aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafał Miłecki <zajec5@gmail.com>2014-07-31 15:59:43 -0400
committerJohn W. Linville <linville@tuxdriver.com>2014-08-25 16:00:42 -0400
commitd342b95dd735014a590f9051b1ba227eb54ca8f6 (patch)
tree2be91cea3fcb03b371882188b50236eac8c51820
parent6247d2aa5188ac0ace33d8390341075c04107218 (diff)
b43: don't duplicate common PHY read/write ops
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>
-rw-r--r--drivers/net/wireless/b43/phy_common.c14
-rw-r--r--drivers/net/wireless/b43/phy_ht.c14
-rw-r--r--drivers/net/wireless/b43/phy_lcn.c14
-rw-r--r--drivers/net/wireless/b43/phy_lp.c14
-rw-r--r--drivers/net/wireless/b43/phy_n.c16
5 files changed, 12 insertions, 60 deletions
diff --git a/drivers/net/wireless/b43/phy_common.c b/drivers/net/wireless/b43/phy_common.c
index c868748b3f9e..08ca524664e6 100644
--- a/drivers/net/wireless/b43/phy_common.c
+++ b/drivers/net/wireless/b43/phy_common.c
@@ -274,7 +274,12 @@ u16 b43_phy_read(struct b43_wldev *dev, u16 reg)
274{ 274{
275 assert_mac_suspended(dev); 275 assert_mac_suspended(dev);
276 dev->phy.writes_counter = 0; 276 dev->phy.writes_counter = 0;
277 return dev->phy.ops->phy_read(dev, reg); 277
278 if (dev->phy.ops->phy_read)
279 return dev->phy.ops->phy_read(dev, reg);
280
281 b43_write16(dev, B43_MMIO_PHY_CONTROL, reg);
282 return b43_read16(dev, B43_MMIO_PHY_DATA);
278} 283}
279 284
280void b43_phy_write(struct b43_wldev *dev, u16 reg, u16 value) 285void 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)
285 b43_read16(dev, B43_MMIO_PHY_VER); 290 b43_read16(dev, B43_MMIO_PHY_VER);
286 dev->phy.writes_counter = 1; 291 dev->phy.writes_counter = 1;
287 } 292 }
288 dev->phy.ops->phy_write(dev, reg, value); 293
294 if (dev->phy.ops->phy_write)
295 return dev->phy.ops->phy_write(dev, reg, value);
296
297 b43_write16(dev, B43_MMIO_PHY_CONTROL, reg);
298 b43_write16(dev, B43_MMIO_PHY_DATA, value);
289} 299}
290 300
291void b43_phy_copy(struct b43_wldev *dev, u16 destreg, u16 srcreg) 301void b43_phy_copy(struct b43_wldev *dev, u16 destreg, u16 srcreg)
diff --git a/drivers/net/wireless/b43/phy_ht.c b/drivers/net/wireless/b43/phy_ht.c
index f2974c6b1c01..8b0b4b6852fd 100644
--- a/drivers/net/wireless/b43/phy_ht.c
+++ b/drivers/net/wireless/b43/phy_ht.c
@@ -1071,18 +1071,6 @@ static unsigned int b43_phy_ht_op_get_default_chan(struct b43_wldev *dev)
1071 * R/W ops. 1071 * R/W ops.
1072 **************************************************/ 1072 **************************************************/
1073 1073
1074static u16 b43_phy_ht_op_read(struct b43_wldev *dev, u16 reg)
1075{
1076 b43_write16(dev, B43_MMIO_PHY_CONTROL, reg);
1077 return b43_read16(dev, B43_MMIO_PHY_DATA);
1078}
1079
1080static void b43_phy_ht_op_write(struct b43_wldev *dev, u16 reg, u16 value)
1081{
1082 b43_write16(dev, B43_MMIO_PHY_CONTROL, reg);
1083 b43_write16(dev, B43_MMIO_PHY_DATA, value);
1084}
1085
1086static void b43_phy_ht_op_maskset(struct b43_wldev *dev, u16 reg, u16 mask, 1074static void b43_phy_ht_op_maskset(struct b43_wldev *dev, u16 reg, u16 mask,
1087 u16 set) 1075 u16 set)
1088{ 1076{
@@ -1126,8 +1114,6 @@ const struct b43_phy_operations b43_phyops_ht = {
1126 .free = b43_phy_ht_op_free, 1114 .free = b43_phy_ht_op_free,
1127 .prepare_structs = b43_phy_ht_op_prepare_structs, 1115 .prepare_structs = b43_phy_ht_op_prepare_structs,
1128 .init = b43_phy_ht_op_init, 1116 .init = b43_phy_ht_op_init,
1129 .phy_read = b43_phy_ht_op_read,
1130 .phy_write = b43_phy_ht_op_write,
1131 .phy_maskset = b43_phy_ht_op_maskset, 1117 .phy_maskset = b43_phy_ht_op_maskset,
1132 .radio_read = b43_phy_ht_op_radio_read, 1118 .radio_read = b43_phy_ht_op_radio_read,
1133 .radio_write = b43_phy_ht_op_radio_write, 1119 .radio_write = b43_phy_ht_op_radio_write,
diff --git a/drivers/net/wireless/b43/phy_lcn.c b/drivers/net/wireless/b43/phy_lcn.c
index e76bbdf3247e..bf29c3eb0095 100644
--- a/drivers/net/wireless/b43/phy_lcn.c
+++ b/drivers/net/wireless/b43/phy_lcn.c
@@ -810,18 +810,6 @@ static void b43_phy_lcn_op_adjust_txpower(struct b43_wldev *dev)
810 * R/W ops. 810 * R/W ops.
811 **************************************************/ 811 **************************************************/
812 812
813static u16 b43_phy_lcn_op_read(struct b43_wldev *dev, u16 reg)
814{
815 b43_write16(dev, B43_MMIO_PHY_CONTROL, reg);
816 return b43_read16(dev, B43_MMIO_PHY_DATA);
817}
818
819static void b43_phy_lcn_op_write(struct b43_wldev *dev, u16 reg, u16 value)
820{
821 b43_write16(dev, B43_MMIO_PHY_CONTROL, reg);
822 b43_write16(dev, B43_MMIO_PHY_DATA, value);
823}
824
825static void b43_phy_lcn_op_maskset(struct b43_wldev *dev, u16 reg, u16 mask, 813static void b43_phy_lcn_op_maskset(struct b43_wldev *dev, u16 reg, u16 mask,
826 u16 set) 814 u16 set)
827{ 815{
@@ -855,8 +843,6 @@ const struct b43_phy_operations b43_phyops_lcn = {
855 .free = b43_phy_lcn_op_free, 843 .free = b43_phy_lcn_op_free,
856 .prepare_structs = b43_phy_lcn_op_prepare_structs, 844 .prepare_structs = b43_phy_lcn_op_prepare_structs,
857 .init = b43_phy_lcn_op_init, 845 .init = b43_phy_lcn_op_init,
858 .phy_read = b43_phy_lcn_op_read,
859 .phy_write = b43_phy_lcn_op_write,
860 .phy_maskset = b43_phy_lcn_op_maskset, 846 .phy_maskset = b43_phy_lcn_op_maskset,
861 .radio_read = b43_phy_lcn_op_radio_read, 847 .radio_read = b43_phy_lcn_op_radio_read,
862 .radio_write = b43_phy_lcn_op_radio_write, 848 .radio_write = b43_phy_lcn_op_radio_write,
diff --git a/drivers/net/wireless/b43/phy_lp.c b/drivers/net/wireless/b43/phy_lp.c
index 92190dacf689..1e9bae68b621 100644
--- a/drivers/net/wireless/b43/phy_lp.c
+++ b/drivers/net/wireless/b43/phy_lp.c
@@ -1985,18 +1985,6 @@ static void lpphy_calibration(struct b43_wldev *dev)
1985 b43_mac_enable(dev); 1985 b43_mac_enable(dev);
1986} 1986}
1987 1987
1988static u16 b43_lpphy_op_read(struct b43_wldev *dev, u16 reg)
1989{
1990 b43_write16(dev, B43_MMIO_PHY_CONTROL, reg);
1991 return b43_read16(dev, B43_MMIO_PHY_DATA);
1992}
1993
1994static void b43_lpphy_op_write(struct b43_wldev *dev, u16 reg, u16 value)
1995{
1996 b43_write16(dev, B43_MMIO_PHY_CONTROL, reg);
1997 b43_write16(dev, B43_MMIO_PHY_DATA, value);
1998}
1999
2000static void b43_lpphy_op_maskset(struct b43_wldev *dev, u16 reg, u16 mask, 1988static void b43_lpphy_op_maskset(struct b43_wldev *dev, u16 reg, u16 mask,
2001 u16 set) 1989 u16 set)
2002{ 1990{
@@ -2713,8 +2701,6 @@ const struct b43_phy_operations b43_phyops_lp = {
2713 .free = b43_lpphy_op_free, 2701 .free = b43_lpphy_op_free,
2714 .prepare_structs = b43_lpphy_op_prepare_structs, 2702 .prepare_structs = b43_lpphy_op_prepare_structs,
2715 .init = b43_lpphy_op_init, 2703 .init = b43_lpphy_op_init,
2716 .phy_read = b43_lpphy_op_read,
2717 .phy_write = b43_lpphy_op_write,
2718 .phy_maskset = b43_lpphy_op_maskset, 2704 .phy_maskset = b43_lpphy_op_maskset,
2719 .radio_read = b43_lpphy_op_radio_read, 2705 .radio_read = b43_lpphy_op_radio_read,
2720 .radio_write = b43_lpphy_op_radio_write, 2706 .radio_write = b43_lpphy_op_radio_write,
diff --git a/drivers/net/wireless/b43/phy_n.c b/drivers/net/wireless/b43/phy_n.c
index b04aa34b0277..55653186b575 100644
--- a/drivers/net/wireless/b43/phy_n.c
+++ b/drivers/net/wireless/b43/phy_n.c
@@ -6497,20 +6497,6 @@ static inline void check_phyreg(struct b43_wldev *dev, u16 offset)
6497#endif /* B43_DEBUG */ 6497#endif /* B43_DEBUG */
6498} 6498}
6499 6499
6500static u16 b43_nphy_op_read(struct b43_wldev *dev, u16 reg)
6501{
6502 check_phyreg(dev, reg);
6503 b43_write16(dev, B43_MMIO_PHY_CONTROL, reg);
6504 return b43_read16(dev, B43_MMIO_PHY_DATA);
6505}
6506
6507static void b43_nphy_op_write(struct b43_wldev *dev, u16 reg, u16 value)
6508{
6509 check_phyreg(dev, reg);
6510 b43_write16(dev, B43_MMIO_PHY_CONTROL, reg);
6511 b43_write16(dev, B43_MMIO_PHY_DATA, value);
6512}
6513
6514static void b43_nphy_op_maskset(struct b43_wldev *dev, u16 reg, u16 mask, 6500static void b43_nphy_op_maskset(struct b43_wldev *dev, u16 reg, u16 mask,
6515 u16 set) 6501 u16 set)
6516{ 6502{
@@ -6653,8 +6639,6 @@ const struct b43_phy_operations b43_phyops_n = {
6653 .free = b43_nphy_op_free, 6639 .free = b43_nphy_op_free,
6654 .prepare_structs = b43_nphy_op_prepare_structs, 6640 .prepare_structs = b43_nphy_op_prepare_structs,
6655 .init = b43_nphy_op_init, 6641 .init = b43_nphy_op_init,
6656 .phy_read = b43_nphy_op_read,
6657 .phy_write = b43_nphy_op_write,
6658 .phy_maskset = b43_nphy_op_maskset, 6642 .phy_maskset = b43_nphy_op_maskset,
6659 .radio_read = b43_nphy_op_radio_read, 6643 .radio_read = b43_nphy_op_radio_read,
6660 .radio_write = b43_nphy_op_radio_write, 6644 .radio_write = b43_nphy_op_radio_write,