Commit 27a46633 authored by Sebastian Andrzej Siewior's avatar Sebastian Andrzej Siewior Committed by Felipe Balbi

usb: gadget: f_acm: use usb_gstrings_attach()

Use usb_gstrings_attach() to assign strings in f_acm to assign strings
ids.
Signed-off-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
parent 9bb2859f
...@@ -943,6 +943,12 @@ static int get_string(struct usb_composite_dev *cdev, ...@@ -943,6 +943,12 @@ static int get_string(struct usb_composite_dev *cdev,
collect_langs(sp, s->wData); collect_langs(sp, s->wData);
} }
} }
list_for_each_entry(uc, &cdev->gstrings, list) {
struct usb_gadget_strings **sp;
sp = get_containers_gs(uc);
collect_langs(sp, s->wData);
}
for (len = 0; len <= 126 && s->wData[len]; len++) for (len = 0; len <= 126 && s->wData[len]; len++)
continue; continue;
...@@ -1506,7 +1512,6 @@ static DEVICE_ATTR(suspended, 0444, composite_show_suspended, NULL); ...@@ -1506,7 +1512,6 @@ static DEVICE_ATTR(suspended, 0444, composite_show_suspended, NULL);
static void __composite_unbind(struct usb_gadget *gadget, bool unbind_driver) static void __composite_unbind(struct usb_gadget *gadget, bool unbind_driver)
{ {
struct usb_composite_dev *cdev = get_gadget_data(gadget); struct usb_composite_dev *cdev = get_gadget_data(gadget);
struct usb_gadget_string_container *uc, *tmp;
/* composite_disconnect() must already have been called /* composite_disconnect() must already have been called
* by the underlying peripheral controller driver! * by the underlying peripheral controller driver!
...@@ -1521,10 +1526,6 @@ static void __composite_unbind(struct usb_gadget *gadget, bool unbind_driver) ...@@ -1521,10 +1526,6 @@ static void __composite_unbind(struct usb_gadget *gadget, bool unbind_driver)
struct usb_configuration, list); struct usb_configuration, list);
remove_config(cdev, c); remove_config(cdev, c);
} }
list_for_each_entry_safe(uc, tmp, &cdev->gstrings, list) {
list_del(&uc->list);
kfree(uc);
}
if (cdev->driver->unbind && unbind_driver) if (cdev->driver->unbind && unbind_driver)
cdev->driver->unbind(cdev); cdev->driver->unbind(cdev);
...@@ -1626,6 +1627,12 @@ int composite_dev_prepare(struct usb_composite_driver *composite, ...@@ -1626,6 +1627,12 @@ int composite_dev_prepare(struct usb_composite_driver *composite,
void composite_dev_cleanup(struct usb_composite_dev *cdev) void composite_dev_cleanup(struct usb_composite_dev *cdev)
{ {
struct usb_gadget_string_container *uc, *tmp;
list_for_each_entry_safe(uc, tmp, &cdev->gstrings, list) {
list_del(&uc->list);
kfree(uc);
}
if (cdev->req) { if (cdev->req) {
kfree(cdev->req->buf); kfree(cdev->req->buf);
usb_ep_free_request(cdev->gadget->ep0, cdev->req); usb_ep_free_request(cdev->gadget->ep0, cdev->req);
......
...@@ -285,7 +285,6 @@ static struct usb_string acm_string_defs[] = { ...@@ -285,7 +285,6 @@ static struct usb_string acm_string_defs[] = {
[ACM_CTRL_IDX].s = "CDC Abstract Control Model (ACM)", [ACM_CTRL_IDX].s = "CDC Abstract Control Model (ACM)",
[ACM_DATA_IDX].s = "CDC ACM Data", [ACM_DATA_IDX].s = "CDC ACM Data",
[ACM_IAD_IDX ].s = "CDC Serial", [ACM_IAD_IDX ].s = "CDC Serial",
{ /* ZEROES END LIST */ },
}; };
static struct usb_gadget_strings acm_string_table = { static struct usb_gadget_strings acm_string_table = {
...@@ -607,6 +606,7 @@ acm_bind(struct usb_configuration *c, struct usb_function *f) ...@@ -607,6 +606,7 @@ acm_bind(struct usb_configuration *c, struct usb_function *f)
{ {
struct usb_composite_dev *cdev = c->cdev; struct usb_composite_dev *cdev = c->cdev;
struct f_acm *acm = func_to_acm(f); struct f_acm *acm = func_to_acm(f);
struct usb_string *us;
int status; int status;
struct usb_ep *ep; struct usb_ep *ep;
...@@ -615,16 +615,13 @@ acm_bind(struct usb_configuration *c, struct usb_function *f) ...@@ -615,16 +615,13 @@ acm_bind(struct usb_configuration *c, struct usb_function *f)
*/ */
/* maybe allocate device-global string IDs, and patch descriptors */ /* maybe allocate device-global string IDs, and patch descriptors */
if (acm_string_defs[0].id == 0) { us = usb_gstrings_attach(cdev, acm_strings,
status = usb_string_ids_tab(c->cdev, acm_string_defs); ARRAY_SIZE(acm_string_defs));
if (status < 0) if (IS_ERR(us))
return status; return PTR_ERR(us);
acm_control_interface_desc.iInterface = acm_control_interface_desc.iInterface = us[ACM_CTRL_IDX].id;
acm_string_defs[ACM_CTRL_IDX].id; acm_data_interface_desc.iInterface = us[ACM_DATA_IDX].id;
acm_data_interface_desc.iInterface = acm_iad_descriptor.iFunction = us[ACM_IAD_IDX].id;
acm_string_defs[ACM_DATA_IDX].id;
acm_iad_descriptor.iFunction = acm_string_defs[ACM_IAD_IDX].id;
}
/* allocate instance-specific interface IDs, and patch descriptors */ /* allocate instance-specific interface IDs, and patch descriptors */
status = usb_interface_id(c, f); status = usb_interface_id(c, f);
...@@ -733,7 +730,6 @@ static struct f_acm *acm_alloc_basic_func(void) ...@@ -733,7 +730,6 @@ static struct f_acm *acm_alloc_basic_func(void)
acm->port.send_break = acm_send_break; acm->port.send_break = acm_send_break;
acm->port.func.name = "acm"; acm->port.func.name = "acm";
acm->port.func.strings = acm_strings;
/* descriptors are per-instance copies */ /* descriptors are per-instance copies */
acm->port.func.bind = acm_bind; acm->port.func.bind = acm_bind;
acm->port.func.set_alt = acm_set_alt; acm->port.func.set_alt = acm_set_alt;
...@@ -749,7 +745,6 @@ acm_old_unbind(struct usb_configuration *c, struct usb_function *f) ...@@ -749,7 +745,6 @@ acm_old_unbind(struct usb_configuration *c, struct usb_function *f)
{ {
struct f_acm *acm = func_to_acm(f); struct f_acm *acm = func_to_acm(f);
acm_string_defs[0].id = 0;
usb_free_all_descriptors(f); usb_free_all_descriptors(f);
if (acm->notify_req) if (acm->notify_req)
gs_free_req(acm->notify, acm->notify_req); gs_free_req(acm->notify, acm->notify_req);
......
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