ChangeSet 1.1018.1.16, 2003/04/07 10:17:40-07:00, mdharm-usb@one-eyed-alien.net

[PATCH] usb-storage: fix CB/CBI

When we fixed the error handling, we accidentally made a mistake.  A STALL
on a control endpoint isn't necessarily a fatal thing -- it can be used to
indicate a command failure.

This fixes bugzilla bug #510.

 - A control endpoint stall when sending the command to a CB/CBI device is
   legal.  Our error handling was just a little too agressive.


 drivers/usb/storage/transport.c |   21 +++++++++++++++++----
 1 files changed, 17 insertions(+), 4 deletions(-)


diff -Nru a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c
--- a/drivers/usb/storage/transport.c	Mon Apr  7 15:12:46 2003
+++ b/drivers/usb/storage/transport.c	Mon Apr  7 15:12:46 2003
@@ -297,10 +297,11 @@
 
 	/* stalled */
 	case -EPIPE:
-		/* for control endpoints, a stall indicates a protocol error */
+		/* for control endpoints, (used by CB[I]) a stall indicates
+		 * a failed command */
 		if (usb_pipecontrol(pipe)) {
 			US_DEBUGP("-- stall on control pipe\n");
-			return USB_STOR_XFER_ERROR;
+			return USB_STOR_XFER_STALLED;
 		}
 
 		/* for other sorts of endpoint, clear the stall */
@@ -750,8 +751,14 @@
 
 	/* check the return code for the command */
 	US_DEBUGP("Call to usb_stor_ctrl_transfer() returned %d\n", result);
+
+	/* if we stalled the command, it means command failed */
+	if (result == USB_STOR_XFER_STALLED) {
+		return USB_STOR_TRANSPORT_FAILED;
+	}
+
+	/* Uh oh... serious problem here */
 	if (result != USB_STOR_XFER_GOOD) {
-		/* Uh oh... serious problem here */
 		return USB_STOR_TRANSPORT_ERROR;
 	}
 
@@ -834,8 +841,14 @@
 
 	/* check the return code for the command */
 	US_DEBUGP("Call to usb_stor_ctrl_transfer() returned %d\n", result);
+
+	/* if we stalled the command, it means command failed */
+	if (result == USB_STOR_XFER_STALLED) {
+		return USB_STOR_TRANSPORT_FAILED;
+	}
+
+	/* Uh oh... serious problem here */
 	if (result != USB_STOR_XFER_GOOD) {
-		/* Uh oh... serious problem here */
 		return USB_STOR_TRANSPORT_ERROR;
 	}
 
