Merge branch 'upstream'
[powerpc.git] / drivers / usb / storage / usb.c
index 2557711..f9a9bfa 100644 (file)
@@ -90,7 +90,9 @@
 #ifdef CONFIG_USB_STORAGE_JUMPSHOT
 #include "jumpshot.h"
 #endif
-
+#ifdef CONFIG_USB_STORAGE_ONETOUCH
+#include "onetouch.h"
+#endif
 
 /* Some informational data */
 MODULE_AUTHOR("Matthew Dharm <mdharm-usb@one-eyed-alien.net>");
@@ -390,11 +392,16 @@ SkipForAbort:
                /* If an abort request was received we need to signal that
                 * the abort has finished.  The proper test for this is
                 * the TIMED_OUT flag, not srb->result == DID_ABORT, because
-                * a timeout/abort request might be received after all the
-                * USB processing was complete. */
-               if (test_bit(US_FLIDX_TIMED_OUT, &us->flags))
+                * the timeout might have occurred after the command had
+                * already completed with a different result code. */
+               if (test_bit(US_FLIDX_TIMED_OUT, &us->flags)) {
                        complete(&(us->notify));
 
+                       /* Allow USB transfers to resume */
+                       clear_bit(US_FLIDX_ABORTING, &us->flags);
+                       clear_bit(US_FLIDX_TIMED_OUT, &us->flags);
+               }
+
                /* finished working on this command */
                us->srb = NULL;
                scsi_unlock(host);
@@ -833,6 +840,19 @@ static void quiesce_and_remove_host(struct us_data *us)
        /* Wait for the current command to finish, then remove the host */
        down(&us->dev_semaphore);
        up(&us->dev_semaphore);
+
+       /* queuecommand won't accept any new commands and the control
+        * thread won't execute a previously-queued command.  If there
+        * is such a command pending, complete it with an error. */
+       if (us->srb) {
+               us->srb->result = DID_NO_CONNECT << 16;
+               scsi_lock(us_to_host(us));
+               us->srb->scsi_done(us->srb);
+               us->srb = NULL;
+               scsi_unlock(us_to_host(us));
+       }
+
+       /* Now we own no commands so it's safe to remove the SCSI host */
        scsi_remove_host(us_to_host(us));
 }