summaryrefslogtreecommitdiffstats
path: root/drivers/usb/gadget/f_uvc.c
diff options
context:
space:
mode:
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>2012-10-22 22:15:10 +0200
committerFelipe Balbi <balbi@ti.com>2012-10-31 15:11:47 +0200
commit1616e99d42a8b427b8dcada347ef0ee0df1a1b7b (patch)
tree2753f0d18e9458c126460a731b309df9e10bb17c /drivers/usb/gadget/f_uvc.c
parentb36c347966160ecfe420cd47a5a1f81ddaffc007 (diff)
downloadblackbird-op-linux-1616e99d42a8b427b8dcada347ef0ee0df1a1b7b.tar.gz
blackbird-op-linux-1616e99d42a8b427b8dcada347ef0ee0df1a1b7b.zip
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_uvc.c')
-rw-r--r--drivers/usb/gadget/f_uvc.c26
1 files changed, 9 insertions, 17 deletions
diff --git a/drivers/usb/gadget/f_uvc.c b/drivers/usb/gadget/f_uvc.c
index 28ff2546a5b3..5b629876941b 100644
--- a/drivers/usb/gadget/f_uvc.c
+++ b/drivers/usb/gadget/f_uvc.c
@@ -580,6 +580,7 @@ uvc_function_unbind(struct usb_configuration *c, struct usb_function *f)
uvc->control_ep->driver_data = NULL;
uvc->video.ep->driver_data = NULL;
+ uvc_en_us_strings[UVC_STRING_ASSOCIATION_IDX].id = 0;
usb_ep_free_request(cdev->gadget->ep0, uvc->control_req);
kfree(uvc->control_buf);
@@ -798,25 +799,16 @@ uvc_bind_config(struct usb_configuration *c,
uvc->desc.hs_streaming = hs_streaming;
uvc->desc.ss_streaming = ss_streaming;
- /* maybe allocate device-global string IDs, and patch descriptors */
+ /* Allocate string descriptor numbers. */
if (uvc_en_us_strings[UVC_STRING_ASSOCIATION_IDX].id == 0) {
- /* Allocate string descriptor numbers. */
- ret = usb_string_id(c->cdev);
- if (ret < 0)
+ ret = usb_string_ids_tab(c->cdev, uvc_en_us_strings);
+ if (ret)
goto error;
- uvc_en_us_strings[UVC_STRING_ASSOCIATION_IDX].id = ret;
- uvc_iad.iFunction = ret;
-
- ret = usb_string_id(c->cdev);
- if (ret < 0)
- goto error;
- uvc_en_us_strings[UVC_STRING_CONTROL_IDX].id = ret;
- uvc_control_intf.iInterface = ret;
-
- ret = usb_string_id(c->cdev);
- if (ret < 0)
- goto error;
- uvc_en_us_strings[UVC_STRING_STREAMING_IDX].id = ret;
+ uvc_iad.iFunction =
+ uvc_en_us_strings[UVC_STRING_ASSOCIATION_IDX].id;
+ uvc_control_intf.iInterface =
+ uvc_en_us_strings[UVC_STRING_CONTROL_IDX].id;
+ ret = uvc_en_us_strings[UVC_STRING_STREAMING_IDX].id;
uvc_streaming_intf_alt0.iInterface = ret;
uvc_streaming_intf_alt1.iInterface = ret;
}
OpenPOWER on IntegriCloud