Commit 75c9310a authored by Li Jun's avatar Li Jun Committed by Felipe Balbi

usb: gadget: g_ffs: 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 ab6796ae
...@@ -88,21 +88,7 @@ MODULE_PARM_DESC(bDeviceProtocol, "USB Device protocol"); ...@@ -88,21 +88,7 @@ MODULE_PARM_DESC(bDeviceProtocol, "USB Device protocol");
module_param_array_named(functions, func_names, charp, &func_num, 0); module_param_array_named(functions, func_names, charp, &func_num, 0);
MODULE_PARM_DESC(functions, "USB Functions list"); MODULE_PARM_DESC(functions, "USB Functions list");
static const struct usb_descriptor_header *gfs_otg_desc[] = { static const struct usb_descriptor_header *gfs_otg_desc[2];
(const struct usb_descriptor_header *)
&(const 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
};
/* String IDs are assigned dynamically */ /* String IDs are assigned dynamically */
static struct usb_string gfs_strings[] = { static struct usb_string gfs_strings[] = {
...@@ -412,6 +398,17 @@ static int gfs_bind(struct usb_composite_dev *cdev) ...@@ -412,6 +398,17 @@ static int gfs_bind(struct usb_composite_dev *cdev)
goto error_rndis; goto error_rndis;
gfs_dev_desc.iProduct = gfs_strings[USB_GADGET_PRODUCT_IDX].id; gfs_dev_desc.iProduct = gfs_strings[USB_GADGET_PRODUCT_IDX].id;
if (gadget_is_otg(cdev->gadget) && !gfs_otg_desc[0]) {
struct usb_descriptor_header *usb_desc;
usb_desc = usb_otg_descriptor_alloc(cdev->gadget);
if (!usb_desc)
goto error_rndis;
usb_otg_descriptor_init(cdev->gadget, usb_desc);
gfs_otg_desc[0] = usb_desc;
gfs_otg_desc[1] = NULL;
}
for (i = 0; i < ARRAY_SIZE(gfs_configurations); ++i) { for (i = 0; i < ARRAY_SIZE(gfs_configurations); ++i) {
struct gfs_configuration *c = gfs_configurations + i; struct gfs_configuration *c = gfs_configurations + i;
int sid = USB_GADGET_FIRST_AVAIL_IDX + i; int sid = USB_GADGET_FIRST_AVAIL_IDX + i;
...@@ -432,6 +429,8 @@ static int gfs_bind(struct usb_composite_dev *cdev) ...@@ -432,6 +429,8 @@ static int gfs_bind(struct usb_composite_dev *cdev)
/* TODO */ /* TODO */
error_unbind: error_unbind:
kfree(gfs_otg_desc[0]);
gfs_otg_desc[0] = NULL;
error_rndis: error_rndis:
#ifdef CONFIG_USB_FUNCTIONFS_RNDIS #ifdef CONFIG_USB_FUNCTIONFS_RNDIS
usb_put_function_instance(fi_rndis); usb_put_function_instance(fi_rndis);
...@@ -473,6 +472,9 @@ static int gfs_unbind(struct usb_composite_dev *cdev) ...@@ -473,6 +472,9 @@ static int gfs_unbind(struct usb_composite_dev *cdev)
for (i = 0; i < N_CONF * func_num; ++i) for (i = 0; i < N_CONF * func_num; ++i)
usb_put_function(*(f_ffs[0] + i)); usb_put_function(*(f_ffs[0] + i));
kfree(gfs_otg_desc[0]);
gfs_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