Skip to contentSkip to conversation

libertas: allow removal of card at any time

PATCH In review Holger Schurig 2 participants 2 messages Apr 30, 2008 Networking drivers (wireless)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libertas: allow removal of card at any time

This fixes several problems I had:

* when removing the card while the card was scanning or associtating, it could happen that destroy_workqueue() stuck and didn't return.
* make sure the command function doesn't run while we remove the list of pending commands
* for still unknown reason, I had calls to lbs_stop_card() with priv==NULL

drivers/net/wireless/libertas/main.c +7 -2
Index: wireless-testing/drivers/net/wireless/libertas/main.c
===================================================================
@@ -1166,8 +1166,8 @@ void lbs_remove_card(struct lbs_private 
 
 	dev = priv->dev;
 
-	cancel_delayed_work(&priv->scan_work);
-	cancel_delayed_work(&priv->assoc_work);
+	cancel_delayed_work_sync(&priv->scan_work);
+	cancel_delayed_work_sync(&priv->assoc_work);
 	destroy_workqueue(priv->work_thread);
 
 	if (priv->psmode == LBS802_11POWERMODEMAX_PSP) {
@@ -1267,6 +1267,9 @@ void lbs_stop_card(struct lbs_private *p
 
 	lbs_deb_enter(LBS_DEB_MAIN);
 
+	if (!priv)
+		goto out;
+
 	netif_stop_queue(priv->dev);
 	netif_carrier_off(priv->dev);
 
@@ -1276,6 +1279,7 @@ void lbs_stop_card(struct lbs_private *p
 		device_remove_file(&dev->dev, &dev_attr_lbs_mesh);
 
 	/* Flush pending command nodes */
+	del_timer_sync(&priv->command_timer);
 	spin_lock_irqsave(&priv->driver_lock, flags);
 	list_for_each_entry(cmdnode, &priv->cmdpendingq, list) {
 		cmdnode->result = -ENOENT;
@@ -1286,6 +1290,7 @@ void lbs_stop_card(struct lbs_private *p
 
 	unregister_netdev(dev);
 
+out:
 	lbs_deb_leave(LBS_DEB_MAIN);
 }
 EXPORT_SYMBOL_GPL(lbs_stop_card);
Acked-by on v1 1/1
#1 lore raw
Quoted 10 lines · Holger Schurig

This fixes several problems I had:

* when removing the card while the card was scanning or associtating, it could happen that destroy_workqueue() stuck and didn't return.
* make sure the command function doesn't run while we remove the list of pending commands
* for still unknown reason, I had calls to lbs_stop_card() with priv==NULL

Quoted 41 lines

Index: wireless-testing/drivers/net/wireless/libertas/main.c
===================================================================

drivers/net/wireless/libertas/main.c +7 -2
@@ -1166,8 +1166,8 @@ void lbs_remove_card(struct lbs_private 
 
 	dev = priv->dev;
 
-	cancel_delayed_work(&priv->scan_work);
-	cancel_delayed_work(&priv->assoc_work);
+	cancel_delayed_work_sync(&priv->scan_work);
+	cancel_delayed_work_sync(&priv->assoc_work);
 	destroy_workqueue(priv->work_thread);
 
 	if (priv->psmode == LBS802_11POWERMODEMAX_PSP) {
@@ -1267,6 +1267,9 @@ void lbs_stop_card(struct lbs_private *p
 
 	lbs_deb_enter(LBS_DEB_MAIN);
 
+	if (!priv)
+		goto out;
+
 	netif_stop_queue(priv->dev);
 	netif_carrier_off(priv->dev);
 
@@ -1276,6 +1279,7 @@ void lbs_stop_card(struct lbs_private *p
 		device_remove_file(&dev->dev, &dev_attr_lbs_mesh);
 
 	/* Flush pending command nodes */
+	del_timer_sync(&priv->command_timer);
 	spin_lock_irqsave(&priv->driver_lock, flags);
 	list_for_each_entry(cmdnode, &priv->cmdpendingq, list) {
 		cmdnode->result = -ENOENT;
@@ -1286,6 +1290,7 @@ void lbs_stop_card(struct lbs_private *p
 
 	unregister_netdev(dev);
 
+out:
 	lbs_deb_leave(LBS_DEB_MAIN);
 }
 EXPORT_SYMBOL_GPL(lbs_stop_card);