]> err.no Git - linux-2.6/commitdiff
[PATCH] rt2x00: Cleanup if-statements
authorIvo van Doorn <ivdoorn@gmail.com>
Sat, 13 Oct 2007 14:26:42 +0000 (16:26 +0200)
committerDavid S. Miller <davem@davemloft.net>
Mon, 28 Jan 2008 23:02:54 +0000 (15:02 -0800)
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>
drivers/net/wireless/rt2x00/rt2400pci.c
drivers/net/wireless/rt2x00/rt2500pci.c
drivers/net/wireless/rt2x00/rt2500usb.c
drivers/net/wireless/rt2x00/rt2500usb.h
drivers/net/wireless/rt2x00/rt2x00.h
drivers/net/wireless/rt2x00/rt61pci.c
drivers/net/wireless/rt2x00/rt73usb.c

index 5b3adbae482011ffebfcfe9216e8d392e18f587b..fc162122617e881baadcb6c46714f941a8bd2317 100644 (file)
@@ -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_OFF_PERIOD, 30);
-
-       if (rt2x00dev->led_mode == LED_MODE_TXRX_ACTIVITY) {
-               rt2x00_set_field32(&reg, LEDCSR_LINK, 1);
-               rt2x00_set_field32(&reg, LEDCSR_ACTIVITY, 0);
-       } 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);
-       }
-
+       rt2x00_set_field32(&reg, LEDCSR_LINK,
+                          (rt2x00dev->led_mode != LED_MODE_ASUS));
+       rt2x00_set_field32(&reg, LEDCSR_ACTIVITY,
+                          (rt2x00dev->led_mode != LED_MODE_TXRX_ACTIVITY));
        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);
-       if (queue == IEEE80211_TX_QUEUE_DATA0)
-               rt2x00_set_field32(&reg, TXCSR0_KICK_PRIO, 1);
-       else if (queue == IEEE80211_TX_QUEUE_DATA1)
-               rt2x00_set_field32(&reg, TXCSR0_KICK_TX, 1);
-       else if (queue == IEEE80211_TX_QUEUE_AFTER_BEACON)
-               rt2x00_set_field32(&reg, TXCSR0_KICK_ATIM, 1);
+       rt2x00_set_field32(&reg, TXCSR0_KICK_PRIO,
+                          (queue == IEEE80211_TX_QUEUE_DATA0));
+       rt2x00_set_field32(&reg, TXCSR0_KICK_TX,
+                          (queue == IEEE80211_TX_QUEUE_DATA1));
+       rt2x00_set_field32(&reg, TXCSR0_KICK_ATIM,
+                          (queue == IEEE80211_TX_QUEUE_AFTER_BEACON));
        rt2x00pci_register_write(rt2x00dev, TXCSR0, reg);
 }
 
index 958b148d8f50e5cdfa3cd1eb5b6cf4cbf3619bab..869b1a7cec73410eb85743e2dffd6b73be12df38 100644 (file)
@@ -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_OFF_PERIOD, 30);
-
-       if (rt2x00dev->led_mode == LED_MODE_TXRX_ACTIVITY) {
-               rt2x00_set_field32(&reg, LEDCSR_LINK, 1);
-               rt2x00_set_field32(&reg, LEDCSR_ACTIVITY, 0);
-       } 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);
-       }
-
+       rt2x00_set_field32(&reg, LEDCSR_LINK,
+                          (rt2x00dev->led_mode != LED_MODE_ASUS));
+       rt2x00_set_field32(&reg, LEDCSR_ACTIVITY,
+                          (rt2x00dev->led_mode != LED_MODE_TXRX_ACTIVITY));
        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);
-       if (queue == IEEE80211_TX_QUEUE_DATA0)
-               rt2x00_set_field32(&reg, TXCSR0_KICK_PRIO, 1);
-       else if (queue == IEEE80211_TX_QUEUE_DATA1)
-               rt2x00_set_field32(&reg, TXCSR0_KICK_TX, 1);
-       else if (queue == IEEE80211_TX_QUEUE_AFTER_BEACON)
-               rt2x00_set_field32(&reg, TXCSR0_KICK_ATIM, 1);
+       rt2x00_set_field32(&reg, TXCSR0_KICK_PRIO,
+                          (queue == IEEE80211_TX_QUEUE_DATA0));
+       rt2x00_set_field32(&reg, TXCSR0_KICK_TX,
+                          (queue == IEEE80211_TX_QUEUE_DATA1));
+       rt2x00_set_field32(&reg, TXCSR0_KICK_ATIM,
+                          (queue == IEEE80211_TX_QUEUE_AFTER_BEACON));
        rt2x00pci_register_write(rt2x00dev, TXCSR0, reg);
 }
 
