Kyle:

Here's an initial try at a patch for 2.6.0.  Anything that finally gets 
accepted will undoubtedly be a good deal different from this, but it's a 
start.

Alan Stern



--- 2.6.0/drivers/usb/core/usb.c.orig   Thu Jul 22 15:56:29 2004
+++ 2.6.0/drivers/usb/core/usb.c        Thu Jul 22 17:17:11 2004
@@ -984,6 +984,7 @@
 #define SET_ADDRESS_RETRYS     2
 int usb_new_device(struct usb_device *dev, struct device *parent)
 {
+       char *buf;
        int err = 0;
        int i;
        int j;
@@ -1019,11 +1020,12 @@
                i = 64;
                break;
        case USB_SPEED_FULL:            /* 8, 16, 32, or 64 */
-               /* to determine the ep0 maxpacket size, read the first 8
-                * bytes from the device descriptor to get bMaxPacketSize0;
-                * then correct our initial (small) guess.
+               /* to determine the ep0 maxpacket size, try to read
+                * the device descriptor to get bMaxPacketSize0;
+                * then correct our initial (large) guess.
                 */
-               // FALLTHROUGH
+               i = 64;
+               break;
        case USB_SPEED_LOW:             /* fixed at 8 */
                i = 8;
                break;
@@ -1033,6 +1035,27 @@
        dev->epmaxpacketin [0] = i;
        dev->epmaxpacketout[0] = i;
 
+       buf = kmalloc(64, GFP_KERNEL);
+       if (!buf) {
+               clear_bit(dev->devnum, dev->bus->devmap.devicemap);
+               dev->devnum = -1;
+               return 1;
+       }
+       i = dev->devnum;
+       dev->devnum = 0;
+       err = usb_get_descriptor(dev, USB_DT_DEVICE, 0, buf, 64);
+       if (err < 8) {
+               err("USB device failed initial GET_DESCRIPTOR (err=%d)", err);
+               clear_bit(i, dev->bus->devmap.devicemap);
+               dev->devnum = -1;
+               kfree(buf);
+               return 1;
+       }
+       dev->devnum = i;
+       dev->epmaxpacketin[0] = dev->epmaxpacketout[0] =
+               ((struct usb_device_descriptor *) buf)->bMaxPacketSize0;
+       kfree(buf);
+
        for (i = 0; i < NEW_DEVICE_RETRYS; ++i) {
 
                for (j = 0; j < SET_ADDRESS_RETRYS; ++j) {
@@ -1049,27 +1072,15 @@
                        return 1;
                }
 
-               wait_ms(10);    /* Let the SET_ADDRESS settle */
-
-               /* high and low speed devices don't need this... */
-               err = usb_get_descriptor(dev, USB_DT_DEVICE, 0, &dev->descriptor, 8);
-               if (err >= 8)
-                       break;
                wait_ms(100);
+               break;
        }
 
-       if (err < 8) {
-               if (err < 0)
-                       err("USB device not responding, giving up (error=%d)", err);
-               else
-                       err("USB device descriptor short read (expected %i, got %i)", 
8, err);
+       if (err < 0) {
+               err("USB device not responding, giving up (error=%d)", err);
                clear_bit(dev->devnum, dev->bus->devmap.devicemap);
                dev->devnum = -1;
                return 1;
-       }
-       if (dev->speed == USB_SPEED_FULL) {
-               dev->epmaxpacketin [0] = dev->descriptor.bMaxPacketSize0;
-               dev->epmaxpacketout[0] = dev->descriptor.bMaxPacketSize0;
        }
 
        /* USB device state == addressed ... still not usable */



-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=4721&alloc_id=10040&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