diff options
author | Harvey Harrison <harvey.harrison@gmail.com> | 2008-05-13 21:13:35 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2008-05-14 16:29:50 -0400 |
commit | 6dcdc19e4ba4e6a9ccd733fdb745ad062cf3ea0a (patch) | |
tree | cb0a2b5dd6ada7582664b3d27c6cdbb4da29a152 /drivers/net | |
parent | d6894b5be1d674a31a94ed8f057c9f7d98c53999 (diff) |
b43: use the bitrev helpers rather than rolling a private one
The 4-bit reversal flip_4bit is replaced with the bitrev helper
bitrev8 and a 4-bit shift. The B43_WARN is moved to the location
where a register is read from for checking there. The other caller
explicitly passes an array index which is guaranteed to be within range
and so a B43_WARN is not added there.
Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
Reviewed-by: Michael Buesch <mb@bu3sch.de>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/wireless/b43/phy.c | 27 |
1 files changed, 6 insertions, 21 deletions
diff --git a/drivers/net/wireless/b43/phy.c b/drivers/net/wireless/b43/phy.c index 6378c266549a..305d4cd6fd03 100644 --- a/drivers/net/wireless/b43/phy.c +++ b/drivers/net/wireless/b43/phy.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <linux/delay.h> | 28 | #include <linux/delay.h> |
29 | #include <linux/io.h> | 29 | #include <linux/io.h> |
30 | #include <linux/types.h> | 30 | #include <linux/types.h> |
31 | #include <linux/bitrev.h> | ||
31 | 32 | ||
32 | #include "b43.h" | 33 | #include "b43.h" |
33 | #include "phy.h" | 34 | #include "phy.h" |
@@ -83,25 +84,9 @@ const u8 b43_radio_channel_codes_bg[] = { | |||
83 | 72, 84, | 84 | 72, 84, |
84 | }; | 85 | }; |
85 | 86 | ||
87 | #define bitrev4(tmp) (bitrev8(tmp) >> 4) | ||
86 | static void b43_phy_initg(struct b43_wldev *dev); | 88 | static void b43_phy_initg(struct b43_wldev *dev); |
87 | 89 | ||
88 | /* Reverse the bits of a 4bit value. | ||
89 | * Example: 1101 is flipped 1011 | ||
90 | */ | ||
91 | static u16 flip_4bit(u16 value) | ||
92 | { | ||
93 | u16 flipped = 0x0000; | ||
94 | |||
95 | B43_WARN_ON(value & ~0x000F); | ||
96 | |||
97 | flipped |= (value & 0x0001) << 3; | ||
98 | flipped |= (value & 0x0002) << 1; | ||
99 | flipped |= (value & 0x0004) >> 1; | ||
100 | flipped |= (value & 0x0008) >> 3; | ||
101 | |||
102 | return flipped; | ||
103 | } | ||
104 | |||
105 | static void generate_rfatt_list(struct b43_wldev *dev, | 90 | static void generate_rfatt_list(struct b43_wldev *dev, |
106 | struct b43_rfatt_list *list) | 91 | struct b43_rfatt_list *list) |
107 | { | 92 | { |
@@ -2891,13 +2876,13 @@ b43_radio_interference_mitigation_enable(struct b43_wldev *dev, int mode) | |||
2891 | } | 2876 | } |
2892 | radio_stacksave(0x0078); | 2877 | radio_stacksave(0x0078); |
2893 | tmp = (b43_radio_read16(dev, 0x0078) & 0x001E); | 2878 | tmp = (b43_radio_read16(dev, 0x0078) & 0x001E); |
2894 | flipped = flip_4bit(tmp); | 2879 | B43_WARN_ON(tmp > 15); |
2880 | flipped = bitrev4(tmp); | ||
2895 | if (flipped < 10 && flipped >= 8) | 2881 | if (flipped < 10 && flipped >= 8) |
2896 | flipped = 7; | 2882 | flipped = 7; |
2897 | else if (flipped >= 10) | 2883 | else if (flipped >= 10) |
2898 | flipped -= 3; | 2884 | flipped -= 3; |
2899 | flipped = flip_4bit(flipped); | 2885 | flipped = (bitrev4(flipped) << 1) | 0x0020; |
2900 | flipped = (flipped << 1) | 0x0020; | ||
2901 | b43_radio_write16(dev, 0x0078, flipped); | 2886 | b43_radio_write16(dev, 0x0078, flipped); |
2902 | 2887 | ||
2903 | b43_calc_nrssi_threshold(dev); | 2888 | b43_calc_nrssi_threshold(dev); |
@@ -3530,7 +3515,7 @@ u16 b43_radio_init2050(struct b43_wldev *dev) | |||
3530 | tmp1 >>= 9; | 3515 | tmp1 >>= 9; |
3531 | 3516 | ||
3532 | for (i = 0; i < 16; i++) { | 3517 | for (i = 0; i < 16; i++) { |
3533 | radio78 = ((flip_4bit(i) << 1) | 0x20); | 3518 | radio78 = (bitrev4(i) << 1) | 0x0020; |
3534 | b43_radio_write16(dev, 0x78, radio78); | 3519 | b43_radio_write16(dev, 0x78, radio78); |
3535 | udelay(10); | 3520 | udelay(10); |
3536 | for (j = 0; j < 16; j++) { | 3521 | for (j = 0; j < 16; j++) { |