ChangeSet 1.2020.1.17, 2005/03/07 22:32:28-08:00, [EMAIL PROTECTED]

[PATCH] USB: Retry more aggressively during device initialization

This patch make the hub driver's device initialization routine more
aggressive about detecting errors and retrying.  It checks the result of
the 64-byte GET-DESCRIPTOR request to verify that the descriptor tag is
set correctly and the ep0-maxpacket value is legal; if either is not true
it will retry the request immediately.  David Brownell has said that this
kind of approach is necessary to make certain buggy devices work.


Signed-off-by: Alan Stern <[EMAIL PROTECTED]>
Signed-off-by: Greg Kroah-Hartman <[EMAIL PROTECTED]>


 drivers/usb/core/hub.c |   28 ++++++++++++++++++----------
 1 files changed, 18 insertions(+), 10 deletions(-)


diff -Nru a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
--- a/drivers/usb/core/hub.c    2005-03-08 16:55:02 -08:00
+++ b/drivers/usb/core/hub.c    2005-03-08 16:55:02 -08:00
@@ -2181,24 +2181,35 @@
                                retval = -ENOMEM;
                                continue;
                        }
-                       buf->bMaxPacketSize0 = 0;
 
                        /* Use a short timeout the first time through,
                         * so that recalcitrant full-speed devices with
                         * 8- or 16-byte ep0-maxpackets won't slow things
                         * down tremendously by NAKing the unexpectedly
-                        * early status stage.  Also, retry on length 0
-                        * or stall; some devices are flakey.
+                        * early status stage.  Also, retry on all errors;
+                        * some devices are flakey.
                         */
                        for (j = 0; j < 3; ++j) {
+                               buf->bMaxPacketSize0 = 0;
                                r = usb_control_msg(udev, usb_rcvaddr0pipe(),
                                        USB_REQ_GET_DESCRIPTOR, USB_DIR_IN,
                                        USB_DT_DEVICE << 8, 0,
                                        buf, GET_DESCRIPTOR_BUFSIZE,
                                        (i ? HZ * USB_CTRL_GET_TIMEOUT : HZ));
-                               if (r == 0 || r == -EPIPE)
-                                       continue;
-                               if (r < 0)
+                               switch (buf->bMaxPacketSize0) {
+                               case 8: case 16: case 32: case 64:
+                                       if (buf->bDescriptorType ==
+                                                       USB_DT_DEVICE) {
+                                               r = 0;
+                                               break;
+                                       }
+                                       /* FALL THROUGH */
+                               default:
+                                       if (r == 0)
+                                               r = -EPROTO;
+                                       break;
+                               }
+                               if (r == 0)
                                        break;
                        }
                        udev->descriptor.bMaxPacketSize0 =
@@ -2214,10 +2225,7 @@
                                retval = -ENODEV;
                                goto fail;
                        }
-                       switch (udev->descriptor.bMaxPacketSize0) {
-                       case 64: case 32: case 16: case 8:
-                               break;
-                       default:
+                       if (r) {
                                dev_err(&udev->dev, "device descriptor "
                                                "read/%s, error %d\n",
                                                "64", r);



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_ide95&alloc_id396&op=click
_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to