p54: only unregister ieee80211_hw when it has been registered
authorChristian Lamparter <chunkeey@googlemail.com>
Sat, 17 Mar 2012 13:10:02 +0000 (14:10 +0100)
committerJohn W. Linville <linville@tuxdriver.com>
Mon, 9 Apr 2012 20:07:35 +0000 (16:07 -0400)
p54_unregister_common may now be called by the backend
driver's remove routine, even if the ieee80211_hw device
struct was never successfully registered.

Signed-off-by: Christian Lamparter <chunkeey@googlemail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/p54/main.c
drivers/net/wireless/p54/p54.h

index ee8af1f047c8834f3f5cf5be4952616b6f44e5f9..7cffea795ad27d0044e777a0a04e02e741793ea9 100644 (file)
@@ -796,11 +796,14 @@ int p54_register_common(struct ieee80211_hw *dev, struct device *pdev)
                dev_err(pdev, "Cannot register device (%d).\n", err);
                return err;
        }
+       priv->registered = true;
 
 #ifdef CONFIG_P54_LEDS
        err = p54_init_leds(priv);
-       if (err)
+       if (err) {
+               p54_unregister_common(dev);
                return err;
+       }
 #endif /* CONFIG_P54_LEDS */
 
        dev_info(pdev, "is registered as '%s'\n", wiphy_name(dev->wiphy));
@@ -840,7 +843,11 @@ void p54_unregister_common(struct ieee80211_hw *dev)
        p54_unregister_leds(priv);
 #endif /* CONFIG_P54_LEDS */
 
-       ieee80211_unregister_hw(dev);
+       if (priv->registered) {
+               priv->registered = false;
+               ieee80211_unregister_hw(dev);
+       }
+
        mutex_destroy(&priv->conf_mutex);
        mutex_destroy(&priv->eeprom_mutex);
 }
index 452fa3a64aa1297f033801802702f8056c619632..40b401ed68458d92f71789d7c22fed20a6104039 100644 (file)
@@ -173,6 +173,7 @@ struct p54_common {
        struct sk_buff_head tx_pending;
        struct sk_buff_head tx_queue;
        struct mutex conf_mutex;
+       bool registered;
 
        /* memory management (as seen by the firmware) */
        u32 rx_start;