This is patch as384.  It reverts some of our sanity checks on the GetMaxLUN
part of the Bulk-only protocol.  Apparently, this is one area where vendors
can't even get close to correct.  So, in the face of any sort of error, we
assume a single LUN.

We also include some comments so we don't make this mistake again.

Greg, please apply.

Signed-off-by: Matthew Dharm <[EMAIL PROTECTED]>
Signed-off-by: Alan Stern <[EMAIL PROTECTED]>

# This is a BitKeeper generated diff -Nru style patch.
#
# ChangeSet
#   2004/09/26 13:04:58-07:00 [EMAIL PROTECTED] 
#   as384
# 
# drivers/usb/storage/transport.c
#   2004/09/26 13:04:38-07:00 [EMAIL PROTECTED] +9 -7
#   as384
# 
diff -Nru a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c
--- a/drivers/usb/storage/transport.c   Sun Sep 26 13:06:12 2004
+++ b/drivers/usb/storage/transport.c   Sun Sep 26 13:06:12 2004
@@ -911,7 +911,6 @@
        int result;
 
        /* issue the command */
-       us->iobuf[0] = 0;
        result = usb_stor_control_msg(us, us->recv_ctrl_pipe,
                                 US_BULK_GET_MAX_LUN, 
                                 USB_DIR_IN | USB_TYPE_CLASS | 
@@ -922,7 +921,7 @@
                  result, us->iobuf[0]);
 
        /* if we have a successful request, return the result */
-       if (result >= 0)
+       if (result > 0)
                return us->iobuf[0];
 
        /* 
@@ -934,13 +933,16 @@
        if (result == -EPIPE) {
                usb_stor_clear_halt(us, us->recv_bulk_pipe);
                usb_stor_clear_halt(us, us->send_bulk_pipe);
-               /* return the default -- no LUNs */
-               return 0;
        }
 
-       /* An answer or a STALL are the only valid responses.  If we get
-        * something else, return an indication of error */
-       return -1;
+       /*
+        * Some devices don't like GetMaxLUN.  They may STALL the control
+        * pipe, they may return a zero-length result, they may do nothing at
+        * all and timeout, or they may fail in even more bizarrely creative
+        * ways.  In these cases the best approach is to use the default
+        * value: only one LUN.
+        */
+       return 0;
 }
 
 int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us)
-- 
Matthew Dharm                              Home: [EMAIL PROTECTED] 
Maintainer, Linux USB Mass Storage Driver

Stef, you just got beaten by a ball of DIRT.
                                        -- Greg
User Friendly, 12/7/1997

Attachment: pgpU67tzVi6f9.pgp
Description: PGP signature

Reply via email to