John Mock - 2004-10-26

linux-wlan-ng-0.2.1pre23 is now available at:

    ftp://ftp.linux-wlan.org/pub/linux-wlan-ng/

I generated a 'diff -u' with 0.2.1pre23 and applied it to the
most recent release here [Zydas1201-LinuxDriver-0.3.tar.gz]
without noting any major problems, and it gets rid of my need
to patch 'p80211conv.c' for Linux 2.6.9 .

Alas, it does not fix my 'kismet' troubles and still gets a
kernel OOPS if debug memory allocations (CONFIG_SLAB_DEBUG)
is set.  I'll supply comments/bug reports for them elsewhere.
            -- KD6PAG

P.S.  Attached is my current 'usbcore' patch for Linux-2.6.9 and it
looks like it'll be fixed in the kernel for 2.6.10 (i hope).

--- ./drivers/usb/core/Kconfig.orig    2004-10-18 14:55:21.000000000 -0700
+++ ./drivers/usb/core/Kconfig    2004-10-25 23:35:32.000000000 -0700
@@ -97,3 +97,18 @@
       convenient for many stages of product development.

+config USB_SET_ADDRESS_QUIRKY
+    bool "USB 'set address' quirky (EXPERIMENTAL)"
+    depends on USB && EXPERIMENTAL
+    help
+      This works around a problem with certain USB devices, such
+      as some inexpensive USB wireless networking devices, which do
+      not seem to set an address without first being asked for a
+      descriptor.
+
+      If you say Y here, the driver will do a dummy 'get descriptor'
+      operation before attempting to set an address (like Windows
+      does).  This may be require to make certain USB devices work
+      properly.  It might break others, but this seems unlikely.
+
+      If you are unsure about this, say N here.
--- ./drivers/usb/core/hub.c.orig    2004-10-18 14:54:07.000000000 -0700
+++ ./drivers/usb/core/hub.c    2004-10-26 00:22:04.000000000 -0700
@@ -1984,6 +1984,22 @@
     return retval;
}

+#ifdef CONFIG_USB_SET_ADDRESS_QUIRKY
+/* Try to get the descriptor from a device without address set.
+ * e.g. ZyDAS ZD1201 won't accept an address until this is done
+ */
+int usb_dummy_get_descriptor(struct usb_device *dev)
+{
+    char buffer[8];
+    int retval;
+
+    retval = usb_control_msg(dev, (PIPE_CONTROL << 30) | USB_DIR_IN,
+        USB_REQ_GET_DESCRIPTOR, USB_DIR_IN, USB_DT_DEVICE<<8, 0, buffer,
+        8, HZ * USB_CTRL_GET_TIMEOUT);
+    return retval;
+}
+#endif
+
/* Reset device, (re)assign address, get device descriptor.
  * Device connection must be stable, no more debouncing needed.
  * Returns device in USB_STATE_ADDRESS, except on error.
@@ -2089,6 +2105,10 @@
      * work around device bugs like "can't use addresses with bit 3
      * set in certain configurations".  Yes, really.
      */
+#ifdef CONFIG_USB_SET_ADDRESS_QUIRKY
+    usb_dummy_get_descriptor(udev);
+    msleep(100);
+#endif
     for (i = 0; i < GET_DESCRIPTOR_TRIES; ++i) {
         for (j = 0; j < SET_ADDRESS_TRIES; ++j) {
             retval = hub_set_address(udev);