[PATCH] rt2x00: Cleanup if-statements

Cleanup if-statements for simple 1/0 register field values.

This also fixes a endian bug in rt2500usb when working
with the PHY_CSR2 initialization. As well as a bug
in the enabling of the LED in rt73usb.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Ivo van Doorn 2007-10-13 16:26:42 +02:00 коммит произвёл David S. Miller
Родитель 69f81a2cac
Коммит ddc827f93a
7 изменённых файлов: 83 добавлений и 98 удалений

Просмотреть файл

@ -524,18 +524,10 @@ static void rt2400pci_enable_led(struct rt2x00_dev *rt2x00dev)
rt2x00_set_field32(&reg, LEDCSR_ON_PERIOD, 70); rt2x00_set_field32(&reg, LEDCSR_ON_PERIOD, 70);
rt2x00_set_field32(&reg, LEDCSR_OFF_PERIOD, 30); rt2x00_set_field32(&reg, LEDCSR_OFF_PERIOD, 30);
rt2x00_set_field32(&reg, LEDCSR_LINK,
if (rt2x00dev->led_mode == LED_MODE_TXRX_ACTIVITY) { (rt2x00dev->led_mode != LED_MODE_ASUS));
rt2x00_set_field32(&reg, LEDCSR_LINK, 1); rt2x00_set_field32(&reg, LEDCSR_ACTIVITY,
rt2x00_set_field32(&reg, LEDCSR_ACTIVITY, 0); (rt2x00dev->led_mode != LED_MODE_TXRX_ACTIVITY));
} else if (rt2x00dev->led_mode == LED_MODE_ASUS) {
rt2x00_set_field32(&reg, LEDCSR_LINK, 0);
rt2x00_set_field32(&reg, LEDCSR_ACTIVITY, 1);
} else {
rt2x00_set_field32(&reg, LEDCSR_LINK, 1);
rt2x00_set_field32(&reg, LEDCSR_ACTIVITY, 1);
}
rt2x00pci_register_write(rt2x00dev, LEDCSR, reg); rt2x00pci_register_write(rt2x00dev, LEDCSR, reg);
} }
@ -1110,12 +1102,12 @@ static void rt2400pci_kick_tx_queue(struct rt2x00_dev *rt2x00dev,
} }
rt2x00pci_register_read(rt2x00dev, TXCSR0, &reg); rt2x00pci_register_read(rt2x00dev, TXCSR0, &reg);
if (queue == IEEE80211_TX_QUEUE_DATA0) rt2x00_set_field32(&reg, TXCSR0_KICK_PRIO,
rt2x00_set_field32(&reg, TXCSR0_KICK_PRIO, 1); (queue == IEEE80211_TX_QUEUE_DATA0));
else if (queue == IEEE80211_TX_QUEUE_DATA1) rt2x00_set_field32(&reg, TXCSR0_KICK_TX,
rt2x00_set_field32(&reg, TXCSR0_KICK_TX, 1); (queue == IEEE80211_TX_QUEUE_DATA1));
else if (queue == IEEE80211_TX_QUEUE_AFTER_BEACON) rt2x00_set_field32(&reg, TXCSR0_KICK_ATIM,
rt2x00_set_field32(&reg, TXCSR0_KICK_ATIM, 1); (queue == IEEE80211_TX_QUEUE_AFTER_BEACON));
rt2x00pci_register_write(rt2x00dev, TXCSR0, reg); rt2x00pci_register_write(rt2x00dev, TXCSR0, reg);
} }

Просмотреть файл