index 60f729044427216ea850bac057da78f336e0586d..4f8e388700c04ffd1763b9aaec2a24747f823a75 100644 (file)
@@ -517,18 +517,10 @@ static void rt2500usb_enable_led(struct rt2x00_dev *rt2x00dev)
        rt2500usb_register_write(rt2x00dev, MAC_CSR21, reg);
 
        rt2500usb_register_read(rt2x00dev, MAC_CSR20, &reg);
-
-       if (rt2x00dev->led_mode == LED_MODE_TXRX_ACTIVITY) {
-               rt2x00_set_field16(&reg, MAC_CSR20_LINK, 1);
-               rt2x00_set_field16(&reg, MAC_CSR20_ACTIVITY, 0);
-       } 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);
-       }
-
+       rt2x00_set_field16(&reg, MAC_CSR20_LINK,
+                          (rt2x00dev->led_mode != LED_MODE_ASUS));
+       rt2x00_set_field16(&reg, MAC_CSR20_ACTIVITY,
+                          (rt2x00dev->led_mode != LED_MODE_TXRX_ACTIVITY));
        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) {
                rt2500usb_register_read(rt2x00dev, PHY_CSR2, &reg);
-               reg &= ~0x0002;
+               rt2x00_set_field16(&reg, PHY_CSR2_LNA, 0);
        } 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);
 
