b43: don't duplicate common PHY read/write ops
authorRafał Miłecki <zajec5@gmail.com>
Thu, 31 Jul 2014 19:59:43 +0000 (21:59 +0200)
committerJohn W. Linville <linville@tuxdriver.com>
Mon, 25 Aug 2014 20:00:42 +0000 (16:00 -0400)
Most of the PHYs use the same way of accessing registers, so move that
code to the shared place. An exception is G-PHY which sometimes access
A-PHY regs and requires special handling.

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/b43/phy_common.c
drivers/net/wireless/b43/phy_ht.c
drivers/net/wireless/b43/phy_lcn.c
drivers/net/wireless/b43/phy_lp.c
drivers/net/wireless/b43/phy_n.c

index c868748b3f9e69a0dbf1e669bb2989d9cd7c6f26..08ca524664e6acfe49f3a4fd2a14abc691af118f 100644 (file)
@@ -274,7 +274,12 @@ u16 b43_phy_read(struct b43_wldev *dev, u16 reg)
 {
        assert_mac_suspended(dev);
        dev->phy.writes_counter = 0;
-       return dev->phy.ops->phy_read(dev, reg);
+
+       if (dev->phy.ops->phy_read)
+               return dev->phy.ops->phy_read(dev, reg);
+
+       b43_write16(dev, B43_MMIO_PHY_CONTROL, reg);
+       return b43_read16(dev, B43_MMIO_PHY_DATA);
 }
 
 void b43_phy_write(struct b43_wldev *dev, u16 reg, u16 value)
@@ -285,7 +290,12 @@ void b43_phy_write(struct b43_wldev *dev, u16 reg, u16 value)
                b43_read16(dev, B43_MMIO_PHY_VER);
                dev->phy.writes_counter = 1;
        }
-       dev->phy.ops->phy_write(dev, reg, value);
+
+       if (dev->phy.ops->phy_write)
+               return dev->phy.ops->phy_write(dev, reg, value);
+
+       b43_write16(dev, B43_MMIO_PHY_CONTROL, reg);
+       b43_write16(dev, B43_MMIO_PHY_DATA, value);
 }
 
 void b43_phy_copy(struct b43_wldev *dev, u16 destreg, u16 srcreg)
index f2974c6b1c01fa3ddd11753a74badac91bc9b43e..8b0b4b6852fddc4180968e0af9fb297858af1943 100644 (file)
@@ -1071,18 +1071,6 @@ static unsigned int b43_phy_ht_op_get_default_chan(struct b43_wldev *dev)
  * R/W ops.
  **************************************************/
 
