Commit 21ddc2a8 authored by Li Jun's avatar Li Jun Committed by Felipe Balbi

usb: gadget: multi: allocate and init otg descriptor by otg capabilities

Allocate and initialize usb otg descriptor according to gadget otg
capabilities, add it for each usb configurations. If otg capability
is not defined, keep its original otg descriptor unchanged.
Signed-off-by: default avatarLi Jun <jun.li@freescale.com>
Reviewed-by: default avatarRoger Quadros <rogerq@ti.com>
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
parent d8678897
...@@ -78,21 +78,7 @@ static struct usb_device_descriptor device_desc = { ...@@ -78,21 +78,7 @@ static struct usb_device_descriptor device_desc = {
.idProduct = cpu_to_le16(MULTI_PRODUCT_NUM), .idProduct = cpu_to_le16(MULTI_PRODUCT_NUM),
}; };
static const struct usb_descriptor_header *otg_desc[2];
static const struct usb_descriptor_header *otg_desc[] = {
(struct usb_descriptor_header *) &(struct usb_otg_descriptor){
.bLength = sizeof(struct usb_otg_descriptor),
.bDescriptorType = USB_DT_OTG,
/*
* REVISIT SRP-only hardware is possible, although
* it would not be called "OTG" ...
*/
.bmAttributes = USB_OTG_SRP | USB_OTG_HNP,
},
NULL,
};
enum { enum {
MULTI_STRING_RNDIS_CONFIG_IDX = USB_GADGET_FIRST_AVAIL_IDX, MULTI_STRING_RNDIS_CONFIG_IDX = USB_GADGET_FIRST_AVAIL_IDX,
...@@ -429,14 +415,25 @@ static int __ref multi_bind(struct usb_composite_dev *cdev) ...@@ -429,14 +415,25 @@ static int __ref multi_bind(struct usb_composite_dev *cdev)
goto fail_string_ids; goto fail_string_ids;
device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id; device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id;
if (gadget_is_otg(gadget) && !otg_desc[0]) {
struct usb_descriptor_header *usb_desc;
usb_desc = usb_otg_descriptor_alloc(gadget);
if (!usb_desc)
goto fail_string_ids;
usb_otg_descriptor_init(gadget, usb_desc);
otg_desc[0] = usb_desc;
otg_desc[1] = NULL;
}
/* register configurations */ /* register configurations */
status = rndis_config_register(cdev); status = rndis_config_register(cdev);
if (unlikely(status < 0)) if (unlikely(status < 0))
goto fail_string_ids; goto fail_otg_desc;
status = cdc_config_register(cdev); status = cdc_config_register(cdev);
if (unlikely(status < 0)) if (unlikely(status < 0))
goto fail_string_ids; goto fail_otg_desc;
usb_composite_overwrite_options(cdev, &coverwrite); usb_composite_overwrite_options(cdev, &coverwrite);
/* we're done */ /* we're done */
...@@ -445,6 +442,9 @@ static int __ref multi_bind(struct usb_composite_dev *cdev) ...@@ -445,6 +442,9 @@ static int __ref multi_bind(struct usb_composite_dev *cdev)
/* error recovery */ /* error recovery */
fail_otg_desc:
kfree(otg_desc[0]);
otg_desc[0] = NULL;
fail_string_ids: fail_string_ids:
fsg_common_remove_luns(fsg_opts->common); fsg_common_remove_luns(fsg_opts->common);
fail_set_cdev: fail_set_cdev:
...@@ -490,6 +490,9 @@ static int multi_unbind(struct usb_composite_dev *cdev) ...@@ -490,6 +490,9 @@ static int multi_unbind(struct usb_composite_dev *cdev)
usb_put_function(f_ecm); usb_put_function(f_ecm);
usb_put_function_instance(fi_ecm); usb_put_function_instance(fi_ecm);
#endif #endif
kfree(otg_desc[0]);
otg_desc[0] = NULL;
return 0; return 0;
} }
......
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