Revert "AR6000: move low-level cleanup from ar6000_destroy to ar6000_close"
authorPaul Fertser <fercerpav@gmail.com>
Sun, 30 Aug 2009 07:55:48 +0000 (11:55 +0400)
committerPaul Fertser <fercerpav@gmail.com>
Tue, 1 Sep 2009 20:22:23 +0000 (00:22 +0400)
This reverts commit 9c4451ff31b937a478f3d3eabef30b71cbe12b12.

This commit made wifi unusable after ifconfig down and sometimes after
unbinding.

drivers/ar6000/ar6000/ar6000_drv.c

index b790670..21504f2 100644 (file)
@@ -974,17 +974,86 @@ ar6000_destroy(struct net_device *dev, unsigned int unregister)
         return;
     }
 
+    /* Stop the transmit queues */
+    netif_stop_queue(dev);
+
+    /* Disable the target and the interrupts associated with it */
+    if (ar->arWmiReady == TRUE)
+    {
+        if (!bypasswmi)
+        {
+            if (ar->arConnected == TRUE || ar->arConnectPending == TRUE)
+            {
+                AR_DEBUG_PRINTF("%s(): Disconnect\n", __func__);
+                AR6000_SPIN_LOCK(&ar->arLock, 0);
+                ar6000_init_profile_info(ar);
+                AR6000_SPIN_UNLOCK(&ar->arLock, 0);
+                wmi_disconnect_cmd(ar->arWmi);
+            }
+
+            ar6000_dbglog_get_debug_logs(ar);
+            ar->arWmiReady  = FALSE;
+            ar->arConnected = FALSE;
+            ar->arConnectPending = FALSE;
+            wmi_shutdown(ar->arWmi);
+            ar->arWmiEnabled = FALSE;
+            ar->arWmi = NULL;
+            ar->arWlanState = WLAN_ENABLED;
+#ifdef USER_KEYS
+            ar->user_savedkeys_stat = USER_SAVEDKEYS_STAT_INIT;
+            ar->user_key_ctrl      = 0;
+#endif
+        }
+
+         AR_DEBUG_PRINTF("%s(): WMI stopped\n", __func__);
+    }
+    else
+    {
+        AR_DEBUG_PRINTF("%s(): WMI not ready 0x%08x 0x%08x\n",
+            __func__, (unsigned int) ar, (unsigned int) ar->arWmi);
+
+        /* Shut down WMI if we have started it */
+        if(ar->arWmiEnabled == TRUE)
+        {
+            AR_DEBUG_PRINTF("%s(): Shut down WMI\n", __func__);
+            wmi_shutdown(ar->arWmi);
+            ar->arWmiEnabled = FALSE;
+            ar->arWmi = NULL;
+        }
+    }
+
+    /* stop HTC */
+    HTCStop(ar->arHtcTarget);
+
+    /* set the instance to NULL so we do not get called back on remove incase we
+     * we're explicity destroyed by module unload */
+    HTCSetInstance(ar->arHtcTarget, NULL);
+
+    if (resetok) {
+        /* try to reset the device if we can
+         * The driver may have been configure NOT to reset the target during
+         * a debug session */
+        AR_DEBUG_PRINTF(" Attempting to reset target on instance destroy.... \n");
+        ar6000_reset_device(ar->arHifDevice, ar->arTargetType);
+    } else {
+        AR_DEBUG_PRINTF(" Host does not want target reset. \n");
+    }
+
+       /* Done with cookies */
+    ar6000_cookie_cleanup(ar);
+
+    /* Cleanup BMI */
+    BMIInit();
+
     /* Clear the tx counters */
     memset(tx_attempt, 0, sizeof(tx_attempt));
     memset(tx_post, 0, sizeof(tx_post));
     memset(tx_complete, 0, sizeof(tx_complete));
 
+
     /* Free up the device data structure */
-    if (unregister) {
-       unregister_netdev(dev);
-    } else {
-       ar6000_close(dev);
-    }
+    if (unregister)
+           unregister_netdev(dev);
 
     free_raw_buffers(ar);
 
@@ -1090,79 +1159,8 @@ ar6000_open(struct net_device *dev)
 static int
 ar6000_close(struct net_device *dev)
 {
-    AR_SOFTC_T *ar = netdev_priv(dev);
-
-    /* Stop the transmit queues */
     netif_stop_queue(dev);
 
-    /* Disable the target and the interrupts associated with it */
-    if (ar->arWmiReady == TRUE)
-    {
-        if (!bypasswmi)
-        {
-            if (ar->arConnected == TRUE || ar->arConnectPending == TRUE)
-            {
-                AR_DEBUG_PRINTF("%s(): Disconnect\n", __func__);
-                AR6000_SPIN_LOCK(&ar->arLock, 0);
-                ar6000_init_profile_info(ar);
-                AR6000_SPIN_UNLOCK(&ar->arLock, 0);
-                wmi_disconnect_cmd(ar->arWmi);
-            }
-
-            ar6000_dbglog_get_debug_logs(ar);
-            ar->arWmiReady  = FALSE;
-            ar->arConnected = FALSE;
-            ar->arConnectPending = FALSE;
-            wmi_shutdown(ar->arWmi);
-            ar->arWmiEnabled = FALSE;
-            ar->arWmi = NULL;
-            ar->arWlanState = WLAN_ENABLED;
-#ifdef USER_KEYS
-            ar->user_savedkeys_stat = USER_SAVEDKEYS_STAT_INIT;
-            ar->user_key_ctrl      = 0;
-#endif
-        }
-
-         AR_DEBUG_PRINTF("%s(): WMI stopped\n", __func__);
-    }
-    else
-    {
-        AR_DEBUG_PRINTF("%s(): WMI not ready 0x%08x 0x%08x\n",
-            __func__, (unsigned int) ar, (unsigned int) ar->arWmi);
-
-        /* Shut down WMI if we have started it */
-        if(ar->arWmiEnabled == TRUE)
-        {
-            AR_DEBUG_PRINTF("%s(): Shut down WMI\n", __func__);
-            wmi_shutdown(ar->arWmi);
-            ar->arWmiEnabled = FALSE;
-            ar->arWmi = NULL;
-        }
-    }
-
-    /* stop HTC */
-    HTCStop(ar->arHtcTarget);
-
-    /* set the instance to NULL so we do not get called back on remove incase we
-     * we're explicity destroyed by module unload */
-    HTCSetInstance(ar->arHtcTarget, NULL);
-
-    if (resetok) {
-        /* try to reset the device if we can
-         * The driver may have been configure NOT to reset the target during
-         * a debug session */
-        AR_DEBUG_PRINTF(" Attempting to reset target on instance destroy.... \n");
-        ar6000_reset_device(ar->arHifDevice, ar->arTargetType);
-    } else {
-        AR_DEBUG_PRINTF(" Host does not want target reset. \n");
-    }
-
-       /* Done with cookies */
-    ar6000_cookie_cleanup(ar);
-
-    /* Cleanup BMI */
-    BMIInit();
-
     return 0;
 }