-static u16 b43_phy_ht_op_read(struct b43_wldev *dev, u16 reg)
-{
-       b43_write16(dev, B43_MMIO_PHY_CONTROL, reg);
-       return b43_read16(dev, B43_MMIO_PHY_DATA);
-}
-
-static void b43_phy_ht_op_write(struct b43_wldev *dev, u16 reg, u16 value)
-{
-       b43_write16(dev, B43_MMIO_PHY_CONTROL, reg);
-       b43_write16(dev, B43_MMIO_PHY_DATA, value);
-}
-
 static void b43_phy_ht_op_maskset(struct b43_wldev *dev, u16 reg, u16 mask,
                                 u16 set)
 {
@@ -1126,8 +1114,6 @@ const struct b43_phy_operations b43_phyops_ht = {
        .free                   = b43_phy_ht_op_free,
        .prepare_structs        = b43_phy_ht_op_prepare_structs,
        .init                   = b43_phy_ht_op_init,
-       .phy_read               = b43_phy_ht_op_read,
-       .phy_write              = b43_phy_ht_op_write,
        .phy_maskset            = b43_phy_ht_op_maskset,
        .radio_read             = b43_phy_ht_op_radio_read,
        .radio_write            = b43_phy_ht_op_radio_write,
index e76bbdf3247e9b095af94bf907b2439f3f25f5f3..bf29c3eb00953d0faef6ea4d4a4bb6a23e406a1b 100644 (file)
@@ -810,18 +810,6 @@ static void b43_phy_lcn_op_adjust_txpower(struct b43_wldev *dev)
  * R/W ops.
  **************************************************/
 
-static u16 b43_phy_lcn_op_read(struct b43_wldev *dev, u16 reg)
-{
-       b43_write16(dev, B43_MMIO_PHY_CONTROL, reg);
-       return b43_read16(dev, B43_MMIO_PHY_DATA);
-}
-
-static void b43_phy_lcn_op_write(struct b43_wldev *dev, u16 reg, u16 value)
-{
-       b43_write16(dev, B43_MMIO_PHY_CONTROL, reg);
-       b43_write16(dev, B43_MMIO_PHY_DATA, value);
-}
-
 static void b43_phy_lcn_op_maskset(struct b43_wldev *dev, u16 reg, u16 mask,
                                   u16 set)
 {
@@ -855,8 +843,6 @@ const struct b43_phy_operations b43_phyops_lcn = {
        .free                   = b43_phy_lcn_op_free,
        .prepare_structs        = b43_phy_lcn_op_prepare_structs,
        .init                   = b43_phy_lcn_op_init,
-       .phy_read               = b43_phy_lcn_op_read,
-       .phy_write              = b43_phy_lcn_op_write,
        .phy_maskset            = b43_phy_lcn_op_maskset,
        .radio_read             = b43_phy_lcn_op_radio_read,
        .radio_write            = b43_phy_lcn_op_radio_write,
index 92190dacf6895c31cfbd9748930465e4dc5a4f59..1e9bae68b62157e3b3d2f1875906bb6fa982a615 100644 (file)
@@ -1985,18 +1985,6 @@ static void lpphy_calibration(struct b43_wldev *dev)
        b43_mac_enable(dev);
 }
 
-static u16 b43_lpphy_op_read(struct b43_wldev *dev, u16 reg)
-{
-       b43_write16(dev, B43_MMIO_PHY_CONTROL, reg);
-       return b43_read16(dev, B43_MMIO_PHY_DATA);
-}
-
-static void b43_lpphy_op_write(struct b43_wldev *dev, u16 reg, u16 value)
-{
-       b43_write16(dev, B43_MMIO_PHY_CONTROL, reg);
-       b43_write16(dev, B43_MMIO_PHY_DATA, value);
-}
-
 static void b43_lpphy_op_maskset(struct b43_wldev *dev, u16 reg, u16 mask,
                                 u16 set)
 {
@@ -2713,8 +2701,6 @@ const struct b43_phy_operations b43_phyops_lp = {
        .free                   = b43_lpphy_op_free,
        .prepare_structs        = b43_lpphy_op_prepare_structs,
        .init                   = b43_lpphy_op_init,
-       .phy_read               = b43_lpphy_op_read,
-       .phy_write              = b43_lpphy_op_write,
        .phy_maskset            = b43_lpphy_op_maskset,
        .radio_read             = b43_lpphy_op_radio_read,
        .radio_write            = b43_lpphy_op_radio_write,
index b04aa34b027711f2de379cef7fcdf1ba73b7a4b7..55653186b575d7b7976ff1fc247a8a22b506736c 100644 (file)
@@ -6497,20 +6497,6 @@ static inline void check_phyreg(struct b43_wldev *dev, u16 offset)
 #endif /* B43_DEBUG */
 }
 
-static u16 b43_nphy_op_read(struct b43_wldev *dev, u16 reg)
-{
-       check_phyreg(dev, reg);
-       b43_write16(dev, B43_MMIO_PHY_CONTROL, reg);
-       return b43_read16(dev, B43_MMIO_PHY_DATA);
-}
-
-static void b43_nphy_op_write(struct b43_wldev *dev, u16 reg, u16 value)
-{
-       check_phyreg(dev, reg);
-       b43_write16(dev, B43_MMIO_PHY_CONTROL, reg);
-       b43_write16(dev, B43_MMIO_PHY_DATA, value);
-}
-
 static void b43_nphy_op_maskset(struct b43_wldev *dev, u16 reg, u16 mask,
                                 u16 set)
 {
@@ -6653,8 +6639,6 @@ const struct b43_phy_operations b43_phyops_n = {
        .free                   = b43_nphy_op_free,
        .prepare_structs        = b43_nphy_op_prepare_structs,
        .init                   = b43_nphy_op_init,
-       .phy_read               = b43_nphy_op_read,
-       .phy_write              = b43_nphy_op_write,
        .phy_maskset            = b43_nphy_op_maskset,
        .radio_read             = b43_nphy_op_radio_read,
        .radio_write            = b43_nphy_op_radio_write,