Alan Stern wrote:

>On Mon, 13 Mar 2006, Craig W. Nadler wrote:
>
>  
>
>>    I've put together a patch demonstrating how Interface Association
>>Descriptors could be supported with a minimal amount of changes the
>>current USB stack. When a USB device is enumerated the descriptors are
>>parsed by the code in drivers/usb/core/config.c. A list of IADs for a
>>given configuration would be stored in the usb_host_config struct for
>>that configuration. If an interface is referenced by an IAD then a
>>pointer to the IAD will be stored in the usb_host_interface struct for
>>that interface.
>>    
>>
>
>Some minor gammatical comments on the printer gadget patch:  "it's" is a
>contraction of "it is", whereas "its" is a possessive pronoun.  Also,
>"howto" should be two words ("how to") unless you're using it as a noun.
>
>--- a/drivers/usb/core/config.c        2006-01-02 22:21:10.000000000 -0500
>+++ b/drivers/usb/core/config.c        2006-03-05 01:19:33.000000000 -0500
>@@ -310,6 +312,22 @@
>                               ++n;
>                       }
> 
>+              } else if (header->bDescriptorType ==
>+                              USB_DT_INTERFACE_ASSOCIATION) {
>+                      if (iad_num == USB_MAXIADS) {
>+                              dev_err(ddev, "found more Interface "
>+                                             "Association Descriptors "
>+                                             "than allocated for\n");
>+                      } else {
>+                              config->intf_assoc[iad_num] = kzalloc(
>+                                              header->bLength, GFP_KERNEL);
>+                              if (!config->intf_assoc[iad_num])
>+                                      return -ENOMEM;
>+                              memcpy (config->intf_assoc[iad_num], header,
>+                                              header->bLength);
>+                              iad_num++;
>+                      }
>
>Unless you think that interface association descriptors are critical for
>using the device correctly, you should accept allocation failures and
>continue instead of aborting.
>
>Furthermore, there's no real point in copying the descriptor to this
>newly-allocated memory area.  The original data bytes will remain
>available in the raw_descriptors array, so it would be enough to have
>config->intf_assoc[iad_num] be nothing more than a pointer into
>raw_descriptors.
>
>@@ -419,6 +437,10 @@
>               struct usb_host_config *cf = &dev->config[c];
> 
>               kfree(cf->string);
>+              for (i = 0; i < USB_MAXIADS; i++) {
>+                      if (cf->intf_assoc[i])
>+                              kfree(cf->intf_assoc[i]);
>+              }
>
>The test isn't needed.  Of course, if you change intf_assoc[i] to be a 
>pointer into raw_descriptors then the kfree and the loop aren't needed 
>either.
>
>Alan Stern
>
>
>
>  
>
Thank you for pointing that out, I have a new patch that I'm about to
send out.

Best Regards,

Craig Nadler


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to