]> git.hungrycats.org Git - linux/commitdiff
[PATCH] USB: Update unlink testing code in the usbtest driver
authorAlan Stern <stern@rowland.harvard.edu>
Tue, 24 Aug 2004 09:34:01 +0000 (02:34 -0700)
committerGreg Kroah-Hartman <greg@kroah.com>
Tue, 24 Aug 2004 09:34:01 +0000 (02:34 -0700)
Greg:

This patch updates the part of the usbtest driver that tests URB
unlinking.  The move to usb_kill_urb() invalidated some of the old tests.
There's a corresponding change to the UHCI driver, causing it to return a
more descriptive error code in the rare event that an URB is cancelled
after it has been linked but before it has been queued.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
drivers/usb/host/uhci-hcd.c
drivers/usb/misc/usbtest.c

index e444c2944b82c57e9c13698f4dc6f892946daf6a..00e6eb15a6ce70cb2c3b9bd688eadab54599b2b6 100644 (file)
@@ -1340,7 +1340,7 @@ static struct urb *uhci_find_urb_ep(struct uhci_hcd *uhci, struct urb *urb)
 
 static int uhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, int mem_flags)
 {
-       int ret = -EINVAL;
+       int ret;
        struct uhci_hcd *uhci = hcd_to_uhci(hcd);
        unsigned long flags;
        struct urb *eurb;
@@ -1348,7 +1348,8 @@ static int uhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, int mem_flags)
 
        spin_lock_irqsave(&uhci->schedule_lock, flags);
 
-       if (urb->status != -EINPROGRESS)        /* URB already unlinked! */
+       ret = urb->status;
+       if (ret != -EINPROGRESS)                /* URB already unlinked! */
                goto out;
 
        eurb = uhci_find_urb_ep(uhci, urb);
index 8ee1b05ea879dec99b069bad2a10150271550d17..a03b8d44a782cbdb989ee65e79579d40e52924f7 100644 (file)
@@ -1054,8 +1054,7 @@ static int unlink1 (struct usbtest_dev *dev, int pipe, int size, int async)
        urb = simple_alloc_urb (testdev_to_usbdev (dev), pipe, size);
        if (!urb)
                return -ENOMEM;
-       if (async)
-               urb->transfer_flags |= URB_ASYNC_UNLINK;
+       urb->transfer_flags |= URB_ASYNC_UNLINK;
        urb->context = &completion;
        urb->complete = unlink1_callback;
 
@@ -1074,17 +1073,20 @@ static int unlink1 (struct usbtest_dev *dev, int pipe, int size, int async)
         * hcd states and code paths, even with little other system load.
         */
        msleep (jiffies % (2 * INTERRUPT_RATE));
+       if (async) {
 retry:
-       retval = usb_unlink_urb (urb);
-       if (retval == -EBUSY || retval == -EIDRM) {
-               /* we can't unlink urbs while they're completing.
-                * or if they've completed, and we haven't resubmitted.
-                * "normal" drivers would prevent resubmission, but
-                * since we're testing unlink paths, we can't.
-                */
-               dev_dbg (&dev->intf->dev, "unlink retry\n");
-               goto retry;
-       }
+               retval = usb_unlink_urb (urb);
+               if (retval == -EBUSY || retval == -EIDRM) {
+                       /* we can't unlink urbs while they're completing.
+                        * or if they've completed, and we haven't resubmitted.
+                        * "normal" drivers would prevent resubmission, but
+                        * since we're testing unlink paths, we can't.
+                        */
+                       dev_dbg (&dev->intf->dev, "unlink retry\n");
+                       goto retry;
+               }
+       } else
+               usb_kill_urb (urb);
        if (!(retval == 0 || retval == -EINPROGRESS)) {
                dev_dbg (&dev->intf->dev, "unlink fail %d\n", retval);
                return retval;
@@ -1095,9 +1097,10 @@ retry:
        simple_free_urb (urb);
 
        if (async)
-               return (retval != -ECONNRESET) ? -ECONNRESET : 0;
+               return (retval == -ECONNRESET) ? 0 : retval - 1000;
        else
-               return (retval != -ENOENT) ? -ENOENT : 0;
+               return (retval == -ENOENT || retval == -EPERM) ?
+                               0 : retval - 2000;
 }
 
 static int unlink_simple (struct usbtest_dev *dev, int pipe, int len)