David Brownell wrote:
> 
> > 2.  The code that generates bcdDevice for the root hub is a maintenance
> > problem (will it still say 2.4 when the kernel is 2.8? :)
> 
> I just picked "2.4" because it's "42" backward ... but I'd be content
> with your approach to make it track the kernel version!  :-)
OK, I left this alone.

> > So I then thought about maybe adding the kernel string as the
> > manufacturer:
> 
> In fact, I'd like to fix all that stuff someday:
> 
>     Manufacturer = "Linux $(KERNEL_VERSION) $(DRIVER_NAME) USB Host"
>     Product="... from pci_dev->description"
>     Serial="...from pci_dev->slot_name"
> 
> The serial number should be a more "stable" identifier than it is today,
> and the other information should be more informative.
I liked this idea so much, I decided to try to implement it. See
attached
patch. On my OHCI / UHCI system, with this patch, /proc/bus/usb/devices 
looks like:
T:  Bus=02 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#=  2 Spd=12  MxCh= 2
B:  Alloc=  0/900 us ( 0%), #Int=  0, #Iso=  0
D:  Ver= 1.10 Cls=09(hub  ) Sub=00 Prot=00 MxPS= 8 #Cfgs=  1
P:  Vendor=0000 ProdID=0000 Rev= 0.00
S:  Manufacturer=Linux 2.4.2-ac11 OHCI Root Hub
S:  Product=OPTi Inc. 82C861
S:  SerialNumber=00:0f.0
C:* #Ifs= 1 Cfg#= 1 Atr=40 MxPwr=  0mA
I:  If#= 0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub
E:  Ad=81(I) Atr=03(Int.) MxPS=   2 Ivl=255ms
T:  Bus=01 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#=  1 Spd=12  MxCh= 2
B:  Alloc=129/900 us (14%), #Int=  2, #Iso=  0
D:  Ver= 1.00 Cls=09(hub  ) Sub=00 Prot=00 MxPS= 8 #Cfgs=  1
P:  Vendor=0000 ProdID=0000 Rev= 0.00
S:  Manufacturer=Linux 2.4.2-ac11 UHCI Root Hub
S:  Product=Intel Corporation 82371AB PIIX4 USB
S:  SerialNumber=00:07.2
C:* #Ifs= 1 Cfg#= 1 Atr=40 MxPwr=  0mA
I:  If#= 0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub
E:  Ad=81(I) Atr=03(Int.) MxPS=   8 Ivl=255ms

Comments?
I also tested it with uhci.c (aka JE, aka alt-uhci) and it seemed 
to work OK. Seems OK with usbview as well.
diff -Naur -X dontdiff linux-2.4.2ac11-clean/drivers/usb/uhci.c 
linux/drivers/usb/uhci.c
--- linux-2.4.2ac11-clean/drivers/usb/uhci.c    Sun Mar  4 19:59:22 2001
+++ linux/drivers/usb/uhci.c    Sun Mar  4 19:10:40 2001
@@ -1811,7 +1811,7 @@
        0x00,
        0x00,                   /*  __u16 bcdDevice; */
        0x00,
-       0x00,                   /*  __u8  iManufacturer; */
+       0x03,                   /*  __u8  iManufacturer; */
        0x02,                   /*  __u8  iProduct; */
        0x01,                   /*  __u8  iSerialNumber; */
        0x01                    /*  __u8  bNumConfigurations; */
