This patch fixes interpret_urb_result in two major ways:
(1) Uses a switch() instead of nested if() statements
(2) Handle -EREMOTEIO to indicate a short scatter-gather transfer

Greg, please apply.

Matt

# This is a BitKeeper generated patch for the following project:
# Project Name: greg k-h's linux 2.5 USB kernel tree
# This patch format is intended for GNU patch command version 2.5 or higher.
# This patch includes the following deltas:
#                  ChangeSet    1.659   -> 1.660  
#       drivers/usb/storage/transport.c 1.72    -> 1.73   
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 02/12/15      [EMAIL PROTECTED]       1.660
# Structural change: use switch() instead of nested if()s.
# Functional change: support -EREMOTEIO
# --------------------------------------------
#
diff -Nru a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c
--- a/drivers/usb/storage/transport.c   Sun Dec 15 18:20:26 2002
+++ b/drivers/usb/storage/transport.c   Sun Dec 15 18:20:26 2002
@@ -480,7 +480,7 @@
        status = usb_stor_msg_common(us);
 
        /* return the actual length of the data transferred if no error */
-       if (status >= 0)
+       if (status == 0)
                status = us->current_urb->actual_length;
        return status;
 }
@@ -583,50 +583,52 @@
 
        US_DEBUGP("Status code %d; transferred %u/%u\n",
                        result, partial, length);
+       switch (result) {
 
-       /* stalled */
-       if (result == -EPIPE) {
+       /* no error code; did we send all the data? */
+       case 0:
+               if (partial != length) {
+                       US_DEBUGP("-- short transfer\n");
+                       return USB_STOR_XFER_SHORT;
+               }
+
+               US_DEBUGP("-- transfer complete\n");
+               return USB_STOR_XFER_GOOD;
 
-               /* for non-bulk (i.e., control) endpoints, a stall indicates
-                * a protocol error */
-               if (!usb_pipebulk(pipe)) {
+       /* stalled */
+       case -EPIPE:
+               /* for control endpoints, a stall indicates a protocol error */
+               if (usb_pipecontrol(pipe)) {
                        US_DEBUGP("-- stall on control pipe\n");
                        return USB_STOR_XFER_ERROR;
                }
 
-               /* for a bulk endpoint, clear the stall */
+               /* for other sorts of endpoint, clear the stall */
                US_DEBUGP("clearing endpoint halt for pipe 0x%x\n", pipe);
                if (usb_stor_clear_halt(us, pipe) < 0)
                        return USB_STOR_XFER_ERROR;
                return USB_STOR_XFER_STALLED;
-       }
 
        /* NAK - that means we've retried this a few times already */
-       if (result == -ETIMEDOUT) {
+       case -ETIMEDOUT:
                US_DEBUGP("-- device NAKed\n");
                return USB_STOR_XFER_ERROR;
-       }
 
        /* the transfer was cancelled, presumably by an abort */
-       if (result == -ENODEV) {
+       case -ENODEV:
                US_DEBUGP("-- transfer cancelled\n");
                return USB_STOR_XFER_ERROR;
-       }
+
+       /* short scatter-gather read transfer */
+       case -EREMOTEIO:
+               US_DEBUGP("-- short read transfer\n");
+               return USB_STOR_XFER_SHORT;
 
        /* the catch-all error case */
-       if (result < 0) {
+       default:
                US_DEBUGP("-- unknown error\n");
                return USB_STOR_XFER_ERROR;
        }
-
-       /* no error code; did we send all the data? */
-       if (partial != length) {
-               US_DEBUGP("-- transferred only %u bytes\n", partial);
-               return USB_STOR_XFER_SHORT;
-       }
-
-       US_DEBUGP("-- transfer complete\n");
-       return USB_STOR_XFER_GOOD;
 }
 
 /*

-- 
Matthew Dharm                              Home: [EMAIL PROTECTED] 
Maintainer, Linux USB Mass Storage Driver

Ye gods! I have feet??!
                                        -- Dust Puppy
User Friendly, 12/4/1997

Attachment: msg10046/pgp00000.pgp
Description: PGP signature

Reply via email to