ChangeSet 1.1315.8.23, 2003/09/17 17:09:21-07:00, [EMAIL PROTECTED]

[PATCH] USB: Changes to core/config.c (4 of 9)

Although it's hard to tell from reading the patch, this just moves one
section of code to a slightly different spot.  Currently the code that
skips over the extra class- and vendor-specific configuration-related
descriptors is part of the loop that parses interface descriptors.  The
patch moves it outside, immediately before that loop -- where it belongs.


 drivers/usb/core/config.c |   83 +++++++++++++++++++++-------------------------
 1 files changed, 39 insertions(+), 44 deletions(-)


diff -Nru a/drivers/usb/core/config.c b/drivers/usb/core/config.c
--- a/drivers/usb/core/config.c Fri Sep 19 17:10:00 2003
+++ b/drivers/usb/core/config.c Fri Sep 19 17:10:00 2003
@@ -251,8 +251,10 @@
        int nintf;
        int i, size;
        struct usb_interface *interface;
-       int retval;
+       int numskipped, len;
+       char *begin;
        struct usb_descriptor_header *header;
+       int retval;
 
        memcpy(&config->desc, buffer, USB_DT_CONFIG_SIZE);
        le16_to_cpus(&config->desc.wTotalLength);
@@ -284,55 +286,48 @@
        buffer += config->desc.bLength;
        size -= config->desc.bLength;
 
-       for (i = 0; i < nintf; i++) {
-               int numskipped, len;
-               char *begin;
+       /* Skip over any Class Specific or Vendor Specific descriptors */
+       begin = buffer;
+       numskipped = 0;
+       while (size >= sizeof(struct usb_descriptor_header)) {
+               header = (struct usb_descriptor_header *)buffer;
+
+               if ((header->bLength > size) || (header->bLength < 2)) {
+                       err("invalid descriptor length of %d", header->bLength);
+                       return -EINVAL;
+               }
 
-               /* Skip over the rest of the Class Specific or Vendor */
-               /*  Specific descriptors */
-               begin = buffer;
-               numskipped = 0;
-               while (size >= sizeof(struct usb_descriptor_header)) {
-                       header = (struct usb_descriptor_header *)buffer;
-
-                       if ((header->bLength > size) || (header->bLength < 2)) {
-                               err("invalid descriptor length of %d", 
header->bLength);
-                               return -EINVAL;
-                       }
-
-                       /* If we find another "proper" descriptor then we're done  */
-                       if ((header->bDescriptorType == USB_DT_ENDPOINT) ||
-                           (header->bDescriptorType == USB_DT_INTERFACE) ||
-                           (header->bDescriptorType == USB_DT_CONFIG) ||
-                           (header->bDescriptorType == USB_DT_DEVICE))
-                               break;
+               /* If we find another "proper" descriptor then we're done  */
+               if ((header->bDescriptorType == USB_DT_ENDPOINT) ||
+                   (header->bDescriptorType == USB_DT_INTERFACE) ||
+                   (header->bDescriptorType == USB_DT_CONFIG) ||
+                   (header->bDescriptorType == USB_DT_DEVICE))
+                       break;
 
-                       dbg("skipping descriptor 0x%X", header->bDescriptorType);
-                       numskipped++;
+               dbg("skipping descriptor 0x%X", header->bDescriptorType);
+               numskipped++;
 
-                       buffer += header->bLength;
-                       size -= header->bLength;
-               }
-               if (numskipped) {
-                       dbg("skipped %d class/vendor specific configuration 
descriptors", numskipped);
+               buffer += header->bLength;
+               size -= header->bLength;
+       }
+       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;
-                       if (config->extralen) {
-                               warn("extra config descriptor");
-                       } else {
-                               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;
-                       }
+               /* 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;
+       }
+
+       /* Parse all the interface/altsetting descriptors */
+       for (i = 0; i < nintf; i++) {
                retval = usb_parse_interface(config->interface[i], buffer, size);
                if (retval < 0)
                        return retval;



-------------------------------------------------------
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

Reply via email to