Greg:

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.

Alan Stern



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

===== drivers/usb/core/hub.c 1.223 vs edited =====
--- 1.223/drivers/usb/core/hub.c        2005-01-11 12:14:56 -05:00
+++ edited/drivers/usb/core/hub.c       2005-01-13 11:51:32 -05:00
@@ -2180,24 +2180,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 =
@@ -2213,10 +2224,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);



-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues
Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
_______________________________________________
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to