diff options
author | Li Jun <jun.li@freescale.com> | 2015-06-17 16:06:33 +0800 |
---|---|---|
committer | Li Jun <jun.li@freescale.com> | 2015-07-07 11:18:30 +0800 |
commit | c700bb5e7afa4db87a80998aa73e1f43bfea63aa (patch) | |
tree | 5e927f3b96fb282998bec58380f5500e1978b95c | |
parent | b81a1215ac75f52a95554668617461c8c3318050 (diff) |
MLK-11123-5 usb: gadget: composite: USB_DT_OTG request handling update
According to gadget otg revision to setup buffer, copy usb_otg_descriptor
from config's descriptor if host requests USB_DT_OTG.
Signed-off-by: Li Jun <jun.li@freescale.com>
-rw-r--r-- | drivers/usb/gadget/composite.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index 9cf244f42488..1fc6997a5ff1 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c @@ -19,6 +19,7 @@ #include <linux/utsname.h> #include <linux/usb/composite.h> +#include <linux/usb/otg.h> #include <asm/unaligned.h> /* @@ -1289,13 +1290,26 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl) case USB_DT_OTG: if (gadget_is_otg(gadget)) { struct usb_configuration *config; + int otg_desc_len = 0; - config = list_first_entry(&cdev->configs, + if (cdev->config) + config = cdev->config; + else + config = list_first_entry( + &cdev->configs, struct usb_configuration, list); if (!config) goto done; - value = sizeof(struct usb_otg_descriptor); + if (gadget->otg_caps && + (gadget->otg_caps->otg_rev >= 0x0200)) + otg_desc_len += sizeof( + struct usb_otg20_descriptor); + else + otg_desc_len += sizeof( + struct usb_otg_descriptor); + + value = min_t(int, w_length, otg_desc_len); memcpy(req->buf, config->descriptors[0], value); } break; |