]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - drivers/usb/core/message.c
Merge tag 'spi-v4.7' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi
[karo-tx-linux.git] / drivers / usb / core / message.c
index e13a2e5577156bde0da058192cdad6b767c720ab..ea681f157368f245772ab145073594bf4f6fb273 100644 (file)
@@ -577,31 +577,28 @@ EXPORT_SYMBOL_GPL(usb_sg_wait);
 void usb_sg_cancel(struct usb_sg_request *io)
 {
        unsigned long flags;
+       int i, retval;
 
        spin_lock_irqsave(&io->lock, flags);
+       if (io->status) {
+               spin_unlock_irqrestore(&io->lock, flags);
+               return;
+       }
+       /* shut everything down */
+       io->status = -ECONNRESET;
+       spin_unlock_irqrestore(&io->lock, flags);
 
-       /* shut everything down, if it didn't already */
-       if (!io->status) {
-               int i;
+       for (i = io->entries - 1; i >= 0; --i) {
+               usb_block_urb(io->urbs[i]);
 
-               io->status = -ECONNRESET;
-               spin_unlock(&io->lock);
-               for (i = 0; i < io->entries; i++) {
-                       int retval;
-
-                       usb_block_urb(io->urbs[i]);
-
-                       retval = usb_unlink_urb(io->urbs[i]);
-                       if (retval != -EINPROGRESS
-                                       && retval != -ENODEV
-                                       && retval != -EBUSY
-                                       && retval != -EIDRM)
-                               dev_warn(&io->dev->dev, "%s, unlink --> %d\n",
-                                       __func__, retval);
-               }
-               spin_lock(&io->lock);
+               retval = usb_unlink_urb(io->urbs[i]);
+               if (retval != -EINPROGRESS
+                   && retval != -ENODEV
+                   && retval != -EBUSY
+                   && retval != -EIDRM)
+                       dev_warn(&io->dev->dev, "%s, unlink --> %d\n",
+                                __func__, retval);
        }
-       spin_unlock_irqrestore(&io->lock, flags);
 }
 EXPORT_SYMBOL_GPL(usb_sg_cancel);