libertas: send reset before USB device is shutdown

Marcelo Tosatti mtosatti at redhat.unroutablecom
Tue Nov 28 02:56:39 EST 2006


Commit:     97cd940968eb775d24343b7a6c311c26729f7f95
Parent:     c43fdd2363870e5ab09d92920708668435e4a607
commit 97cd940968eb775d24343b7a6c311c26729f7f95
Author:     Marcelo Tosatti <mtosatti at redhat.com>
AuthorDate: Thu Nov 23 21:09:59 2006 -0200
Commit:     Marcelo Tosatti <mtosatti at redhat.com>
CommitDate: Thu Nov 23 21:09:59 2006 -0200

    libertas: send reset before USB device is shutdown
    
    The reset firmware command (which allows the firmware to be reloaded) is
    sent _after_ the USB connection is down, thus it never reaches the device.
    
    Fix it.
    
    Signed-off-by: Marcelo Tosatti <mtosatti at redhat.com>
---
 drivers/net/wireless/libertas/if_usb.c    |   13 ++-----------
 drivers/net/wireless/libertas/wlan_decl.h |    2 ++
 drivers/net/wireless/libertas/wlan_main.c |   17 ++++++++++++++++-
 3 files changed, 20 insertions(+), 12 deletions(-)

diff --git a/drivers/net/wireless/libertas/if_usb.c b/drivers/net/wireless/libertas/if_usb.c
index 250448d..77c1edb 100644
--- a/drivers/net/wireless/libertas/if_usb.c
+++ b/drivers/net/wireless/libertas/if_usb.c
@@ -578,17 +578,8 @@ #define MRVDRV_MIN_PKT_LEN	30
 		dprintk(1, "Receive type = 0x%X\n", RecvType);
 		RecvType = le32_to_cpu(RecvType);
 		dprintk(1, "Receive type after = 0x%X\n", RecvType);
-	} else if (urb->status) {
-		if (!cardp->rx_urb_recall) {
-			dprintk(1, "Card Is Removed\n");
-			spin_lock(&priv->adapter->driver_lock);
-			priv->adapter->SurpriseRemoved = 1;
-			// Wake up main thread to handle card removal.
-			if_usb_interrupt(priv, 0, 0);
-			spin_unlock(&priv->adapter->driver_lock);
-		}
+	} else if (urb->status)
 		goto rx_exit;
-	}
 
 
 	switch (RecvType) {
@@ -760,7 +751,7 @@ int libertas_sbi_get_cis_info(wlan_priva
 	return WLAN_STATUS_SUCCESS;
 }
 
-static int reset_device(wlan_private *priv)
+int reset_device(wlan_private *priv)
 {
 	int ret;
 
diff --git a/drivers/net/wireless/libertas/wlan_decl.h b/drivers/net/wireless/libertas/wlan_decl.h
index 3b6be95..896000d 100644
--- a/drivers/net/wireless/libertas/wlan_decl.h
+++ b/drivers/net/wireless/libertas/wlan_decl.h
@@ -103,4 +103,6 @@ extern void libertas_mac_event_disconnec
 
 void libertas_send_iwevcustom_event(wlan_private * priv, s8 * str);
 
+int reset_device(wlan_private *priv);
+
 #endif				/* _WLAN_DECL_H_ */
diff --git a/drivers/net/wireless/libertas/wlan_main.c b/drivers/net/wireless/libertas/wlan_main.c
index eba4a33..52383ba 100644
--- a/drivers/net/wireless/libertas/wlan_main.c
+++ b/drivers/net/wireless/libertas/wlan_main.c
@@ -215,6 +215,10 @@ u8 libertas_adhoc_rates_b[4] = { 0x82, 0
  */
 static wlan_private *wlanpriv = NULL;
 
+#define MAX_DEVS 5
+static struct net_device *libertas_devs[MAX_DEVS];
+static int libertas_found = 0;
+
 /**
  * the table to keep region code
  */
@@ -882,7 +886,11 @@ #endif				/* REASSOCIATION */
 	printk(KERN_INFO "%s: Marvell Wlan 802.11 Adapter ", dev->name);
 
 	libertas_debugfs_init_one(priv, dev);
-
+	
+	if (libertas_found == MAX_DEVS)
+		goto err_init_fw;
+	libertas_devs[libertas_found] = dev;
+	libertas_found++;
 #ifdef ENABLE_PM
 	if (!(wlan_pm_dev = pm_register(PM_UNKNOWN_DEV, 0, wlan_pm_callback)))
 		printk(KERN_ALERT "Failed to register PM callback\n");
@@ -1143,8 +1151,15 @@ done:
  */
 static void wlan_cleanup_module(void)
 {
+	int i;
+
 	ENTER();
 
+	for (i = 0; i<libertas_found; i++) {
+		wlan_private *priv = libertas_devs[i]->priv;
+		reset_device(priv);
+	}
+
 	libertas_sbi_unregister();
 	libertas_debugfs_remove();
 


More information about the Commits-kernel mailing list