@@ -2121,7 +2121,7 @@
                        OK(len);
                case 0x03:      /* string descriptors */
                        len = usb_root_hub_string(wValue & 0xff,
-                               uhci->io_addr, "UHCI-alt",
+                               uhci->dev, "UHCI-alt",
                                data, wLength);
                        if (len > 0) {
                                OK(min (leni, len));
diff -Naur -X dontdiff linux-2.4.2ac11-clean/drivers/usb/usb-ohci.c 
linux/drivers/usb/usb-ohci.c
--- linux-2.4.2ac11-clean/drivers/usb/usb-ohci.c        Sun Mar  4 19:59:22 2001
+++ linux/drivers/usb/usb-ohci.c        Sun Mar  4 19:46:16 2001
@@ -1581,7 +1581,7 @@
        0x00,
        0x00,       /*  __u16 bcdDevice; */
        0x00,
-       0x00,       /*  __u8  iManufacturer; */
+       0x03,       /*  __u8  iManufacturer; */
        0x02,       /*  __u8  iProduct; */
        0x01,       /*  __u8  iSerialNumber; */
        0x01        /*  __u8  bNumConfigurations; */
@@ -1854,7 +1854,7 @@
                                        data_buf = root_hub_config_des; OK(len);
                                case (0x03): /* string descriptors */
                                        len = usb_root_hub_string (wValue & 0xff,
-                                               (int)(long) ohci->regs, "OHCI",
+                                               ohci->ohci_dev, "OHCI",
                                                data, wLength);
                                        if (len > 0) {
                                                data_buf = data;
diff -Naur -X dontdiff linux-2.4.2ac11-clean/drivers/usb/usb-uhci.c 
linux/drivers/usb/usb-uhci.c
--- linux-2.4.2ac11-clean/drivers/usb/usb-uhci.c        Sun Mar  4 19:59:22 2001
+++ linux/drivers/usb/usb-uhci.c        Sun Mar  4 19:48:01 2001
@@ -1790,7 +1790,7 @@
        0x00,
        0x00,                   /*  __u16 bcdDevice; */
        0x00,
-       0x00,                   /*  __u8  iManufacturer; */
+       0x03,                   /*  __u8  iManufacturer; */
        0x02,                   /*  __u8  iProduct; */
        0x01,                   /*  __u8  iSerialNumber; */
        0x01                    /*  __u8  bNumConfigurations; */
@@ -2091,7 +2091,7 @@
                        OK (len);
                case (0x03):    /* string descriptors */
                        len = usb_root_hub_string (wValue & 0xff,
-                               uhci->io_addr, "UHCI",
+                               uhci->uhci_pci, "UHCI",
                                data, wLength);
                        if (len > 0) {
                                OK (min (leni, len));
diff -Naur -X dontdiff linux-2.4.2ac11-clean/drivers/usb/usb.c linux/drivers/usb/usb.c
--- linux-2.4.2ac11-clean/drivers/usb/usb.c     Sun Mar  4 19:59:23 2001
+++ linux/drivers/usb/usb.c     Sun Mar  4 19:27:29 2001
@@ -32,7 +32,8 @@
 #include <linux/init.h>
 #include <linux/devfs_fs_kernel.h>
 #include <linux/spinlock.h>
-
+#include <linux/version.h>    /* for UTS_RELEASE */
+#include <linux/pci.h>        /* for root hub info */
 #ifdef CONFIG_USB_DEBUG
        #define DEBUG
 #else
@@ -1596,9 +1597,9 @@
  * root_hub_string is used by each host controller's root hub code,
  * so that they're identified consistently throughout the system.
  */
-int usb_root_hub_string (int id, int serial, char *type, __u8 *data, int len)
+int usb_root_hub_string (int id, struct pci_dev *pci_desc, char *type, __u8 *data, 
+int len)
 {
-       char buf [30];
+       char buf [80];
 
        // assert (len > (2 * (sizeof (buf) + 1)));
        // assert (strlen (type) <= 8);
@@ -1611,13 +1612,15 @@
 
        // serial number
        } else if (id == 1) {
-               sprintf (buf, "%x", serial);
+               sprintf (buf, "%s", pci_desc->slot_name);
 
        // product description
        } else if (id == 2) {
-               sprintf (buf, "USB %s Root Hub", type);
-
+               sprintf (buf, "%s", pci_desc->name);
+       
        // id 3 == vendor description
+       } else if (id == 3) {
+               sprintf (buf, "Linux %s %s Root Hub", UTS_RELEASE, type);
 
        // unsupported IDs --> "stall"
        } else
diff -Naur -X dontdiff linux-2.4.2ac11-clean/include/linux/usb.h 
linux/include/linux/usb.h
--- linux-2.4.2ac11-clean/include/linux/usb.h   Sun Mar  4 19:59:34 2001
+++ linux/include/linux/usb.h   Sun Mar  4 19:24:57 2001
@@ -135,6 +135,7 @@
 #include <linux/interrupt.h>   /* for in_interrupt() */
 #include <linux/config.h>
 #include <linux/list.h>
+#include <linux/pci.h>          /* for root hub strings */
 
 #define USB_MAJOR 180
 
@@ -666,7 +667,7 @@
 
 extern int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request, 
__u8 requesttype, __u16 value, __u16 index, void *data, __u16 size, int timeout);
 
-extern int usb_root_hub_string(int id, int serial, char *type, __u8 *data, int len);
+extern int usb_root_hub_string(int id, struct pci_dev *pci_desc, char *type, __u8 
+*data, int len);
 extern void usb_connect(struct usb_device *dev);
 extern void usb_disconnect(struct usb_device **);
 

Reply via email to