diff options
author | Michael Buesch <mb@bu3sch.de> | 2008-01-09 14:15:31 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-01-28 18:10:42 -0500 |
commit | bfe6a50156ab0c33729378fae7038bce3c6c5184 (patch) | |
tree | 4d29fdaa77eef7772eadab31033227e49e67c911 /drivers/net/wireless | |
parent | a8bdf29c6cd117644d27677962fe832b33036c77 (diff) |
b43legacy: Remove the PHY spinlock
This fixes a sparse warning about weird locking.
The spinlock is not needed, so simply remove it.
This also adds some sanity checks to the PHY and radio locking
to protect against recursive locking.
Signed-off-by: Michael Buesch <mb@bu3sch.de>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless')
-rw-r--r-- | drivers/net/wireless/b43legacy/b43legacy.h | 16 | ||||
-rw-r--r-- | drivers/net/wireless/b43legacy/main.c | 4 | ||||
-rw-r--r-- | drivers/net/wireless/b43legacy/phy.c | 35 | ||||
-rw-r--r-- | drivers/net/wireless/b43legacy/phy.h | 14 | ||||
-rw-r--r-- | drivers/net/wireless/b43legacy/radio.c | 7 |
5 files changed, 28 insertions, 48 deletions
diff --git a/drivers/net/wireless/b43legacy/b43legacy.h b/drivers/net/wireless/b43legacy/b43legacy.h index 8352a4e1cfc9..93419adb925e 100644 --- a/drivers/net/wireless/b43legacy/b43legacy.h +++ b/drivers/net/wireless/b43legacy/b43legacy.h | |||
@@ -415,7 +415,6 @@ struct b43legacy_phy { | |||
415 | u8 calibrated:1; | 415 | u8 calibrated:1; |
416 | u8 radio_rev; /* Radio revision */ | 416 | u8 radio_rev; /* Radio revision */ |
417 | 417 | ||
418 | bool locked; /* Only used in b43legacy_phy_{un}lock() */ | ||
419 | bool dyn_tssi_tbl; /* tssi2dbm is kmalloc()ed. */ | 418 | bool dyn_tssi_tbl; /* tssi2dbm is kmalloc()ed. */ |
420 | 419 | ||
421 | /* ACI (adjacent channel interference) flags. */ | 420 | /* ACI (adjacent channel interference) flags. */ |
@@ -458,11 +457,6 @@ struct b43legacy_phy { | |||
458 | s16 lna_gain; /* LNA */ | 457 | s16 lna_gain; /* LNA */ |
459 | s16 pga_gain; /* PGA */ | 458 | s16 pga_gain; /* PGA */ |
460 | 459 | ||
461 | /* PHY lock for core.rev < 3 | ||
462 | * This lock is only used by b43legacy_phy_{un}lock() | ||
463 | */ | ||
464 | spinlock_t lock; | ||
465 | |||
466 | /* Desired TX power level (in dBm). This is set by the user and | 460 | /* Desired TX power level (in dBm). This is set by the user and |
467 | * adjusted in b43legacy_phy_xmitpower(). */ | 461 | * adjusted in b43legacy_phy_xmitpower(). */ |
468 | u8 power_level; | 462 | u8 power_level; |
@@ -486,9 +480,6 @@ struct b43legacy_phy { | |||
486 | u16 txpwr_offset; | 480 | u16 txpwr_offset; |
487 | }; | 481 | }; |
488 | 482 | ||
489 | #ifdef CONFIG_B43LEGACY_DEBUG | ||
490 | bool manual_txpower_control; /* Manual TX-power control enabled? */ | ||
491 | #endif | ||
492 | /* Current Interference Mitigation mode */ | 483 | /* Current Interference Mitigation mode */ |
493 | int interfmode; | 484 | int interfmode; |
494 | /* Stack of saved values from the Interference Mitigation code. | 485 | /* Stack of saved values from the Interference Mitigation code. |
@@ -516,6 +507,13 @@ struct b43legacy_phy { | |||
516 | 507 | ||
517 | /* PHY TX errors counter. */ | 508 | /* PHY TX errors counter. */ |
518 | atomic_t txerr_cnt; | 509 | atomic_t txerr_cnt; |
510 | |||
511 | #if B43legacy_DEBUG | ||
512 | /* Manual TX-power control enabled? */ | ||
513 | bool manual_txpower_control; | ||
514 | /* PHY registers locked by b43legacy_phy_lock()? */ | ||
515 | bool phy_locked; | ||
516 | #endif /* B43legacy_DEBUG */ | ||
519 | }; | 517 | }; |
520 | 518 | ||
521 | /* Data structures for DMA transmission, per 80211 core. */ | 519 | /* Data structures for DMA transmission, per 80211 core. */ |
diff --git a/drivers/net/wireless/b43legacy/main.c b/drivers/net/wireless/b43legacy/main.c index 2d5735ddad8c..4ed4243feeaa 100644 --- a/drivers/net/wireless/b43legacy/main.c +++ b/drivers/net/wireless/b43legacy/main.c | |||
@@ -2847,8 +2847,6 @@ static void setup_struct_phy_for_init(struct b43legacy_wldev *dev, | |||
2847 | memset(phy->minlowsig, 0xFF, sizeof(phy->minlowsig)); | 2847 | memset(phy->minlowsig, 0xFF, sizeof(phy->minlowsig)); |
2848 | memset(phy->minlowsigpos, 0, sizeof(phy->minlowsigpos)); | 2848 | memset(phy->minlowsigpos, 0, sizeof(phy->minlowsigpos)); |
2849 | 2849 | ||
2850 | /* Flags */ | ||
2851 | phy->locked = 0; | ||
2852 | /* Assume the radio is enabled. If it's not enabled, the state will | 2850 | /* Assume the radio is enabled. If it's not enabled, the state will |
2853 | * immediately get fixed on the first periodic work run. */ | 2851 | * immediately get fixed on the first periodic work run. */ |
2854 | dev->radio_hw_enable = 1; | 2852 | dev->radio_hw_enable = 1; |
@@ -2881,7 +2879,6 @@ static void setup_struct_phy_for_init(struct b43legacy_wldev *dev, | |||
2881 | phy->lofcal = 0xFFFF; | 2879 | phy->lofcal = 0xFFFF; |
2882 | phy->initval = 0xFFFF; | 2880 | phy->initval = 0xFFFF; |
2883 | 2881 | ||
2884 | spin_lock_init(&phy->lock); | ||
2885 | phy->interfmode = B43legacy_INTERFMODE_NONE; | 2882 | phy->interfmode = B43legacy_INTERFMODE_NONE; |
2886 | phy->channel = 0xFF; | 2883 | phy->channel = 0xFF; |
2887 | } | 2884 | } |
@@ -3013,7 +3010,6 @@ static void prepare_phy_data_for_init(struct b43legacy_wldev *dev) | |||
3013 | 3010 | ||
3014 | /* Flags */ | 3011 | /* Flags */ |
3015 | phy->calibrated = 0; | 3012 | phy->calibrated = 0; |
3016 | phy->locked = 0; | ||
3017 | 3013 | ||
3018 | if (phy->_lo_pairs) | 3014 | if (phy->_lo_pairs) |
3019 | memset(phy->_lo_pairs, 0, | 3015 | memset(phy->_lo_pairs, 0, |
diff --git a/drivers/net/wireless/b43legacy/phy.c b/drivers/net/wireless/b43legacy/phy.c index 57c668f575fc..c16febbdbf5d 100644 --- a/drivers/net/wireless/b43legacy/phy.c +++ b/drivers/net/wireless/b43legacy/phy.c | |||
@@ -91,40 +91,36 @@ void b43legacy_voluntary_preempt(void) | |||
91 | #endif /* CONFIG_PREEMPT */ | 91 | #endif /* CONFIG_PREEMPT */ |
92 | } | 92 | } |
93 | 93 | ||
94 | void b43legacy_raw_phy_lock(struct b43legacy_wldev *dev) | 94 | /* Lock the PHY registers against concurrent access from the microcode. |
95 | * This lock is nonrecursive. */ | ||
96 | void b43legacy_phy_lock(struct b43legacy_wldev *dev) | ||
95 | { | 97 | { |
96 | struct b43legacy_phy *phy = &dev->phy; | 98 | #if B43legacy_DEBUG |
99 | B43legacy_WARN_ON(dev->phy.phy_locked); | ||
100 | dev->phy.phy_locked = 1; | ||
101 | #endif | ||
97 | 102 | ||
98 | B43legacy_WARN_ON(!irqs_disabled()); | ||
99 | if (b43legacy_read32(dev, B43legacy_MMIO_STATUS_BITFIELD) == 0) { | ||
100 | phy->locked = 0; | ||
101 | return; | ||
102 | } | ||
103 | if (dev->dev->id.revision < 3) { | 103 | if (dev->dev->id.revision < 3) { |
104 | b43legacy_mac_suspend(dev); | 104 | b43legacy_mac_suspend(dev); |
105 | spin_lock(&phy->lock); | ||
106 | } else { | 105 | } else { |
107 | if (!b43legacy_is_mode(dev->wl, IEEE80211_IF_TYPE_AP)) | 106 | if (!b43legacy_is_mode(dev->wl, IEEE80211_IF_TYPE_AP)) |
108 | b43legacy_power_saving_ctl_bits(dev, -1, 1); | 107 | b43legacy_power_saving_ctl_bits(dev, -1, 1); |
109 | } | 108 | } |
110 | phy->locked = 1; | ||
111 | } | 109 | } |
112 | 110 | ||
113 | void b43legacy_raw_phy_unlock(struct b43legacy_wldev *dev) | 111 | void b43legacy_phy_unlock(struct b43legacy_wldev *dev) |
114 | { | 112 | { |
115 | struct b43legacy_phy *phy = &dev->phy; | 113 | #if B43legacy_DEBUG |
114 | B43legacy_WARN_ON(!dev->phy.phy_locked); | ||
115 | dev->phy.phy_locked = 0; | ||
116 | #endif | ||
116 | 117 | ||
117 | B43legacy_WARN_ON(!irqs_disabled()); | ||
118 | if (dev->dev->id.revision < 3) { | 118 | if (dev->dev->id.revision < 3) { |
119 | if (phy->locked) { | 119 | b43legacy_mac_enable(dev); |
120 | spin_unlock(&phy->lock); | ||
121 | b43legacy_mac_enable(dev); | ||
122 | } | ||
123 | } else { | 120 | } else { |
124 | if (!b43legacy_is_mode(dev->wl, IEEE80211_IF_TYPE_AP)) | 121 | if (!b43legacy_is_mode(dev->wl, IEEE80211_IF_TYPE_AP)) |
125 | b43legacy_power_saving_ctl_bits(dev, -1, -1); | 122 | b43legacy_power_saving_ctl_bits(dev, -1, -1); |
126 | } | 123 | } |
127 | phy->locked = 0; | ||
128 | } | 124 | } |
129 | 125 | ||
130 | u16 b43legacy_phy_read(struct b43legacy_wldev *dev, u16 offset) | 126 | u16 b43legacy_phy_read(struct b43legacy_wldev *dev, u16 offset) |
@@ -1789,7 +1785,6 @@ void b43legacy_phy_xmitpower(struct b43legacy_wldev *dev) | |||
1789 | s16 baseband_att_delta; | 1785 | s16 baseband_att_delta; |
1790 | s16 radio_attenuation; | 1786 | s16 radio_attenuation; |
1791 | s16 baseband_attenuation; | 1787 | s16 baseband_attenuation; |
1792 | unsigned long phylock_flags; | ||
1793 | 1788 | ||
1794 | if (phy->savedpctlreg == 0xFFFF) | 1789 | if (phy->savedpctlreg == 0xFFFF) |
1795 | return; | 1790 | return; |
@@ -1944,13 +1939,13 @@ void b43legacy_phy_xmitpower(struct b43legacy_wldev *dev) | |||
1944 | phy->bbatt = baseband_attenuation; | 1939 | phy->bbatt = baseband_attenuation; |
1945 | 1940 | ||
1946 | /* Adjust the hardware */ | 1941 | /* Adjust the hardware */ |
1947 | b43legacy_phy_lock(dev, phylock_flags); | 1942 | b43legacy_phy_lock(dev); |
1948 | b43legacy_radio_lock(dev); | 1943 | b43legacy_radio_lock(dev); |
1949 | b43legacy_radio_set_txpower_bg(dev, baseband_attenuation, | 1944 | b43legacy_radio_set_txpower_bg(dev, baseband_attenuation, |
1950 | radio_attenuation, txpower); | 1945 | radio_attenuation, txpower); |
1951 | b43legacy_phy_lo_mark_current_used(dev); | 1946 | b43legacy_phy_lo_mark_current_used(dev); |
1952 | b43legacy_radio_unlock(dev); | 1947 | b43legacy_radio_unlock(dev); |
1953 | b43legacy_phy_unlock(dev, phylock_flags); | 1948 | b43legacy_phy_unlock(dev); |
1954 | } | 1949 | } |
1955 | 1950 | ||
1956 | static inline | 1951 | static inline |
diff --git a/drivers/net/wireless/b43legacy/phy.h b/drivers/net/wireless/b43legacy/phy.h index efa4c5c54a86..ecbe409f9a94 100644 --- a/drivers/net/wireless/b43legacy/phy.h +++ b/drivers/net/wireless/b43legacy/phy.h | |||
@@ -171,18 +171,8 @@ void b43legacy_put_attenuation_into_ranges(int *_bbatt, int *_rfatt); | |||
171 | 171 | ||
172 | struct b43legacy_wldev; | 172 | struct b43legacy_wldev; |
173 | 173 | ||
174 | void b43legacy_raw_phy_lock(struct b43legacy_wldev *dev); | 174 | void b43legacy_phy_lock(struct b43legacy_wldev *dev); |
175 | #define b43legacy_phy_lock(bcm, flags) \ | 175 | void b43legacy_phy_unlock(struct b43legacy_wldev *dev); |
176 | do { \ | ||
177 | local_irq_save(flags); \ | ||
178 | b43legacy_raw_phy_lock(bcm); \ | ||
179 | } while (0) | ||
180 | void b43legacy_raw_phy_unlock(struct b43legacy_wldev *dev); | ||
181 | #define b43legacy_phy_unlock(bcm, flags) \ | ||
182 | do { \ | ||
183 | b43legacy_raw_phy_unlock(bcm); \ | ||
184 | local_irq_restore(flags); \ | ||
185 | } while (0) | ||
186 | 176 | ||
187 | /* Card uses the loopback gain stuff */ | 177 | /* Card uses the loopback gain stuff */ |
188 | #define has_loopback_gain(phy) \ | 178 | #define has_loopback_gain(phy) \ |
diff --git a/drivers/net/wireless/b43legacy/radio.c b/drivers/net/wireless/b43legacy/radio.c index 1a72eb0f8f66..318a270cf9b4 100644 --- a/drivers/net/wireless/b43legacy/radio.c +++ b/drivers/net/wireless/b43legacy/radio.c | |||
@@ -92,6 +92,7 @@ void b43legacy_radio_lock(struct b43legacy_wldev *dev) | |||
92 | u32 status; | 92 | u32 status; |
93 | 93 | ||
94 | status = b43legacy_read32(dev, B43legacy_MMIO_STATUS_BITFIELD); | 94 | status = b43legacy_read32(dev, B43legacy_MMIO_STATUS_BITFIELD); |
95 | B43legacy_WARN_ON(status & B43legacy_SBF_RADIOREG_LOCK); | ||
95 | status |= B43legacy_SBF_RADIOREG_LOCK; | 96 | status |= B43legacy_SBF_RADIOREG_LOCK; |
96 | b43legacy_write32(dev, B43legacy_MMIO_STATUS_BITFIELD, status); | 97 | b43legacy_write32(dev, B43legacy_MMIO_STATUS_BITFIELD, status); |
97 | mmiowb(); | 98 | mmiowb(); |
@@ -104,6 +105,7 @@ void b43legacy_radio_unlock(struct b43legacy_wldev *dev) | |||
104 | 105 | ||
105 | b43legacy_read16(dev, B43legacy_MMIO_PHY_VER); /* dummy read */ | 106 | b43legacy_read16(dev, B43legacy_MMIO_PHY_VER); /* dummy read */ |
106 | status = b43legacy_read32(dev, B43legacy_MMIO_STATUS_BITFIELD); | 107 | status = b43legacy_read32(dev, B43legacy_MMIO_STATUS_BITFIELD); |
108 | B43legacy_WARN_ON(!(status & B43legacy_SBF_RADIOREG_LOCK)); | ||
107 | status &= ~B43legacy_SBF_RADIOREG_LOCK; | 109 | status &= ~B43legacy_SBF_RADIOREG_LOCK; |
108 | b43legacy_write32(dev, B43legacy_MMIO_STATUS_BITFIELD, status); | 110 | b43legacy_write32(dev, B43legacy_MMIO_STATUS_BITFIELD, status); |
109 | mmiowb(); | 111 | mmiowb(); |
@@ -284,12 +286,11 @@ u8 b43legacy_radio_aci_scan(struct b43legacy_wldev *dev) | |||
284 | unsigned int j; | 286 | unsigned int j; |
285 | unsigned int start; | 287 | unsigned int start; |
286 | unsigned int end; | 288 | unsigned int end; |
287 | unsigned long phylock_flags; | ||
288 | 289 | ||
289 | if (!((phy->type == B43legacy_PHYTYPE_G) && (phy->rev > 0))) | 290 | if (!((phy->type == B43legacy_PHYTYPE_G) && (phy->rev > 0))) |
290 | return 0; | 291 | return 0; |
291 | 292 | ||
292 | b43legacy_phy_lock(dev, phylock_flags); | 293 | b43legacy_phy_lock(dev); |
293 | b43legacy_radio_lock(dev); | 294 | b43legacy_radio_lock(dev); |
294 | b43legacy_phy_write(dev, 0x0802, | 295 | b43legacy_phy_write(dev, 0x0802, |
295 | b43legacy_phy_read(dev, 0x0802) & 0xFFFC); | 296 | b43legacy_phy_read(dev, 0x0802) & 0xFFFC); |
@@ -323,7 +324,7 @@ u8 b43legacy_radio_aci_scan(struct b43legacy_wldev *dev) | |||
323 | ret[j] = 1; | 324 | ret[j] = 1; |
324 | } | 325 | } |
325 | b43legacy_radio_unlock(dev); | 326 | b43legacy_radio_unlock(dev); |
326 | b43legacy_phy_unlock(dev, phylock_flags); | 327 | b43legacy_phy_unlock(dev); |
327 | 328 | ||
328 | return ret[channel - 1]; | 329 | return ret[channel - 1]; |
329 | } | 330 | } |