From: John Michelau Date: Fri, 10 Dec 2010 18:09:53 +0000 (-0600) Subject: USB: gadget: composite: Dynamically set IAD bFirstInterface X-Git-Tag: firefly_0821_release~7613^2~789 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=f71a394a4066f704926d53872a92bc6f8d5b469e;p=firefly-linux-kernel-4.4.55.git USB: gadget: composite: Dynamically set IAD bFirstInterface bFirstInterface should be set equal to bInterfaceNumber of the first interface in a grouping. It's currently being set only when a composite device is bound, and it does not get updated when functions are enabled or disabled. Signed-off-by: Mike Lockwood --- diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index c2684b5adc02..96d89870c2f6 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c @@ -305,6 +305,7 @@ static int config_buf(struct usb_configuration *config, { struct usb_config_descriptor *c = buf; struct usb_interface_descriptor *intf; + struct usb_interface_assoc_descriptor *iad = NULL; void *next = buf + USB_DT_CONFIG_SIZE; int len = USB_BUFSIZ - USB_DT_CONFIG_SIZE; struct usb_function *f; @@ -358,6 +359,20 @@ static int config_buf(struct usb_configuration *config, intf->bInterfaceNumber = interfaceCount++; else intf->bInterfaceNumber = interfaceCount - 1; + if (iad) { + iad->bFirstInterface = + intf->bInterfaceNumber; + iad = NULL; + } + } else if (intf->bDescriptorType == + USB_DT_INTERFACE_ASSOCIATION) { + /* This will be first if it exists. Save + * a pointer to it so we can properly set + * bFirstInterface when we process the first + * interface. + */ + iad = (struct usb_interface_assoc_descriptor *) + dest; } dest += intf->bLength; }