[PATCH 2/2] ar6k: unregister netdev only when it's really registered

Samuel Ortiz sameo at openedhand.com
Tue Jan 22 20:09:11 CET 2008


Hi Werner,

Whenever our ar6k chip can not be identified, we are trying to unregister
our netdevice although it was never registered.
This patch fixes this bug.

Signed-off-by: Samuel Ortiz <sameo at openedhand.com>
---
 drivers/sdio/function/wlan/ar6000/ar6000/ar6000_drv.c |   15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

Index: linux-2.6.24-rc8-omoko-svn/drivers/sdio/function/wlan/ar6000/ar6000/ar6000_drv.c
===================================================================
--- linux-2.6.24-rc8-omoko-svn.orig/drivers/sdio/function/wlan/ar6000/ar6000/ar6000_drv.c	2008-01-22 20:00:23.000000000 +0100
+++ linux-2.6.24-rc8-omoko-svn/drivers/sdio/function/wlan/ar6000/ar6000/ar6000_drv.c	2008-01-22 20:03:06.000000000 +0100
@@ -4,7 +4,7 @@
  * All rights reserved.
  *
  *
- *  This program is free software; you can redistribute it and/or modify
+ *  This program is free software; you can redristribute it and/or modify
  *  it under the terms of the GNU General Public License version 2 as
  *  published by the Free Software Foundation;
  *
@@ -209,7 +209,7 @@
 static void ar6000_init_control_info(AR_SOFTC_T *ar);
 static int ar6000_data_tx(struct sk_buff *skb, struct net_device *dev);
 
-static void ar6000_destroy(struct net_device *dev);
+static void ar6000_destroy(struct net_device *dev, unsigned int unregister);
 static void ar6000_detect_error(unsigned long ptr);
 static struct net_device_stats *ar6000_get_stats(struct net_device *dev);
 static struct iw_statistics *ar6000_get_iwstats(struct net_device * dev);
@@ -559,7 +559,7 @@
         if (ar6000_devices[i] != NULL) {
             ar6000_netdev = ar6000_devices[i];
             ar6000_devices[i] = NULL;
-            ar6000_destroy(ar6000_netdev);
+            ar6000_destroy(ar6000_netdev, 1);
         }
     }
 
@@ -842,7 +842,7 @@
     /* This runs the init function */
     if (register_netdev(dev)) {
         AR_DEBUG_PRINTF("ar6000_avail: register_netdev failed\n");
-        ar6000_destroy(dev);
+        ar6000_destroy(dev, 0);
         return;
     }
 
@@ -896,7 +896,7 @@
     AR_SOFTC_T *ar = (AR_SOFTC_T *)Instance;
         /* NULL out it's entry in the global list */
     ar6000_devices[ar->arDeviceIndex] = NULL;
-    ar6000_destroy(ar->arNetDev);
+    ar6000_destroy(ar->arNetDev, 1);
 }
 
 /*
@@ -914,7 +914,7 @@
  *   removal since they will anyway not go through.
  */
 static void
-ar6000_destroy(struct net_device *dev)
+ar6000_destroy(struct net_device *dev, unsigned int unregister)
 {
     AR_SOFTC_T *ar;
 
@@ -1004,7 +1004,8 @@
 
 
     /* Free up the device data structure */
-    unregister_netdev(dev);
+    if (unregister)
+	    unregister_netdev(dev);
 #ifndef free_netdev
     kfree(dev);
 #else





More information about the openmoko-kernel mailing list