Commit 43345b84 authored by Alan Stern's avatar Alan Stern Committed by Greg Kroah-Hartman

[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.
parent 580d2f45
...@@ -251,8 +251,10 @@ int usb_parse_configuration(struct usb_host_config *config, char *buffer) ...@@ -251,8 +251,10 @@ int usb_parse_configuration(struct usb_host_config *config, char *buffer)
int nintf; int nintf;
int i, size; int i, size;
struct usb_interface *interface; struct usb_interface *interface;
int retval; int numskipped, len;
char *begin;
struct usb_descriptor_header *header; struct usb_descriptor_header *header;
int retval;
memcpy(&config->desc, buffer, USB_DT_CONFIG_SIZE); memcpy(&config->desc, buffer, USB_DT_CONFIG_SIZE);
le16_to_cpus(&config->desc.wTotalLength); le16_to_cpus(&config->desc.wTotalLength);
...@@ -284,12 +286,7 @@ int usb_parse_configuration(struct usb_host_config *config, char *buffer) ...@@ -284,12 +286,7 @@ int usb_parse_configuration(struct usb_host_config *config, char *buffer)
buffer += config->desc.bLength; buffer += config->desc.bLength;
size -= config->desc.bLength; size -= config->desc.bLength;
for (i = 0; i < nintf; i++) { /* Skip over any Class Specific or Vendor Specific descriptors */
int numskipped, len;
char *begin;
/* Skip over the rest of the Class Specific or Vendor */
/* Specific descriptors */
begin = buffer; begin = buffer;
numskipped = 0; numskipped = 0;
while (size >= sizeof(struct usb_descriptor_header)) { while (size >= sizeof(struct usb_descriptor_header)) {
...@@ -319,9 +316,6 @@ int usb_parse_configuration(struct usb_host_config *config, char *buffer) ...@@ -319,9 +316,6 @@ int usb_parse_configuration(struct usb_host_config *config, char *buffer)
/* Copy any unknown descriptors into a storage area for */ /* Copy any unknown descriptors into a storage area for */
/* drivers to later parse */ /* drivers to later parse */
len = buffer - begin; len = buffer - begin;
if (config->extralen) {
warn("extra config descriptor");
} else {
config->extra = kmalloc(len, GFP_KERNEL); config->extra = kmalloc(len, GFP_KERNEL);
if (!config->extra) { if (!config->extra) {
err("couldn't allocate memory for config extra descriptors"); err("couldn't allocate memory for config extra descriptors");
...@@ -331,8 +325,9 @@ int usb_parse_configuration(struct usb_host_config *config, char *buffer) ...@@ -331,8 +325,9 @@ int usb_parse_configuration(struct usb_host_config *config, char *buffer)
memcpy(config->extra, begin, len); memcpy(config->extra, begin, len);
config->extralen = 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); retval = usb_parse_interface(config->interface[i], buffer, size);
if (retval < 0) if (retval < 0)
return retval; return retval;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment