Currently, the round-robin devnum allocation uses a static int which is
incremented over all buses.  Since devnums are totally unrelated between busses,
this patch changes the devnum_next to a per-bus devnum_next.

The #define DEVNUM_ROUND_ROBIN option is moved into include/linux/usb.h.




diff -ur 2.4.2-clean/drivers/usb/usb.c linux/drivers/usb/usb.c
--- 2.4.2-clean/drivers/usb/usb.c       Fri Feb  9 14:30:23 2001
+++ linux/drivers/usb/usb.c     Sun Mar 11 16:07:46 2001
@@ -39,11 +39,6 @@
 #endif
 #include <linux/usb.h>
 
-#define DEVNUM_ROUND_ROBIN     /***** OPTION *****/
-#ifdef DEVNUM_ROUND_ROBIN
-static int devnum_next = 1;
-#endif
-
 static const int usb_bandwidth_option =
 #ifdef CONFIG_USB_BANDWIDTH
                                1;
@@ -364,6 +359,10 @@
 
        memset(&bus->devmap, 0, sizeof(struct usb_devmap));
 
+#ifdef DEVNUM_ROUND_ROBIN
+       bus->devnum_next = 1;
+#endif /* DEVNUM_ROUND_ROBIN */
+
        bus->op = op;
        bus->root_hub = NULL;
        bus->hcpriv = NULL;
@@ -1681,14 +1680,12 @@
 #ifndef DEVNUM_ROUND_ROBIN
        devnum = find_next_zero_bit(dev->bus->devmap.devicemap, 128, 1);
 #else  /* round_robin alloc of devnums */
-       /* Try to allocate the next devnum beginning at devnum_next. */
-       devnum = find_next_zero_bit(dev->bus->devmap.devicemap, 128, devnum_next);
+       /* Try to allocate the next devnum beginning at bus->devnum_next. */
+       devnum = find_next_zero_bit(dev->bus->devmap.devicemap, 128, 
+dev->bus->devnum_next);
        if (devnum >= 128)
                devnum = find_next_zero_bit(dev->bus->devmap.devicemap, 128, 1);
 
-       devnum_next = devnum + 1;
-       if (devnum_next >= 128)
-               devnum_next = 1;
+       dev->bus->devnum_next = ( devnum >= 127 ? 1 : devnum + 1);
 #endif /* round_robin alloc of devnums */
 
        if (devnum < 128) {
diff -ur 2.4.2-clean/include/linux/usb.h linux/include/linux/usb.h
--- 2.4.2-clean/include/linux/usb.h     Wed Feb 21 19:11:24 2001
+++ linux/include/linux/usb.h   Sun Mar 11 15:52:13 2001
@@ -555,11 +555,17 @@
        int (*unlink_urb) (struct urb* purb);
 };
 
+#define DEVNUM_ROUND_ROBIN     /***** OPTION *****/
+
 /*
  * Allocated per bus we have
  */
 struct usb_bus {
        int busnum;                     /* Bus number (in order of reg) */
+
+#ifdef DEVNUM_ROUND_ROBIN
+       int devnum_next;                /* Next open device number in round-robin 
+allocation */
+#endif /* DEVNUM_ROUND_ROBIN */
 
        struct usb_devmap devmap;       /* Device map */
        struct usb_operations *op;      /* Operations (specific to the HC) */


_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
http://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to