Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=db9683fb19a0f0da1cb4c296ffe1a8db03333cbc
Commit:     db9683fb19a0f0da1cb4c296ffe1a8db03333cbc
Parent:     33a3dc9328ce3a89d3490a47197851f5dac4b6b5
Author:     Stefano Brivio <[EMAIL PROTECTED]>
AuthorDate: Tue Nov 6 22:48:45 2007 +0100
Committer:  David S. Miller <[EMAIL PROTECTED]>
CommitDate: Mon Jan 28 15:04:30 2008 -0800

    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 <[EMAIL PROTECTED]> has been ported to
    b43legacy.
    
    Signed-off-by: Stefano Brivio <[EMAIL PROTECTED]>
    Signed-off-by: John W. Linville <[EMAIL PROTECTED]>
---
 drivers/net/wireless/b43legacy/main.c   |    2 --
 drivers/net/wireless/b43legacy/rfkill.c |   16 ++++++++++------
 drivers/net/wireless/b43legacy/rfkill.h |    8 ++++----
 3 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/drivers/net/wireless/b43legacy/main.c 
b/drivers/net/wireless/b43legacy/main.c
index 8133efa..2b88896 100644
--- a/drivers/net/wireless/b43legacy/main.c
+++ b/drivers/net/wireless/b43legacy/main.c
@@ -3384,7 +3384,6 @@ static int b43legacy_setup_modes(struct b43legacy_wldev 
*dev,
 
 static void b43legacy_wireless_core_detach(struct b43legacy_wldev *dev)
 {
-       b43legacy_rfkill_free(dev);
        /* We release firmware that late to not be required to re-request
         * is all the time when we reinit the core. */
        b43legacy_release_firmware(dev);
@@ -3466,7 +3465,6 @@ static int b43legacy_wireless_core_attach(struct 
b43legacy_wldev *dev)
        if (!wl->current_dev)
                wl->current_dev = dev;
        INIT_WORK(&dev->restart_work, b43legacy_chip_reset);
-       b43legacy_rfkill_alloc(dev);
 
        b43legacy_radio_turn_off(dev, 1);
        b43legacy_switch_analog(dev, 0);
diff --git a/drivers/net/wireless/b43legacy/rfkill.c 
b/drivers/net/wireless/b43legacy/rfkill.c
index a366129..b9d38a4 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)
        struct b43legacy_wldev *dev = poll_dev->private;
        struct b43legacy_wl *wl = dev->wl;
        bool enabled;
+       bool report_change = 0;
 
        mutex_lock(&wl->mutex);
        B43legacy_WARN_ON(b43legacy_status(dev) < B43legacy_STAT_INITIALIZED);
        enabled = b43legacy_is_hw_radio_enabled(dev);
        if (unlikely(enabled != dev->radio_hw_enable)) {
                dev->radio_hw_enable = enabled;
+               report_change = 1;
                b43legacyinfo(wl, "Radio hardware status changed to %s\n",
                        enabled ? "ENABLED" : "DISABLED");
-               mutex_unlock(&wl->mutex);
+       }
+       mutex_unlock(&wl->mutex);
+
+       if (unlikely(report_change))
                input_report_key(poll_dev->input, KEY_WLAN, enabled);
-       } else
-               mutex_unlock(&wl->mutex);
 }
 
 /* Called when the RFKILL toggled in software.
@@ -70,10 +73,11 @@ static int b43legacy_rfkill_soft_toggle(void *data, enum 
rfkill_state state)
        struct b43legacy_wl *wl = dev->wl;
        int err = 0;
 
-       mutex_lock(&wl->mutex);
-       if (b43legacy_status(dev) < B43legacy_STAT_INITIALIZED)
-               goto out_unlock;
+       if (!wl->rfkill.registered)
+               return 0;
 
+       mutex_lock(&wl->mutex);
+       B43legacy_WARN_ON(b43legacy_status(dev) < B43legacy_STAT_INITIALIZED);
        switch (state) {
        case RFKILL_STATE_ON:
                if (!dev->radio_hw_enable) {
diff --git a/drivers/net/wireless/b43legacy/rfkill.h 
b/drivers/net/wireless/b43legacy/rfkill.h
index b68215e..11150a8 100644
--- a/drivers/net/wireless/b43legacy/rfkill.h
+++ b/drivers/net/wireless/b43legacy/rfkill.h
@@ -16,14 +16,14 @@ struct b43legacy_rfkill {
        struct rfkill *rfkill;
        /* The poll device for the RFKILL input button */
        struct input_polled_dev *poll_dev;
+       /* Did initialization succeed? Used for freeing. */
+       bool registered;
        /* The unique name of this rfkill switch */
-       char name[32];
+       char name[sizeof("b43legacy-phy4294967295")];
 };
 
-/* All the init functions return void, because we are not interested
+/* The init function returns void, because we are not interested
  * in failing the b43 init process when rfkill init failed. */
-void b43legacy_rfkill_alloc(struct b43legacy_wldev *dev);
-void b43legacy_rfkill_free(struct b43legacy_wldev *dev);
 void b43legacy_rfkill_init(struct b43legacy_wldev *dev);
 void b43legacy_rfkill_exit(struct b43legacy_wldev *dev);
 
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to