diff -aur linux-2.3.11-original/drivers/usb/usb.c linux-2.3.11/drivers/usb/usb.c --- linux-2.3.11-original/drivers/usb/usb.c Mon Jul 19 11:17:32 1999 +++ linux-2.3.11/drivers/usb/usb.c Thu Jul 22 21:50:03 1999 @@ -449,6 +449,7 @@ struct usb_config_descriptor *cf; struct usb_alternate_setting *as; struct usb_interface_descriptor *ifp; + struct usb_string_list *strings; if(dev->config==NULL) return; @@ -476,18 +477,16 @@ } kfree(dev->config); - for (i = 1; i < USB_MAXSTRINGS; ++i) { - if (dev->stringindex[i]) { - kfree(dev->stringindex[i]); - dev->stringindex[i] = 0; + strings = dev->strings; + while (strings != NULL) { + struct usb_string_list *nextString; + if (strings->string) { + kfree(strings->string); } + nextString = strings->next; + kfree(strings); + strings = nextString; } -#if 0 - if (dev->stringindex) - kfree(dev->stringindex); - if (dev->stringtable) - kfree(dev->stringtable); -#endif } void usb_init_root_hub(struct usb_device *dev) @@ -910,76 +909,32 @@ return parse; } -#if 0 -int usb_get_stringtable(struct usb_device *dev) -{ - int i; - int maxindex; - int langid; - unsigned char buffer[256]; - int totalchars; - struct usb_string_descriptor *sd = (struct usb_string_descriptor *)buffer; - char *string; - __u8 bLengths[USB_MAXSTRINGS+1]; - int j; - - dev->maxstring = 0; - if(usb_get_string(dev, 0, 0, buffer, 2) || - usb_get_string(dev, 0, 0, buffer, sd->bLength)) - return -1; - /* we are going to assume that the first ID is good */ - langid = le16_to_cpup(&sd->wData[0]); - - /* whip through and find total length and max index */ - for (maxindex = 1, totalchars = 0; maxindex<=USB_MAXSTRINGS; maxindex++) { - if(usb_get_string(dev, langid, maxindex, buffer, 2)) - break; - totalchars += (sd->bLength - 2)/2 + 1; - bLengths[maxindex] = sd->bLength; - } - if (--maxindex <= 0) - return -1; - - /* get space for strings and index */ - dev->stringindex = kmalloc(sizeof(char *) * (maxindex+1), GFP_KERNEL); - if (!dev->stringindex) - return -1; - dev->stringtable = kmalloc(totalchars, GFP_KERNEL); - if (!dev->stringtable) { - kfree(dev->stringindex); - dev->stringindex = NULL; - return -1; - } - - /* fill them in */ - memset(dev->stringindex, 0, sizeof(char *) * (maxindex+1)); - for (i=1, string = dev->stringtable; i <= maxindex; i++) { - if (usb_get_string(dev, langid, i, buffer, bLengths[i])) - continue; - dev->stringindex[i] = string; - for (j=0; j < (bLengths[i] - 2)/2; j++) { - *string++ = le16_to_cpup(&sd->wData[j]); - } - *string++ = '\0'; - } - dev->maxstring = maxindex; - return 0; -} -#endif char *usb_string(struct usb_device *dev, int index) { int len, i; char *ptr; + struct usb_string_list *tempString; + struct usb_string_list *prevString; union { unsigned char buffer[256]; struct usb_string_descriptor desc; } u; - if (index <= 0 || index >= USB_MAXSTRINGS) + if (index <= 0) return 0; - if (dev->stringindex[index] != 0) - return dev->stringindex[index]; + + tempString = dev->strings; + while (tempString) { + if (tempString->id == index) + return (tempString->string); + tempString = tempString->next; + } + + prevString = dev->strings; + if (prevString != NULL) + while (prevString->next != NULL) + prevString = prevString->next; if (dev->string_langid == 0) { /* read string descriptor 0 */ @@ -1004,7 +959,17 @@ ptr[i] = le16_to_cpup(&u.desc.wData[i]); ptr[i] = 0; - dev->stringindex[index] = ptr; + tempString = kmalloc (sizeof (struct usb_string_list), GFP_KERNEL); + if (tempString == NULL) + return 0; + tempString->id = index; + tempString->string = ptr; + tempString->next = NULL; + if (dev->strings == NULL) + dev->strings = tempString; + else + prevString->next = tempString; + return ptr; } @@ -1079,8 +1044,6 @@ return; } - /* usb_get_stringtable(dev); */ - dev->actconfig = dev->config; dev->ifnum = 0; usb_set_maxpacket(dev); @@ -1088,11 +1051,6 @@ usb_show_string(dev, "Manufacturer", dev->descriptor.iManufacturer); usb_show_string(dev, "Product", dev->descriptor.iProduct); usb_show_string(dev, "SerialNumber", dev->descriptor.iSerialNumber); - -#if 0 - printk("Vendor: %X\n", dev->descriptor.idVendor); - printk("Product: %X\n", dev->descriptor.idProduct); -#endif if (usb_device_descriptor(dev)==0) { diff -aur linux-2.3.11-original/drivers/usb/usb.h linux-2.3.11/drivers/usb/usb.h --- linux-2.3.11-original/drivers/usb/usb.h Mon Jul 19 11:19:28 1999 +++ linux-2.3.11/drivers/usb/usb.h Thu Jul 22 22:18:32 1999 @@ -170,7 +170,6 @@ #define USB_MAXALTSETTING 5 #define USB_MAXINTERFACES 32 #define USB_MAXENDPOINTS 32 -#define USB_MAXSTRINGS 32 struct usb_device_descriptor { __u8 bLength; @@ -308,6 +307,12 @@ void *hcpriv; /* Host Controller private data */ }; +/* Allocated for every string that we read in */ +struct usb_string_list { + __u8 id; + char *string; + struct usb_string_list *next; +}; #define USB_MAXCHILDREN (8) @@ -325,7 +330,7 @@ struct usb_device_descriptor descriptor;/* Descriptor */ struct usb_config_descriptor *config; /* All of the configs */ struct usb_device *parent; - char *stringindex[USB_MAXSTRINGS]; /* pointers to strings */ + struct usb_string_list *strings; /* All of the strings */ int string_langid; /* language ID for strings */ /*