]> git.neil.brown.name Git - history.git/commitdiff
[PATCH] USB Kaweth driver update
authorGreg Kroah-Hartman <greg@kroah.com>
Tue, 5 Feb 2002 09:17:05 +0000 (01:17 -0800)
committerGreg Kroah-Hartman <greg@kroah.com>
Tue, 5 Feb 2002 09:17:05 +0000 (01:17 -0800)
Here's a patch against 2.5.3 for the USB kaweth driver that does the
following:
- removes SMP deadlock
- removes nfs deadlock
- fixes a memory leak when the firmware is not loaded.
- few other minor cleanups.
This patch was done by Oliver Neukum.

drivers/usb/kaweth.c

index 046674d3437e0bcad1bb121ec47e4236fd014d14..8d89ba87cf30562ef3a7788a086a131d285a2c5b 100644 (file)
@@ -155,6 +155,7 @@ MODULE_DEVICE_TABLE (usb, usb_klsi_table);
  *     kaweth_driver
  ****************************************************************/
 static struct usb_driver kaweth_driver = {
+       owner:          THIS_MODULE,
        name:           "kaweth",
        probe:          kaweth_probe,
        disconnect:     kaweth_disconnect,
@@ -238,8 +239,7 @@ static int kaweth_control(struct kaweth_device *kaweth,
                return -EBUSY;
        }
 
-       dr = kmalloc(sizeof(struct usb_ctrlrequest), 
-                     in_interrupt() ? GFP_ATOMIC : GFP_KERNEL);
+       dr = kmalloc(sizeof(struct usb_ctrlrequest), GFP_ATOMIC);
 
        if (!dr) {
                kaweth_dbg("kmalloc() failed");
@@ -586,14 +586,10 @@ static void kaweth_usb_transmit_complete(struct urb *urb)
 {
        struct kaweth_device *kaweth = urb->context;
 
-       spin_lock(&kaweth->device_lock);
-
-       if (urb->status)
+       if (unlikely(urb->status != 0))
                kaweth_dbg("%s: TX status %d.", kaweth->net->name, urb->status);
 
        netif_wake_queue(kaweth->net);
-
-       spin_unlock(&kaweth->device_lock);
 }
 
 /****************************************************************
@@ -757,9 +753,7 @@ static void *kaweth_probe(
        memset(kaweth, 0, sizeof(struct kaweth_device));
 
        kaweth->dev = dev;
-       kaweth->status = 0;
-       kaweth->net = NULL;
-       kaweth->device_lock = SPIN_LOCK_UNLOCKED;
+       spin_lock_init(&kaweth->device_lock);
                
        kaweth_dbg("Resetting.");
 
@@ -824,6 +818,7 @@ static void *kaweth_probe(
 
                /* Device will now disappear for a moment...  */
                kaweth_info("Firmware loaded.  I'll be back...");
+               kfree(kaweth);
                return NULL;
        }
 
@@ -925,6 +920,8 @@ static void kaweth_disconnect(struct usb_device *dev, void *ptr)
                kaweth_warn("unregistering non-existant device");
                return;
        }
+       usb_unlink_urb(kaweth->tx_urb);
+       usb_unlink_urb(kaweth->rx_urb);
 
        if(kaweth->net) {
                if(kaweth->net->flags & IFF_UP) {