@ -563,18 +563,10 @@ static void rt2500pci_enable_led(struct rt2x00_dev *rt2x00dev)
rt2x00_set_field32(&reg, LEDCSR_ON_PERIOD, 70); rt2x00_set_field32(&reg, LEDCSR_ON_PERIOD, 70);
rt2x00_set_field32(&reg, LEDCSR_OFF_PERIOD, 30); rt2x00_set_field32(&reg, LEDCSR_OFF_PERIOD, 30);
rt2x00_set_field32(&reg, LEDCSR_LINK,
if (rt2x00dev->led_mode == LED_MODE_TXRX_ACTIVITY) { (rt2x00dev->led_mode != LED_MODE_ASUS));
rt2x00_set_field32(&reg, LEDCSR_LINK, 1); rt2x00_set_field32(&reg, LEDCSR_ACTIVITY,
rt2x00_set_field32(&reg, LEDCSR_ACTIVITY, 0); (rt2x00dev->led_mode != LED_MODE_TXRX_ACTIVITY));
} else if (rt2x00dev->led_mode == LED_MODE_ASUS) {
rt2x00_set_field32(&reg, LEDCSR_LINK, 0);
rt2x00_set_field32(&reg, LEDCSR_ACTIVITY, 1);
} else {
rt2x00_set_field32(&reg, LEDCSR_LINK, 1);
rt2x00_set_field32(&reg, LEDCSR_ACTIVITY, 1);
}
rt2x00pci_register_write(rt2x00dev, LEDCSR, reg); rt2x00pci_register_write(rt2x00dev, LEDCSR, reg);
} }
@ -1244,12 +1236,12 @@ static void rt2500pci_kick_tx_queue(struct rt2x00_dev *rt2x00dev,
} }
rt2x00pci_register_read(rt2x00dev, TXCSR0, &reg); rt2x00pci_register_read(rt2x00dev, TXCSR0, &reg);
if (queue == IEEE80211_TX_QUEUE_DATA0) rt2x00_set_field32(&reg, TXCSR0_KICK_PRIO,
rt2x00_set_field32(&reg, TXCSR0_KICK_PRIO, 1); (queue == IEEE80211_TX_QUEUE_DATA0));
else if (queue == IEEE80211_TX_QUEUE_DATA1) rt2x00_set_field32(&reg, TXCSR0_KICK_TX,
rt2x00_set_field32(&reg, TXCSR0_KICK_TX, 1); (queue == IEEE80211_TX_QUEUE_DATA1));
else if (queue == IEEE80211_TX_QUEUE_AFTER_BEACON) rt2x00_set_field32(&reg, TXCSR0_KICK_ATIM,
rt2x00_set_field32(&reg, TXCSR0_KICK_ATIM, 1); (queue == IEEE80211_TX_QUEUE_AFTER_BEACON));
rt2x00pci_register_write(rt2x00dev, TXCSR0, reg); rt2x00pci_register_write(rt2x00dev, TXCSR0, reg);
} }

Просмотреть файл

@ -517,18 +517,10 @@ static void rt2500usb_enable_led(struct rt2x00_dev *rt2x00dev)
rt2500usb_register_write(rt2x00dev, MAC_CSR21, reg); rt2500usb_register_write(rt2x00dev, MAC_CSR21, reg);
rt2500usb_register_read(rt2x00dev, MAC_CSR20, &reg); rt2500usb_register_read(rt2x00dev, MAC_CSR20, &reg);
rt2x00_set_field16(&reg, MAC_CSR20_LINK,
if (rt2x00dev->led_mode == LED_MODE_TXRX_ACTIVITY) { (rt2x00dev->led_mode != LED_MODE_ASUS));
rt2x00_set_field16(&reg, MAC_CSR20_LINK, 1); rt2x00_set_field16(&reg, MAC_CSR20_ACTIVITY,
rt2x00_set_field16(&reg, MAC_CSR20_ACTIVITY, 0); (rt2x00dev->led_mode != LED_MODE_TXRX_ACTIVITY));
} else if (rt2x00dev->led_mode == LED_MODE_ASUS) {
rt2x00_set_field16(&reg, MAC_CSR20_LINK, 0);
rt2x00_set_field16(&reg, MAC_CSR20_ACTIVITY, 1);
} else {
rt2x00_set_field16(&reg, MAC_CSR20_LINK, 1);
rt2x00_set_field16(&reg, MAC_CSR20_ACTIVITY, 1);
}
rt2500usb_register_write(rt2x00dev, MAC_CSR20, reg); rt2500usb_register_write(rt2x00dev, MAC_CSR20, reg);
} }
@ -765,9 +757,11 @@ static int rt2500usb_init_registers(struct rt2x00_dev *rt2x00dev)
if (rt2x00_rev(&rt2x00dev->chip) >= RT2570_VERSION_C) { if (rt2x00_rev(&rt2x00dev->chip) >= RT2570_VERSION_C) {
rt2500usb_register_read(rt2x00dev, PHY_CSR2, &reg); rt2500usb_register_read(rt2x00dev, PHY_CSR2, &reg);
reg &= ~0x0002; rt2x00_set_field16(&reg, PHY_CSR2_LNA, 0);
} else { } else {
reg = 0x3002; reg = 0;
rt2x00_set_field16(&reg, PHY_CSR2_LNA, 1);
rt2x00_set_field16(&reg, PHY_CSR2_LNA_MODE, 3);
} }
rt2500usb_register_write(rt2x00dev, PHY_CSR2, reg); rt2500usb_register_write(rt2x00dev, PHY_CSR2, reg);

Просмотреть файл

