This patch implements the change discussed last weekend. Rather than allocating separate memory areas for the "extra" descriptors and copying the descriptor contents, it simply makes the "extra" pointers refer to memory within the rawdescriptor arrays.
Alan Stern # This is a BitKeeper generated patch for the following project: # Project Name: greg k-h's linux 2.5 USB kernel tree # This patch format is intended for GNU patch command version 2.5 or higher. # This patch includes the following deltas: # ChangeSet 1.1677 -> 1.1678 # drivers/usb/core/config.c 1.24 -> 1.25 # # The following is the BitKeeper ChangeSet Log # -------------------------------------------- # 03/09/15 [EMAIL PROTECTED] 1.1678 # Change the "extra" descriptor pointers to point at areas within the # rawdescriptors arrays instead of using separately-allocated copies. # -------------------------------------------- # diff -Nru a/drivers/usb/core/config.c b/drivers/usb/core/config.c --- a/drivers/usb/core/config.c Mon Sep 15 14:14:46 2003 +++ b/drivers/usb/core/config.c Mon Sep 15 14:14:46 2003 @@ -17,7 +17,7 @@ unsigned char *buffer0 = buffer; struct usb_descriptor_header *header; unsigned char *begin; - int len, numskipped; + int numskipped; header = (struct usb_descriptor_header *)buffer; if (header->bDescriptorType != USB_DT_ENDPOINT) { @@ -65,19 +65,8 @@ } if (numskipped) { dbg("skipped %d class/vendor specific endpoint descriptors", numskipped); - - /* Copy any unknown descriptors into a storage area for drivers */ - /* to later parse */ - len = buffer - begin; - - endpoint->extra = kmalloc(len, GFP_KERNEL); - if (!endpoint->extra) { - err("couldn't allocate memory for endpoint extra descriptors"); - return -ENOMEM; - } - - memcpy(endpoint->extra, begin, len); - endpoint->extralen = len; + endpoint->extra = begin; + endpoint->extralen = buffer - begin; } return buffer - buffer0; @@ -87,22 +76,14 @@ { struct usb_interface *intf; int j; - int k; intf = to_usb_interface(dev); if (intf->altsetting) { for (j = 0; j < intf->num_altsetting; j++) { struct usb_host_interface *as = &intf->altsetting[j]; - if (as->extra) - kfree(as->extra); - if (as->endpoint) { - for (k = 0; k < as->desc.bNumEndpoints; k++) - if (as->endpoint[k].extra) - kfree(as->endpoint[k].extra); - kfree(as->endpoint); - } + kfree(as->endpoint); } kfree(intf->altsetting); } @@ -183,18 +164,8 @@ } if (numskipped) { dbg("skipped %d class/vendor specific interface descriptors", numskipped); - - /* Copy any unknown descriptors into a storage area for */ - /* drivers to later parse */ - len = buffer - begin; - ifp->extra = kmalloc(len, GFP_KERNEL); - - if (!ifp->extra) { - err("couldn't allocate memory for interface extra descriptors"); - return -ENOMEM; - } - memcpy(ifp->extra, begin, len); - ifp->extralen = len; + ifp->extra = begin; + ifp->extralen = buffer - begin; } if (ifp->desc.bNumEndpoints > USB_MAXENDPOINTS) { @@ -355,18 +326,8 @@ } if (numskipped) { dbg("skipped %d class/vendor specific configuration descriptors", numskipped); - - /* Copy any unknown descriptors into a storage area for */ - /* drivers to later parse */ - len = buffer - begin; - config->extra = kmalloc(len, GFP_KERNEL); - if (!config->extra) { - err("couldn't allocate memory for config extra descriptors"); - return -ENOMEM; - } - - memcpy(config->extra, begin, len); - config->extralen = len; + config->extra = begin; + config->extralen = buffer - begin; } /* Parse all the interface/altsetting descriptors */ @@ -418,7 +379,6 @@ if (ifp) put_device(&ifp->dev); } - kfree(cf->extra); } kfree(dev->config); } ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ [EMAIL PROTECTED] To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel