diff options
author | Sebastian Andrzej Siewior <bigeasy@linutronix.de> | 2012-10-23 00:15:10 +0400 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2012-10-31 17:11:47 +0400 |
commit | 1616e99d42a8b427b8dcada347ef0ee0df1a1b7b (patch) | |
tree | 2753f0d18e9458c126460a731b309df9e10bb17c /drivers/usb/gadget/f_rndis.c | |
parent | b36c347966160ecfe420cd47a5a1f81ddaffc007 (diff) | |
download | linux-1616e99d42a8b427b8dcada347ef0ee0df1a1b7b.tar.xz |
usb: gadget: let f_* use usb_string_ids_tab() where it makes sense
Instead of calling usb_string_id() multiple times I replace it with one
usb_string_ids_tab(). The NULL pointer in struct usb_string with "" and
are not overwritten in fail or unbind case.
The conditional assignment remains because some gadgets recycle the string
ID because the same descriptor (and string ID) is used if we have more
than one config descriptor.
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/gadget/f_rndis.c')
-rw-r--r-- | drivers/usb/gadget/f_rndis.c | 27 |
1 files changed, 6 insertions, 21 deletions
diff --git a/drivers/usb/gadget/f_rndis.c b/drivers/usb/gadget/f_rndis.c index e7c25105bd8e..71beeb833558 100644 --- a/drivers/usb/gadget/f_rndis.c +++ b/drivers/usb/gadget/f_rndis.c @@ -795,8 +795,8 @@ rndis_unbind(struct usb_configuration *c, struct usb_function *f) rndis_deregister(rndis->config); rndis_exit(); - rndis_string_defs[0].id = 0; + rndis_string_defs[0].id = 0; usb_free_all_descriptors(f); kfree(rndis->notify_req->buf); @@ -822,34 +822,19 @@ rndis_bind_config_vendor(struct usb_configuration *c, u8 ethaddr[ETH_ALEN], if (!can_support_rndis(c) || !ethaddr) return -EINVAL; - /* maybe allocate device-global string IDs */ if (rndis_string_defs[0].id == 0) { - /* ... and setup RNDIS itself */ status = rndis_init(); if (status < 0) return status; - /* control interface label */ - status = usb_string_id(c->cdev); - if (status < 0) + status = usb_string_ids_tab(c->cdev, rndis_string_defs); + if (status) return status; - rndis_string_defs[0].id = status; - rndis_control_intf.iInterface = status; - /* data interface label */ - status = usb_string_id(c->cdev); - if (status < 0) - return status; - rndis_string_defs[1].id = status; - rndis_data_intf.iInterface = status; - - /* IAD iFunction label */ - status = usb_string_id(c->cdev); - if (status < 0) - return status; - rndis_string_defs[2].id = status; - rndis_iad_descriptor.iFunction = status; + rndis_control_intf.iInterface = rndis_string_defs[0].id; + rndis_data_intf.iInterface = rndis_string_defs[1].id; + rndis_iad_descriptor.iFunction = rndis_string_defs[2].id; } /* allocate and initialize one new instance */ |