Ok, repost changing the reserved bit to 15 from 5 and after trying to use 
a 'struct hub'->wireless bit (rationale below). This is against's gregkh's
quilt tree.

WUSB: basic device infrastructure modifications

This patch does a bunch of small modifications to the USB core so that WUSB
devices are accepted in the system. I finally got a well-behaved one that
allowed me to test these changes.

1. [this is not really needed] change usb_get_configuration() so that
   it is more tolerant to devices with bad configuration descriptors
   (it'll make it ignore configurations that fail to load).

2. Introduce USB_PORT_STAT_WIRELESS; we take one of the reserved bits
   in the USB port status (bit 15) to report that we are a wireless
   (fake port).

   Yes, bad bad, it is taken by the spec. The rationale for doing it
   like this is that we avoid having to use side channels to convey
   the information.

   There is no simple way to set a bit in the hub structure as we
   don't know it after we do usb_add_hcd() [struct usb_hcd points to
   'struct usb_dev *root_hub' at hcd->self.root_hub, but from there
   we'd have to find the binding information...etc, a mess].

   At suggestion from David Howell, moved from using bit 5 to bit 15.

3. If the port is wireless (as mentioned by USB_PORT_STAT_WIRELESS),
   enable the new speed rules (USB_SPEED_VARIABLE) and set ep0's
   maxpacketsize to 512 (even though the device descriptor reports
   it as 0xff).

4. Clean up the message for a new usb device and make it report wusb
   devices.

New code being pushed to linuxuwb.org requires this patch to connect WUSB
devices.

Signed-off-by: Inaky Perez-Gonzalez <[EMAIL PROTECTED]>

 drivers/usb/core/config.c |    4 +++-
 drivers/usb/core/hub.c    |   41 ++++++++++++++++++++++++++++-------------
 drivers/usb/core/hub.h    |    5 ++++-
 3 files changed, 35 insertions(+), 15 deletions(-)

--

Index: drivers/usb/core/config.c
===================================================================
--- drivers/usb/core/config.c.orig      2006-08-23 12:45:35.000000000 -0700
+++ drivers/usb/core/config.c   2006-08-23 12:55:04.000000000 -0700
@@ -475,7 +475,9 @@
                if (result < 0) {
                        dev_err(ddev, "unable to read config index %d "
                            "descriptor/%s\n", cfgno, "start");
-                       goto err;
+                       dev_err(ddev, "chopping to %d config(s)\n", cfgno);
+                       dev->descriptor.bNumConfigurations = cfgno;
+                       break;
                } else if (result < 4) {
                        dev_err(ddev, "config index %d descriptor too short "
                            "(expected %i, got %i)\n", cfgno,
Index: drivers/usb/core/hub.c
===================================================================
--- drivers/usb/core/hub.c.orig 2006-08-23 12:45:35.000000000 -0700
+++ drivers/usb/core/hub.c      2006-08-23 12:55:04.000000000 -0700
@@ -1406,7 +1406,9 @@
                /* if we`ve finished resetting, then break out of the loop */
                if (!(portstatus & USB_PORT_STAT_RESET) &&
                    (portstatus & USB_PORT_STAT_ENABLE)) {
-                       if (portstatus & USB_PORT_STAT_HIGH_SPEED)
+                       if (portstatus & USB_PORT_STAT_WIRELESS)
+                               udev->speed = USB_SPEED_VARIABLE;
+                       else if (portstatus & USB_PORT_STAT_HIGH_SPEED)
                                udev->speed = USB_SPEED_HIGH;
                        else if (portstatus & USB_PORT_STAT_LOW_SPEED)
                                udev->speed = USB_SPEED_LOW;
@@ -2043,6 +2045,7 @@
        int                     i, j, retval;
        unsigned                delay = HUB_SHORT_RESET_TIME;
        enum usb_device_speed   oldspeed = udev->speed;
+       char                    *speed, *type;
 
        /* root hub ports have a slightly longer reset period
         * (from USB 2.0 spec, section 7.1.7.5)
@@ -2075,8 +2078,13 @@
   
        /* USB 2.0 section 5.5.3 talks about ep0 maxpacket ...
         * it's fixed size except for full speed devices.
+        * For Wireless USB devices, ep0 max packet is always 512 (tho
+        * reported as 0xff in the device descriptor). WUSB1.0[4.8.1].
         */
        switch (udev->speed) {
+       case USB_SPEED_VARIABLE:        /* fixed at 512 */
+               udev->ep0.desc.wMaxPacketSize = __constant_cpu_to_le16(512);
+               break;
        case USB_SPEED_HIGH:            /* fixed at 64 */
                udev->ep0.desc.wMaxPacketSize = __constant_cpu_to_le16(64);
                break;
@@ -2094,17 +2102,21 @@
                goto fail;
        }
  
+       type = ""; 
+       switch (udev->speed) {
+       case USB_SPEED_LOW:     speed = "low";  break;
+       case USB_SPEED_FULL:    speed = "full"; break;
+       case USB_SPEED_HIGH:    speed = "high"; break;
+       case USB_SPEED_VARIABLE:        
+                               speed = "variable";
+                               type = "Wireless ";
+                               break;
+       default:                speed = "?";    break;
+       }
        dev_info (&udev->dev,
-                       "%s %s speed USB device using %s and address %d\n",
-                       (udev->config) ? "reset" : "new",
-                       ({ char *speed; switch (udev->speed) {
-                       case USB_SPEED_LOW:     speed = "low";  break;
-                       case USB_SPEED_FULL:    speed = "full"; break;
-                       case USB_SPEED_HIGH:    speed = "high"; break;
-                       default:                speed = "?";    break;
-                       }; speed;}),
-                       udev->bus->controller->driver->name,
-                       udev->devnum);
+                 "%s %s speed %sUSB device using %s and address %d\n",
+                 (udev->config) ? "reset" : "new", speed, type,
+                 udev->bus->controller->driver->name, udev->devnum);
 
        /* Set up TT records, if needed  */
        if (hdev->tt) {
@@ -2146,6 +2158,8 @@
                         * down tremendously by NAKing the unexpectedly
                         * early status stage.  Also, retry on all errors;
                         * some devices are flakey.
+                        * 255 is for WUSB devices, we actually need to use 512.
+                        * WUSB1.0[4.8.1].
                         */
                        for (j = 0; j < 3; ++j) {
                                buf->bMaxPacketSize0 = 0;
@@ -2155,7 +2169,7 @@
                                        buf, GET_DESCRIPTOR_BUFSIZE,
                                        (i ? USB_CTRL_GET_TIMEOUT : 1000));
                                switch (buf->bMaxPacketSize0) {
-                               case 8: case 16: case 32: case 64:
+                               case 8: case 16: case 32: case 64: case 255:
                                        if (buf->bDescriptorType ==
                                                        USB_DT_DEVICE) {
                                                r = 0;
@@ -2229,7 +2243,8 @@
        if (retval)
                goto fail;
 
-       i = udev->descriptor.bMaxPacketSize0;
+       i = udev->descriptor.bMaxPacketSize0 == 0xff? 
+           512 : udev->descriptor.bMaxPacketSize0;
        if (le16_to_cpu(udev->ep0.desc.wMaxPacketSize) != i) {
                if (udev->speed != USB_SPEED_FULL ||
                                !(i == 8 || i == 16 || i == 32 || i == 64)) {
Index: drivers/usb/core/hub.h
===================================================================
--- drivers/usb/core/hub.h.orig 2006-08-23 12:45:36.000000000 -0700
+++ drivers/usb/core/hub.h      2006-08-23 12:55:04.000000000 -0700
@@ -79,7 +79,10 @@
 #define USB_PORT_STAT_HIGH_SPEED        0x0400
 #define USB_PORT_STAT_TEST              0x0800
 #define USB_PORT_STAT_INDICATOR         0x1000
-/* bits 13 to 15 are reserved */
+/* bits 13 to 15 are reserved, we use 15 however, to mark a fake
+ * wireless status that denotes the port is in a wireless usb host
+ * root hub. */  
+#define USB_PORT_STAT_WIRELESS          0x8000
 
 /* 
  * wPortChange bit field

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
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