@ -430,10 +430,21 @@
/* /*
* MAC configuration registers. * MAC configuration registers.
*/
/*
* PHY_CSR2: TX MAC configuration. * PHY_CSR2: TX MAC configuration.
* PHY_CSR3: RX MAC configuration. * NOTE: Both register fields are complete dummy,
* documentation and legacy drivers are unclear un
* what this register means or what fields exists.
*/ */
#define PHY_CSR2 0x04c4 #define PHY_CSR2 0x04c4
#define PHY_CSR2_LNA FIELD16(0x0002)
#define PHY_CSR2_LNA_MODE FIELD16(0x3000)
/*
* PHY_CSR3: RX MAC configuration.
*/
#define PHY_CSR3 0x04c6 #define PHY_CSR3 0x04c6
/* /*

Просмотреть файл

@ -133,20 +133,20 @@
*/ */
static inline int is_rts_frame(u16 fc) static inline int is_rts_frame(u16 fc)
{ {
return !!(((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_CTL) && return (((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_CTL) &&
((fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_RTS)); ((fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_RTS));
} }
static inline int is_cts_frame(u16 fc) static inline int is_cts_frame(u16 fc)
{ {
return !!(((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_CTL) && return (((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_CTL) &&
((fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_CTS)); ((fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_CTS));
} }
static inline int is_probe_resp(u16 fc) static inline int is_probe_resp(u16 fc)
{ {
return !!(((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_MGMT) && return (((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_MGMT) &&
((fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_PROBE_RESP)); ((fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_PROBE_RESP));
} }
/* /*

Просмотреть файл

@ -428,7 +428,7 @@ static void rt61pci_config_antenna_5x(struct rt2x00_dev *rt2x00dev,
case ANTENNA_HW_DIVERSITY: case ANTENNA_HW_DIVERSITY:
rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA, 2); rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA, 2);
rt2x00_set_field8(&r4, BBP_R4_RX_FRAME_END, rt2x00_set_field8(&r4, BBP_R4_RX_FRAME_END,
!!(rt2x00dev->curr_hwmode != HWMODE_A)); (rt2x00dev->curr_hwmode != HWMODE_A));
break; break;
case ANTENNA_A: case ANTENNA_A:
rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA, 1); rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA, 1);
@ -646,17 +646,17 @@ static void rt61pci_config_antenna(struct rt2x00_dev *rt2x00dev,
if (rt2x00dev->curr_hwmode == HWMODE_A) { if (rt2x00dev->curr_hwmode == HWMODE_A) {
sel = antenna_sel_a; sel = antenna_sel_a;
lna = test_bit(CONFIG_EXTERNAL_LNA_A, &rt2x00dev->flags); lna = test_bit(CONFIG_EXTERNAL_LNA_A, &rt2x00dev->flags);
rt2x00_set_field32(&reg, PHY_CSR0_PA_PE_BG, 0);
rt2x00_set_field32(&reg, PHY_CSR0_PA_PE_A, 1);
} else { } else {
sel = antenna_sel_bg; sel = antenna_sel_bg;
lna = test_bit(CONFIG_EXTERNAL_LNA_BG, &rt2x00dev->flags); lna = test_bit(CONFIG_EXTERNAL_LNA_BG, &rt2x00dev->flags);
rt2x00_set_field32(&reg, PHY_CSR0_PA_PE_BG, 1);
rt2x00_set_field32(&reg, PHY_CSR0_PA_PE_A, 0);
} }
rt2x00_set_field32(&reg, PHY_CSR0_PA_PE_BG,
(rt2x00dev->curr_hwmode == HWMODE_B ||
rt2x00dev->curr_hwmode == HWMODE_G));
rt2x00_set_field32(&reg, PHY_CSR0_PA_PE_A,
(rt2x00dev->curr_hwmode == HWMODE_A));
for (i = 0; i < ARRAY_SIZE(antenna_sel_a); i++) for (i = 0; i < ARRAY_SIZE(antenna_sel_a); i++)
rt61pci_bbp_write(rt2x00dev, sel[i].word, sel[i].value[lna]); rt61pci_bbp_write(rt2x00dev, sel[i].word, sel[i].value[lna]);
@ -727,7 +727,6 @@ static void rt61pci_config(struct rt2x00_dev *rt2x00dev,
static void rt61pci_enable_led(struct rt2x00_dev *rt2x00dev) static void rt61pci_enable_led(struct rt2x00_dev *rt2x00dev)
{ {
u32 reg; u32 reg;
u16 led_reg;
u8 arg0; u8 arg0;
u8 arg1; u8 arg1;
@ -736,15 +735,14 @@ static void rt61pci_enable_led(struct rt2x00_dev *rt2x00dev)
rt2x00_set_field32(&reg, MAC_CSR14_OFF_PERIOD, 30); rt2x00_set_field32(&reg, MAC_CSR14_OFF_PERIOD, 30);
rt2x00pci_register_write(rt2x00dev, MAC_CSR14, reg); rt2x00pci_register_write(rt2x00dev, MAC_CSR14, reg);
led_reg = rt2x00dev->led_reg; rt2x00_set_field16(&rt2x00dev->led_reg, MCU_LEDCS_RADIO_STATUS, 1);
rt2x00_set_field16(&led_reg, MCU_LEDCS_RADIO_STATUS, 1); rt2x00_set_field16(&rt2x00dev->led_reg, MCU_LEDCS_LINK_A_STATUS,
if (rt2x00dev->rx_status.phymode == MODE_IEEE80211A) (rt2x00dev->rx_status.phymode == MODE_IEEE80211A));
rt2x00_set_field16(&led_reg, MCU_LEDCS_LINK_A_STATUS, 1); rt2x00_set_field16(&rt2x00dev->led_reg, MCU_LEDCS_LINK_BG_STATUS,
else (rt2x00dev->rx_status.phymode != MODE_IEEE80211A));
rt2x00_set_field16(&led_reg, MCU_LEDCS_LINK_BG_STATUS, 1);
arg0 = led_reg & 0xff; arg0 = rt2x00dev->led_reg & 0xff;
arg1 = (led_reg >> 8) & 0xff; arg1 = (rt2x00dev->led_reg >> 8) & 0xff;
rt61pci_mcu_request(rt2x00dev, MCU_LED, 0xff, arg0, arg1); rt61pci_mcu_request(rt2x00dev, MCU_LED, 0xff, arg0, arg1);
} }
@ -1655,16 +1653,16 @@ static void rt61pci_kick_tx_queue(struct rt2x00_dev *rt2x00dev,
} }
rt2x00pci_register_read(rt2x00dev, TX_CNTL_CSR, &reg); rt2x00pci_register_read(rt2x00dev, TX_CNTL_CSR, &reg);
if (queue == IEEE80211_TX_QUEUE_DATA0) rt2x00_set_field32(&reg, TX_CNTL_CSR_KICK_TX_AC0,
rt2x00_set_field32(&reg, TX_CNTL_CSR_KICK_TX_AC0, 1); (queue == IEEE80211_TX_QUEUE_DATA0));
else if (queue == IEEE80211_TX_QUEUE_DATA1) rt2x00_set_field32(&reg, TX_CNTL_CSR_KICK_TX_AC1,
rt2x00_set_field32(&reg, TX_CNTL_CSR_KICK_TX_AC1, 1); (queue == IEEE80211_TX_QUEUE_DATA1));
else if (queue == IEEE80211_TX_QUEUE_DATA2) rt2x00_set_field32(&reg, TX_CNTL_CSR_KICK_TX_AC2,
rt2x00_set_field32(&reg, TX_CNTL_CSR_KICK_TX_AC2, 1); (queue == IEEE80211_TX_QUEUE_DATA2));
else if (queue == IEEE80211_TX_QUEUE_DATA3) rt2x00_set_field32(&reg, TX_CNTL_CSR_KICK_TX_AC3,
rt2x00_set_field32(&reg, TX_CNTL_CSR_KICK_TX_AC3, 1); (queue == IEEE80211_TX_QUEUE_DATA3));
else if (queue == IEEE80211_TX_QUEUE_DATA4) rt2x00_set_field32(&reg, TX_CNTL_CSR_KICK_TX_MGMT,
rt2x00_set_field32(&reg, TX_CNTL_CSR_KICK_TX_MGMT, 1); (queue == IEEE80211_TX_QUEUE_DATA4));
rt2x00pci_register_write(rt2x00dev, TX_CNTL_CSR, reg); rt2x00pci_register_write(rt2x00dev, TX_CNTL_CSR, reg);
} }

Просмотреть файл

@ -200,8 +200,8 @@ rf_write:
* all others contain 20 bits. * all others contain 20 bits.
*/ */
rt2x00_set_field32(&reg, PHY_CSR4_NUMBER_OF_BITS, rt2x00_set_field32(&reg, PHY_CSR4_NUMBER_OF_BITS,
20 + !!(rt2x00_rf(&rt2x00dev->chip, RF5225) || 20 + (rt2x00_rf(&rt2x00dev->chip, RF5225) ||
rt2x00_rf(&rt2x00dev->chip, RF2527))); rt2x00_rf(&rt2x00dev->chip, RF2527)));
rt2x00_set_field32(&reg, PHY_CSR4_IF_SELECT, 0); rt2x00_set_field32(&reg, PHY_CSR4_IF_SELECT, 0);
rt2x00_set_field32(&reg, PHY_CSR4_BUSY, 1); rt2x00_set_field32(&reg, PHY_CSR4_BUSY, 1);
@ -412,7 +412,7 @@ static void rt73usb_config_antenna_5x(struct rt2x00_dev *rt2x00dev,
case ANTENNA_HW_DIVERSITY: case ANTENNA_HW_DIVERSITY:
rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA, 2); rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA, 2);
rt2x00_set_field8(&r4, BBP_R4_RX_FRAME_END, rt2x00_set_field8(&r4, BBP_R4_RX_FRAME_END,
!!(rt2x00dev->curr_hwmode != HWMODE_A)); (rt2x00dev->curr_hwmode != HWMODE_A));
break; break;
case ANTENNA_A: case ANTENNA_A:
rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA, 1); rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA, 1);
@ -531,17 +531,17 @@ static void rt73usb_config_antenna(struct rt2x00_dev *rt2x00dev,
if (rt2x00dev->curr_hwmode == HWMODE_A) { if (rt2x00dev->curr_hwmode == HWMODE_A) {
sel = antenna_sel_a; sel = antenna_sel_a;
lna = test_bit(CONFIG_EXTERNAL_LNA_A, &rt2x00dev->flags); lna = test_bit(CONFIG_EXTERNAL_LNA_A, &rt2x00dev->flags);
rt2x00_set_field32(&reg, PHY_CSR0_PA_PE_BG, 0);
rt2x00_set_field32(&reg, PHY_CSR0_PA_PE_A, 1);
} else { } else {
sel = antenna_sel_bg; sel = antenna_sel_bg;
lna = test_bit(CONFIG_EXTERNAL_LNA_BG, &rt2x00dev->flags); lna = test_bit(CONFIG_EXTERNAL_LNA_BG, &rt2x00dev->flags);
rt2x00_set_field32(&reg, PHY_CSR0_PA_PE_BG, 1);
rt2x00_set_field32(&reg, PHY_CSR0_PA_PE_A, 0);
} }
rt2x00_set_field32(&reg, PHY_CSR0_PA_PE_BG,
(rt2x00dev->curr_hwmode == HWMODE_B ||
rt2x00dev->curr_hwmode == HWMODE_G));
rt2x00_set_field32(&reg, PHY_CSR0_PA_PE_A,
(rt2x00dev->curr_hwmode == HWMODE_A));
for (i = 0; i < ARRAY_SIZE(antenna_sel_a); i++) for (i = 0; i < ARRAY_SIZE(antenna_sel_a); i++)
rt73usb_bbp_write(rt2x00dev, sel[i].word, sel[i].value[lna]); rt73usb_bbp_write(rt2x00dev, sel[i].word, sel[i].value[lna]);
@ -614,12 +614,10 @@ static void rt73usb_enable_led(struct rt2x00_dev *rt2x00dev)
rt73usb_register_write(rt2x00dev, MAC_CSR14, reg); rt73usb_register_write(rt2x00dev, MAC_CSR14, reg);
rt2x00_set_field16(&rt2x00dev->led_reg, MCU_LEDCS_RADIO_STATUS, 1); rt2x00_set_field16(&rt2x00dev->led_reg, MCU_LEDCS_RADIO_STATUS, 1);
if (rt2x00dev->rx_status.phymode == MODE_IEEE80211A) rt2x00_set_field16(&rt2x00dev->led_reg, MCU_LEDCS_LINK_A_STATUS,
rt2x00_set_field16(&rt2x00dev->led_reg, (rt2x00dev->rx_status.phymode == MODE_IEEE80211A));
MCU_LEDCS_LINK_A_STATUS, 1); rt2x00_set_field16(&rt2x00dev->led_reg, MCU_LEDCS_LINK_BG_STATUS,
else (rt2x00dev->rx_status.phymode != MODE_IEEE80211A));
rt2x00_set_field16(&rt2x00dev->led_reg,
MCU_LEDCS_LINK_BG_STATUS, 1);
rt2x00usb_vendor_request_sw(rt2x00dev, USB_LED_CONTROL, 0x0000, rt2x00usb_vendor_request_sw(rt2x00dev, USB_LED_CONTROL, 0x0000,
rt2x00dev->led_reg, REGISTER_TIMEOUT); rt2x00dev->led_reg, REGISTER_TIMEOUT);