Commit cf2d2198 authored by Alan Stern's avatar Alan Stern Committed by Greg Kroah-Hartman

[PATCH] USB: Update unlink testing code in the usbtest driver

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: default avatarAlan Stern <stern@rowland.harvard.edu>
Signed-off-by: default avatarGreg Kroah-Hartman <greg@kroah.com>
parent b61ffbfe
...@@ -1340,7 +1340,7 @@ static struct urb *uhci_find_urb_ep(struct uhci_hcd *uhci, struct urb *urb) ...@@ -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) 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); struct uhci_hcd *uhci = hcd_to_uhci(hcd);
unsigned long flags; unsigned long flags;
struct urb *eurb; struct urb *eurb;
...@@ -1348,7 +1348,8 @@ static int uhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, int mem_flags) ...@@ -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); 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; goto out;
eurb = uhci_find_urb_ep(uhci, urb); eurb = uhci_find_urb_ep(uhci, urb);
......
...@@ -1054,8 +1054,7 @@ static int unlink1 (struct usbtest_dev *dev, int pipe, int size, int async) ...@@ -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); urb = simple_alloc_urb (testdev_to_usbdev (dev), pipe, size);
if (!urb) if (!urb)
return -ENOMEM; return -ENOMEM;
if (async) urb->transfer_flags |= URB_ASYNC_UNLINK;
urb->transfer_flags |= URB_ASYNC_UNLINK;
urb->context = &completion; urb->context = &completion;
urb->complete = unlink1_callback; urb->complete = unlink1_callback;
...@@ -1074,17 +1073,20 @@ static int unlink1 (struct usbtest_dev *dev, int pipe, int size, int async) ...@@ -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. * hcd states and code paths, even with little other system load.
*/ */
msleep (jiffies % (2 * INTERRUPT_RATE)); msleep (jiffies % (2 * INTERRUPT_RATE));
if (async) {
retry: retry:
retval = usb_unlink_urb (urb); retval = usb_unlink_urb (urb);
if (retval == -EBUSY || retval == -EIDRM) { if (retval == -EBUSY || retval == -EIDRM) {
/* we can't unlink urbs while they're completing. /* we can't unlink urbs while they're completing.
* or if they've completed, and we haven't resubmitted. * or if they've completed, and we haven't resubmitted.
* "normal" drivers would prevent resubmission, but * "normal" drivers would prevent resubmission, but
* since we're testing unlink paths, we can't. * since we're testing unlink paths, we can't.
*/ */
dev_dbg (&dev->intf->dev, "unlink retry\n"); dev_dbg (&dev->intf->dev, "unlink retry\n");
goto retry; goto retry;
} }
} else
usb_kill_urb (urb);
if (!(retval == 0 || retval == -EINPROGRESS)) { if (!(retval == 0 || retval == -EINPROGRESS)) {
dev_dbg (&dev->intf->dev, "unlink fail %d\n", retval); dev_dbg (&dev->intf->dev, "unlink fail %d\n", retval);
return retval; return retval;
...@@ -1095,9 +1097,10 @@ static int unlink1 (struct usbtest_dev *dev, int pipe, int size, int async) ...@@ -1095,9 +1097,10 @@ static int unlink1 (struct usbtest_dev *dev, int pipe, int size, int async)
simple_free_urb (urb); simple_free_urb (urb);
if (async) if (async)
return (retval != -ECONNRESET) ? -ECONNRESET : 0; return (retval == -ECONNRESET) ? 0 : retval - 1000;
else 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) static int unlink_simple (struct usbtest_dev *dev, int pipe, int len)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment