staging/rtl8187se: Remove duplicated code by using an offset
authorPeter Huewe <peterhuewe@gmx.de>
Wed, 13 Feb 2013 03:05:25 +0000 (04:05 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 15 Feb 2013 18:28:37 +0000 (10:28 -0800)
In SetAntennaConfig87SE both branches of if (bAntDiversity) do exactly
the same, except that there is an offset of 0x80 for the register values
if bAntDiversity is true.

-> Consolidate both branches and assign the offset if necessary.

Signed-off-by: Peter Huewe <peterhuewe@gmx.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/rtl8187se/r8185b_init.c

index 005fb0bce4868454b1e40697b38db092b8d2a449..2ca857d4244f2206508a65b119776f7fa7d69510 100644 (file)
@@ -284,62 +284,38 @@ bool SetAntennaConfig87SE(struct net_device *dev,
 {
        struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
        bool   bAntennaSwitched = true;
+       u8      ant_diversity_offset = 0x00; /* 0x00 = disabled, 0x80 = enabled */
 
        /* printk("SetAntennaConfig87SE(): DefaultAnt(%d), bAntDiversity(%d)\n", DefaultAnt, bAntDiversity); */
 
        /* Threshold for antenna diversity. */
        write_phy_cck(dev, 0x0c, 0x09); /* Reg0c : 09 */
 
-       if (bAntDiversity) {    /*      Enable Antenna Diversity. */
-               if (DefaultAnt == 1) {  /* aux antenna */
-
-                       /* Mac register, aux antenna */
-                       write_nic_byte(dev, ANTSEL, 0x00);
-
-                       /* Config CCK RX antenna. */
-                       write_phy_cck(dev, 0x11, 0xbb); /* Reg11 : bb */
-                       write_phy_cck(dev, 0x01, 0xc7); /* Reg01 : c7 */
-
-                       /* Config OFDM RX antenna. */
-                       write_phy_ofdm(dev, 0x0D, 0x54);        /* Reg0d : 54 */
-                       write_phy_ofdm(dev, 0x18, 0xb2);        /* Reg18 : b2 */
-               } else { /*  use main antenna */
-                       /* Mac register, main antenna */
-                       write_nic_byte(dev, ANTSEL, 0x03);
-                       /* base band */
-                       /*  Config CCK RX antenna. */
-                       write_phy_cck(dev, 0x11, 0x9b); /* Reg11 : 9b */
-                       write_phy_cck(dev, 0x01, 0xc7); /* Reg01 : c7 */
-
-                       /* Config OFDM RX antenna. */
-                       write_phy_ofdm(dev, 0x0d, 0x5c);  /* Reg0d : 5c */
-                       write_phy_ofdm(dev, 0x18, 0xb2);  /* Reg18 : b2 */
-               }
-       } else {
-               /* Disable Antenna Diversity. */
-               if (DefaultAnt == 1) { /* aux Antenna */
-                       /* Mac register, aux antenna */
-                       write_nic_byte(dev, ANTSEL, 0x00);
-
-                       /* Config CCK RX antenna. */
-                       write_phy_cck(dev, 0x11, 0xbb); /* Reg11 : bb */
-                       write_phy_cck(dev, 0x01, 0x47); /* Reg01 : 47 */
-
-                       /* Config OFDM RX antenna. */
-                       write_phy_ofdm(dev, 0x0D, 0x54);        /* Reg0d : 54 */
-                       write_phy_ofdm(dev, 0x18, 0x32);        /* Reg18 : 32 */
-               } else { /* main Antenna */
-                       /* Mac register, main antenna */
-                       write_nic_byte(dev, ANTSEL, 0x03);
-
-                       /* Config CCK RX antenna.       */
-                       write_phy_cck(dev, 0x11, 0x9b); /* Reg11 : 9b */
-                       write_phy_cck(dev, 0x01, 0x47); /* Reg01 : 47 */
-
-                       /* Config OFDM RX antenna. */
-                       write_phy_ofdm(dev, 0x0D, 0x5c); /* Reg0d : 5c */
-                       write_phy_ofdm(dev, 0x18, 0x32); /*Reg18 : 32 */
-               }
+       if (bAntDiversity)      /*      Enable Antenna Diversity. */
+               ant_diversity_offset = 0x80;
+
+       if (DefaultAnt == 1) { /* aux Antenna */
+               /* Mac register, aux antenna */
+               write_nic_byte(dev, ANTSEL, 0x00);
+
+               /* Config CCK RX antenna. */
+               write_phy_cck(dev, 0x11, 0xbb); /* Reg11 : bb */
+               write_phy_cck(dev, 0x01, 0x47|ant_diversity_offset); /* Reg01 : 47 | ant_diversity_offset */
+
+               /* Config OFDM RX antenna. */
+               write_phy_ofdm(dev, 0x0D, 0x54);        /* Reg0d : 54 */
+               write_phy_ofdm(dev, 0x18, 0x32|ant_diversity_offset);   /* Reg18 : 32 */
+       } else { /* main Antenna */
+               /* Mac register, main antenna */
+               write_nic_byte(dev, ANTSEL, 0x03);
+
+               /* Config CCK RX antenna.       */
+               write_phy_cck(dev, 0x11, 0x9b); /* Reg11 : 9b */
+               write_phy_cck(dev, 0x01, 0x47|ant_diversity_offset); /* Reg01 : 47 */
+
+               /* Config OFDM RX antenna. */
+               write_phy_ofdm(dev, 0x0D, 0x5c); /* Reg0d : 5c */
+               write_phy_ofdm(dev, 0x18, 0x32|ant_diversity_offset); /*Reg18 : 32 */
        }
        priv->CurrAntennaIndex = DefaultAnt; /* Update default settings. */
        return  bAntennaSwitched;