diff options
author | Stefano Brivio <stefano.brivio@polimi.it> | 2007-11-06 16:48:45 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-01-28 18:04:30 -0500 |
commit | db9683fb19a0f0da1cb4c296ffe1a8db03333cbc (patch) | |
tree | 86f2c14df0e7cce871d52df687c3b59ccaab1673 /drivers/net/wireless/b43legacy/rfkill.c | |
parent | 33a3dc9328ce3a89d3490a47197851f5dac4b6b5 (diff) |
b43legacy: rewrite and fix rfkill initialization
The rfkill subsystem doesn't like code like that
rfkill_allocate();
rfkill_register();
rfkill_unregister();
rfkill_register(); /* <- This will crash */
This sequence happens with
modprobe b43
ifconfig wlanX up
ifconfig wlanX down
ifconfig wlanX up
Fix this by always re-allocating the rfkill stuff before register.
The patch to b43 by Michael Buesch <mb@bu3sch.de> has been ported to
b43legacy.
Signed-off-by: Stefano Brivio <stefano.brivio@polimi.it>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/b43legacy/rfkill.c')
-rw-r--r-- | drivers/net/wireless/b43legacy/rfkill.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/drivers/net/wireless/b43legacy/rfkill.c b/drivers/net/wireless/b43legacy/rfkill.c index a366129c8b0b..b9d38a4f286d 100644 --- a/drivers/net/wireless/b43legacy/rfkill.c +++ b/drivers/net/wireless/b43legacy/rfkill.c | |||
@@ -48,18 +48,21 @@ static void b43legacy_rfkill_poll(struct input_polled_dev *poll_dev) | |||
48 | struct b43legacy_wldev *dev = poll_dev->private; | 48 | struct b43legacy_wldev *dev = poll_dev->private; |
49 | struct b43legacy_wl *wl = dev->wl; | 49 | struct b43legacy_wl *wl = dev->wl; |
50 | bool enabled; | 50 | bool enabled; |
51 | bool report_change = 0; | ||
51 | 52 | ||
52 | mutex_lock(&wl->mutex); | 53 | mutex_lock(&wl->mutex); |
53 | B43legacy_WARN_ON(b43legacy_status(dev) < B43legacy_STAT_INITIALIZED); | 54 | B43legacy_WARN_ON(b43legacy_status(dev) < B43legacy_STAT_INITIALIZED); |
54 | enabled = b43legacy_is_hw_radio_enabled(dev); | 55 | enabled = b43legacy_is_hw_radio_enabled(dev); |
55 | if (unlikely(enabled != dev->radio_hw_enable)) { | 56 | if (unlikely(enabled != dev->radio_hw_enable)) { |
56 | dev->radio_hw_enable = enabled; | 57 | dev->radio_hw_enable = enabled; |
58 | report_change = 1; | ||
57 | b43legacyinfo(wl, "Radio hardware status changed to %s\n", | 59 | b43legacyinfo(wl, "Radio hardware status changed to %s\n", |
58 | enabled ? "ENABLED" : "DISABLED"); | 60 | enabled ? "ENABLED" : "DISABLED"); |
59 | mutex_unlock(&wl->mutex); | 61 | } |
62 | mutex_unlock(&wl->mutex); | ||
63 | |||
64 | if (unlikely(report_change)) | ||
60 | input_report_key(poll_dev->input, KEY_WLAN, enabled); | 65 | input_report_key(poll_dev->input, KEY_WLAN, enabled); |
61 | } else | ||
62 | mutex_unlock(&wl->mutex); | ||
63 | } | 66 | } |
64 | 67 | ||
65 | /* Called when the RFKILL toggled in software. | 68 | /* Called when the RFKILL toggled in software. |
@@ -70,10 +73,11 @@ static int b43legacy_rfkill_soft_toggle(void *data, enum rfkill_state state) | |||
70 | struct b43legacy_wl *wl = dev->wl; | 73 | struct b43legacy_wl *wl = dev->wl; |
71 | int err = 0; | 74 | int err = 0; |
72 | 75 | ||
73 | mutex_lock(&wl->mutex); | 76 | if (!wl->rfkill.registered) |
74 | if (b43legacy_status(dev) < B43legacy_STAT_INITIALIZED) | 77 | return 0; |
75 | goto out_unlock; | ||
76 | 78 | ||
79 | mutex_lock(&wl->mutex); | ||
80 | B43legacy_WARN_ON(b43legacy_status(dev) < B43legacy_STAT_INITIALIZED); | ||
77 | switch (state) { | 81 | switch (state) { |
78 | case RFKILL_STATE_ON: | 82 | case RFKILL_STATE_ON: |
79 | if (!dev->radio_hw_enable) { | 83 | if (!dev->radio_hw_enable) { |