index b18d56e73cf1cf8c5a5ed7d2316bf9f67e8802d1..2741840fa14acbaeb9820c971e3e7c3285c27362 100644 (file)
 
 /*
  * MAC configuration registers.
+ */
+
+/*
  * 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_LNA                   FIELD16(0x0002)
+#define PHY_CSR2_LNA_MODE              FIELD16(0x3000)
+
+/*
+ * PHY_CSR3: RX MAC configuration.
+ */
 #define PHY_CSR3                       0x04c6
 
 /*
index e7533e2ccd2eefca9e37901df60f5b9ed9c51ba4..4054e54606342443a6491e7f6ae708c96e481aa5 100644 (file)
  */
 static inline int is_rts_frame(u16 fc)
 {
-       return !!(((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_CTL) &&
-                 ((fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_RTS));
+       return (((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_CTL) &&
+               ((fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_RTS));
 }
 
 static inline int is_cts_frame(u16 fc)
 {
-       return !!(((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_CTL) &&
-                 ((fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_CTS));
+       return (((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_CTL) &&
+               ((fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_CTS));
 }
 
 static inline int is_probe_resp(u16 fc)
 {
-       return !!(((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_MGMT) &&
-                 ((fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_PROBE_RESP));
+       return (((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_MGMT) &&
+               ((fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_PROBE_RESP));
 }
 
 /*
index aebc96344cd888ea931630fb3a7db55a4f002055..c57d39002bfb01872f56fe29499a4c37447d8fb6 100644 (file)
@@ -428,7 +428,7 @@ static void rt61pci_config_antenna_5x(struct rt2x00_dev *rt2x00dev,
        case ANTENNA_HW_DIVERSITY:
                rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA, 2);
                rt2x00_set_field8(&r4, BBP_R4_RX_FRAME_END,
-                                 !!(rt2x00dev->curr_hwmode != HWMODE_A));
+                                 (rt2x00dev->curr_hwmode != HWMODE_A));
                break;
        case ANTENNA_A:
                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) {
                sel = antenna_sel_a;
                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 {
                sel = antenna_sel_bg;
                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++)
                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)
 {
        u32 reg;
-       u16 led_reg;
        u8 arg0;
        u8 arg1;
 
@@ -736,15 +735,14 @@ static void rt61pci_enable_led(struct rt2x00_dev *rt2x00dev)
        rt2x00_set_field32(&reg, MAC_CSR14_OFF_PERIOD, 30);
        rt2x00pci_register_write(rt2x00dev, MAC_CSR14, reg);
 
-       led_reg = rt2x00dev->led_reg;
-       rt2x00_set_field16(&led_reg, MCU_LEDCS_RADIO_STATUS, 1);
-       if (rt2x00dev->rx_status.phymode == MODE_IEEE80211A)
-               rt2x00_set_field16(&led_reg, MCU_LEDCS_LINK_A_STATUS, 1);
-       else
-               rt2x00_set_field16(&led_reg, MCU_LEDCS_LINK_BG_STATUS, 1);
+       rt2x00_set_field16(&rt2x00dev->led_reg, MCU_LEDCS_RADIO_STATUS, 1);
+       rt2x00_set_field16(&rt2x00dev->led_reg, MCU_LEDCS_LINK_A_STATUS,
+                          (rt2x00dev->rx_status.phymode == MODE_IEEE80211A));
+       rt2x00_set_field16(&rt2x00dev->led_reg, MCU_LEDCS_LINK_BG_STATUS,
+                          (rt2x00dev->rx_status.phymode != MODE_IEEE80211A));
 
-       arg0 = led_reg & 0xff;
-       arg1 = (led_reg >> 8) & 0xff;
+       arg0 = rt2x00dev->led_reg & 0xff;
+       arg1 = (rt2x00dev->led_reg >> 8) & 0xff;
 
        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);
-       if (queue == IEEE80211_TX_QUEUE_DATA0)
-               rt2x00_set_field32(&reg, TX_CNTL_CSR_KICK_TX_AC0, 1);
-       else if (queue == IEEE80211_TX_QUEUE_DATA1)
-               rt2x00_set_field32(&reg, TX_CNTL_CSR_KICK_TX_AC1, 1);
-       else if (queue == IEEE80211_TX_QUEUE_DATA2)
-               rt2x00_set_field32(&reg, TX_CNTL_CSR_KICK_TX_AC2, 1);
-       else if (queue == IEEE80211_TX_QUEUE_DATA3)
-               rt2x00_set_field32(&reg, TX_CNTL_CSR_KICK_TX_AC3, 1);
-       else if (queue == IEEE80211_TX_QUEUE_DATA4)
-               rt2x00_set_field32(&reg, TX_CNTL_CSR_KICK_TX_MGMT, 1);
+       rt2x00_set_field32(&reg, TX_CNTL_CSR_KICK_TX_AC0,
+                          (queue == IEEE80211_TX_QUEUE_DATA0));
+       rt2x00_set_field32(&reg, TX_CNTL_CSR_KICK_TX_AC1,
+                          (queue == IEEE80211_TX_QUEUE_DATA1));
+       rt2x00_set_field32(&reg, TX_CNTL_CSR_KICK_TX_AC2,
+                          (queue == IEEE80211_TX_QUEUE_DATA2));
+       rt2x00_set_field32(&reg, TX_CNTL_CSR_KICK_TX_AC3,
+                          (queue == IEEE80211_TX_QUEUE_DATA3));
+       rt2x00_set_field32(&reg, TX_CNTL_CSR_KICK_TX_MGMT,
+                          (queue == IEEE80211_TX_QUEUE_DATA4));
        rt2x00pci_register_write(rt2x00dev, TX_CNTL_CSR, reg);
 }
 
index 18324210c13a2a2e4a525b1ee682c0ebaf4c9571..e3d5e78661ea64c3aa670ddacb7ef28766a8964e 100644 (file)
@@ -200,8 +200,8 @@ rf_write:
         * all others contain 20 bits.
         */
        rt2x00_set_field32(&reg, PHY_CSR4_NUMBER_OF_BITS,
-                          20 + !!(rt2x00_rf(&rt2x00dev->chip, RF5225) ||
-                                  rt2x00_rf(&rt2x00dev->chip, RF2527)));
+                          20 + (rt2x00_rf(&rt2x00dev->chip, RF5225) ||
+                                rt2x00_rf(&rt2x00dev->chip, RF2527)));
        rt2x00_set_field32(&reg, PHY_CSR4_IF_SELECT, 0);
        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:
                rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA, 2);
                rt2x00_set_field8(&r4, BBP_R4_RX_FRAME_END,
-                                 !!(rt2x00dev->curr_hwmode != HWMODE_A));
+                                 (rt2x00dev->curr_hwmode != HWMODE_A));
                break;
        case ANTENNA_A:
                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) {
                sel = antenna_sel_a;
                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 {
                sel = antenna_sel_bg;
                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++)
                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);
 
        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, 1);
-       else
-               rt2x00_set_field16(&rt2x00dev->led_reg,
-                                  MCU_LEDCS_LINK_BG_STATUS, 1);
+       rt2x00_set_field16(&rt2x00dev->led_reg, MCU_LEDCS_LINK_A_STATUS,
+                          (rt2x00dev->rx_status.phymode == MODE_IEEE80211A));
+       rt2x00_set_field16(&rt2x00dev->led_reg, MCU_LEDCS_LINK_BG_STATUS,
+                          (rt2x00dev->rx_status.phymode != MODE_IEEE80211A));
 
        rt2x00usb_vendor_request_sw(rt2x00dev, USB_LED_CONTROL, 0x0000,
                                    rt2x00dev->led_reg, REGISTER_TIMEOUT);