diff options
author | Sebastian Andrzej Siewior <bigeasy@linutronix.de> | 2012-10-22 16:15:10 -0400 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2012-10-31 09:11:47 -0400 |
commit | 1616e99d42a8b427b8dcada347ef0ee0df1a1b7b (patch) | |
tree | 2753f0d18e9458c126460a731b309df9e10bb17c | |
parent | b36c347966160ecfe420cd47a5a1f81ddaffc007 (diff) |
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>
-rw-r--r-- | drivers/usb/gadget/f_acm.c | 27 | ||||
-rw-r--r-- | drivers/usb/gadget/f_ecm.c | 42 | ||||
-rw-r--r-- | drivers/usb/gadget/f_ncm.c | 40 | ||||
-rw-r--r-- | drivers/usb/gadget/f_obex.c | 19 | ||||
-rw-r--r-- | drivers/usb/gadget/f_rndis.c | 27 | ||||
-rw-r--r-- | drivers/usb/gadget/f_subset.c | 23 | ||||
-rw-r--r-- | drivers/usb/gadget/f_uac2.c | 100 | ||||
-rw-r--r-- | drivers/usb/gadget/f_uvc.c | 26 |
8 files changed, 71 insertions, 233 deletions
diff --git a/drivers/usb/gadget/f_acm.c b/drivers/usb/gadget/f_acm.c index 308242b5d6e0..549174466c21 100644 --- a/drivers/usb/gadget/f_acm.c +++ b/drivers/usb/gadget/f_acm.c | |||
@@ -705,6 +705,7 @@ acm_unbind(struct usb_configuration *c, struct usb_function *f) | |||
705 | { | 705 | { |
706 | struct f_acm *acm = func_to_acm(f); | 706 | struct f_acm *acm = func_to_acm(f); |
707 | 707 | ||
708 | acm_string_defs[0].id = 0; | ||
708 | usb_free_all_descriptors(f); | 709 | usb_free_all_descriptors(f); |
709 | gs_free_req(acm->notify, acm->notify_req); | 710 | gs_free_req(acm->notify, acm->notify_req); |
710 | kfree(acm); | 711 | kfree(acm); |
@@ -742,27 +743,15 @@ int acm_bind_config(struct usb_configuration *c, u8 port_num) | |||
742 | */ | 743 | */ |
743 | 744 | ||
744 | /* maybe allocate device-global string IDs, and patch descriptors */ | 745 | /* maybe allocate device-global string IDs, and patch descriptors */ |
745 | if (acm_string_defs[ACM_CTRL_IDX].id == 0) { | 746 | if (acm_string_defs[0].id == 0) { |
746 | status = usb_string_id(c->cdev); | 747 | status = usb_string_ids_tab(c->cdev, acm_string_defs); |
747 | if (status < 0) | 748 | if (status < 0) |
748 | return status; | 749 | return status; |
749 | acm_string_defs[ACM_CTRL_IDX].id = status; | 750 | acm_control_interface_desc.iInterface = |
750 | 751 | acm_string_defs[ACM_CTRL_IDX].id; | |
751 | acm_control_interface_desc.iInterface = status; | 752 | acm_data_interface_desc.iInterface = |
752 | 753 | acm_string_defs[ACM_DATA_IDX].id; | |
753 | status = usb_string_id(c->cdev); | 754 | acm_iad_descriptor.iFunction = acm_string_defs[ACM_IAD_IDX].id; |
754 | if (status < 0) | ||
755 | return status; | ||
756 | acm_string_defs[ACM_DATA_IDX].id = status; | ||
757 | |||
758 | acm_data_interface_desc.iInterface = status; | ||
759 | |||
760 | status = usb_string_id(c->cdev); | ||
761 | if (status < 0) | ||
762 | return status; | ||
763 | acm_string_defs[ACM_IAD_IDX].id = status; | ||
764 | |||
765 | acm_iad_descriptor.iFunction = status; | ||
766 | } | 755 | } |
767 | 756 | ||
768 | /* allocate and initialize one new instance */ | 757 | /* allocate and initialize one new instance */ |
diff --git a/drivers/usb/gadget/f_ecm.c b/drivers/usb/gadget/f_ecm.c index 2d3c5a46de8e..83420a310fb7 100644 --- a/drivers/usb/gadget/f_ecm.c +++ b/drivers/usb/gadget/f_ecm.c | |||
@@ -354,7 +354,7 @@ static struct usb_descriptor_header *ecm_ss_function[] = { | |||
354 | 354 | ||
355 | static struct usb_string ecm_string_defs[] = { | 355 | static struct usb_string ecm_string_defs[] = { |
356 | [0].s = "CDC Ethernet Control Model (ECM)", | 356 | [0].s = "CDC Ethernet Control Model (ECM)", |
357 | [1].s = NULL /* DYNAMIC */, | 357 | [1].s = "", |
358 | [2].s = "CDC Ethernet Data", | 358 | [2].s = "CDC Ethernet Data", |
359 | [3].s = "CDC ECM", | 359 | [3].s = "CDC ECM", |
360 | { } /* end of list */ | 360 | { } /* end of list */ |
@@ -803,12 +803,11 @@ ecm_unbind(struct usb_configuration *c, struct usb_function *f) | |||
803 | 803 | ||
804 | DBG(c->cdev, "ecm unbind\n"); | 804 | DBG(c->cdev, "ecm unbind\n"); |
805 | 805 | ||
806 | ecm_string_defs[0].id = 0; | ||
806 | usb_free_all_descriptors(f); | 807 | usb_free_all_descriptors(f); |
807 | 808 | ||
808 | kfree(ecm->notify_req->buf); | 809 | kfree(ecm->notify_req->buf); |
809 | usb_ep_free_request(ecm->notify, ecm->notify_req); | 810 | usb_ep_free_request(ecm->notify, ecm->notify_req); |
810 | |||
811 | ecm_string_defs[1].s = NULL; | ||
812 | kfree(ecm); | 811 | kfree(ecm); |
813 | } | 812 | } |
814 | 813 | ||
@@ -833,36 +832,15 @@ ecm_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN]) | |||
833 | if (!can_support_ecm(c->cdev->gadget) || !ethaddr) | 832 | if (!can_support_ecm(c->cdev->gadget) || !ethaddr) |
834 | return -EINVAL; | 833 | return -EINVAL; |
835 | 834 | ||
836 | /* maybe allocate device-global string IDs */ | ||
837 | if (ecm_string_defs[0].id == 0) { | 835 | if (ecm_string_defs[0].id == 0) { |
838 | 836 | status = usb_string_ids_tab(c->cdev, ecm_string_defs); | |
839 | /* control interface label */ | 837 | if (status) |
840 | status = usb_string_id(c->cdev); | ||
841 | if (status < 0) | ||
842 | return status; | 838 | return status; |
843 | ecm_string_defs[0].id = status; | ||
844 | ecm_control_intf.iInterface = status; | ||
845 | 839 | ||
846 | /* data interface label */ | 840 | ecm_control_intf.iInterface = ecm_string_defs[0].id; |
847 | status = usb_string_id(c->cdev); | 841 | ecm_data_intf.iInterface = ecm_string_defs[2].id; |
848 | if (status < 0) | 842 | ecm_desc.iMACAddress = ecm_string_defs[1].id; |
849 | return status; | 843 | ecm_iad_descriptor.iFunction = ecm_string_defs[3].id; |
850 | ecm_string_defs[2].id = status; | ||
851 | ecm_data_intf.iInterface = status; | ||
852 | |||
853 | /* MAC address */ | ||
854 | status = usb_string_id(c->cdev); | ||
855 | if (status < 0) | ||
856 | return status; | ||
857 | ecm_string_defs[1].id = status; | ||
858 | ecm_desc.iMACAddress = status; | ||
859 | |||
860 | /* IAD label */ | ||
861 | status = usb_string_id(c->cdev); | ||
862 | if (status < 0) | ||
863 | return status; | ||
864 | ecm_string_defs[3].id = status; | ||
865 | ecm_iad_descriptor.iFunction = status; | ||
866 | } | 844 | } |
867 | 845 | ||
868 | /* allocate and initialize one new instance */ | 846 | /* allocate and initialize one new instance */ |
@@ -887,9 +865,7 @@ ecm_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN]) | |||
887 | ecm->port.func.disable = ecm_disable; | 865 | ecm->port.func.disable = ecm_disable; |
888 | 866 | ||
889 | status = usb_add_function(c, &ecm->port.func); | 867 | status = usb_add_function(c, &ecm->port.func); |
890 | if (status) { | 868 | if (status) |
891 | ecm_string_defs[1].s = NULL; | ||
892 | kfree(ecm); | 869 | kfree(ecm); |
893 | } | ||
894 | return status; | 870 | return status; |
895 | } | 871 | } |
diff --git a/drivers/usb/gadget/f_ncm.c b/drivers/usb/gadget/f_ncm.c index 326d7e6c297c..f1f66e9c76ba 100644 --- a/drivers/usb/gadget/f_ncm.c +++ b/drivers/usb/gadget/f_ncm.c | |||
@@ -321,7 +321,7 @@ static struct usb_descriptor_header *ncm_hs_function[] __initdata = { | |||
321 | 321 | ||
322 | static struct usb_string ncm_string_defs[] = { | 322 | static struct usb_string ncm_string_defs[] = { |
323 | [STRING_CTRL_IDX].s = "CDC Network Control Model (NCM)", | 323 | [STRING_CTRL_IDX].s = "CDC Network Control Model (NCM)", |
324 | [STRING_MAC_IDX].s = NULL /* DYNAMIC */, | 324 | [STRING_MAC_IDX].s = "", |
325 | [STRING_DATA_IDX].s = "CDC Network Data", | 325 | [STRING_DATA_IDX].s = "CDC Network Data", |
326 | [STRING_IAD_IDX].s = "CDC NCM", | 326 | [STRING_IAD_IDX].s = "CDC NCM", |
327 | { } /* end of list */ | 327 | { } /* end of list */ |
@@ -1262,12 +1262,12 @@ ncm_unbind(struct usb_configuration *c, struct usb_function *f) | |||
1262 | 1262 | ||
1263 | DBG(c->cdev, "ncm unbind\n"); | 1263 | DBG(c->cdev, "ncm unbind\n"); |
1264 | 1264 | ||
1265 | ncm_string_defs[0].id = 0; | ||
1265 | usb_free_all_descriptors(f); | 1266 | usb_free_all_descriptors(f); |
1266 | 1267 | ||
1267 | kfree(ncm->notify_req->buf); | 1268 | kfree(ncm->notify_req->buf); |
1268 | usb_ep_free_request(ncm->notify, ncm->notify_req); | 1269 | usb_ep_free_request(ncm->notify, ncm->notify_req); |
1269 | 1270 | ||
1270 | ncm_string_defs[1].s = NULL; | ||
1271 | kfree(ncm); | 1271 | kfree(ncm); |
1272 | } | 1272 | } |
1273 | 1273 | ||
@@ -1291,37 +1291,19 @@ int __init ncm_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN]) | |||
1291 | if (!can_support_ecm(c->cdev->gadget) || !ethaddr) | 1291 | if (!can_support_ecm(c->cdev->gadget) || !ethaddr) |
1292 | return -EINVAL; | 1292 | return -EINVAL; |
1293 | 1293 | ||
1294 | /* maybe allocate device-global string IDs */ | ||
1295 | if (ncm_string_defs[0].id == 0) { | 1294 | if (ncm_string_defs[0].id == 0) { |
1296 | 1295 | status = usb_string_ids_tab(c->cdev, ncm_string_defs); | |
1297 | /* control interface label */ | ||
1298 | status = usb_string_id(c->cdev); | ||
1299 | if (status < 0) | 1296 | if (status < 0) |
1300 | return status; | 1297 | return status; |
1301 | ncm_string_defs[STRING_CTRL_IDX].id = status; | 1298 | ncm_control_intf.iInterface = |
1302 | ncm_control_intf.iInterface = status; | 1299 | ncm_string_defs[STRING_CTRL_IDX].id; |
1303 | 1300 | ||
1304 | /* data interface label */ | 1301 | status = ncm_string_defs[STRING_DATA_IDX].id; |
1305 | status = usb_string_id(c->cdev); | ||
1306 | if (status < 0) | ||
1307 | return status; | ||
1308 | ncm_string_defs[STRING_DATA_IDX].id = status; | ||
1309 | ncm_data_nop_intf.iInterface = status; | 1302 | ncm_data_nop_intf.iInterface = status; |
1310 | ncm_data_intf.iInterface = status; | 1303 | ncm_data_intf.iInterface = status; |
1311 | 1304 | ||
1312 | /* MAC address */ | 1305 | ecm_desc.iMACAddress = ncm_string_defs[STRING_MAC_IDX].id; |
1313 | status = usb_string_id(c->cdev); | 1306 | ncm_iad_desc.iFunction = ncm_string_defs[STRING_IAD_IDX].id; |
1314 | if (status < 0) | ||
1315 | return status; | ||
1316 | ncm_string_defs[STRING_MAC_IDX].id = status; | ||
1317 | ecm_desc.iMACAddress = status; | ||
1318 | |||
1319 | /* IAD */ | ||
1320 | status = usb_string_id(c->cdev); | ||
1321 | if (status < 0) | ||
1322 | return status; | ||
1323 | ncm_string_defs[STRING_IAD_IDX].id = status; | ||
1324 | ncm_iad_desc.iFunction = status; | ||
1325 | } | 1307 | } |
1326 | 1308 | ||
1327 | /* allocate and initialize one new instance */ | 1309 | /* allocate and initialize one new instance */ |
@@ -1331,7 +1313,7 @@ int __init ncm_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN]) | |||
1331 | 1313 | ||
1332 | /* export host's Ethernet address in CDC format */ | 1314 | /* export host's Ethernet address in CDC format */ |
1333 | snprintf(ncm->ethaddr, sizeof ncm->ethaddr, "%pm", ethaddr); | 1315 | snprintf(ncm->ethaddr, sizeof ncm->ethaddr, "%pm", ethaddr); |
1334 | ncm_string_defs[1].s = ncm->ethaddr; | 1316 | ncm_string_defs[STRING_MAC_IDX].s = ncm->ethaddr; |
1335 | 1317 | ||
1336 | spin_lock_init(&ncm->lock); | 1318 | spin_lock_init(&ncm->lock); |
1337 | ncm_reset_values(ncm); | 1319 | ncm_reset_values(ncm); |
@@ -1351,9 +1333,7 @@ int __init ncm_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN]) | |||
1351 | ncm->port.unwrap = ncm_unwrap_ntb; | 1333 | ncm->port.unwrap = ncm_unwrap_ntb; |
1352 | 1334 | ||
1353 | status = usb_add_function(c, &ncm->port.func); | 1335 | status = usb_add_function(c, &ncm->port.func); |
1354 | if (status) { | 1336 | if (status) |
1355 | ncm_string_defs[1].s = NULL; | ||
1356 | kfree(ncm); | 1337 | kfree(ncm); |
1357 | } | ||
1358 | return status; | 1338 | return status; |
1359 | } | 1339 | } |
diff --git a/drivers/usb/gadget/f_obex.c b/drivers/usb/gadget/f_obex.c index d74491ad82cb..d8dd8782768c 100644 --- a/drivers/usb/gadget/f_obex.c +++ b/drivers/usb/gadget/f_obex.c | |||
@@ -379,6 +379,7 @@ fail: | |||
379 | static void | 379 | static void |
380 | obex_unbind(struct usb_configuration *c, struct usb_function *f) | 380 | obex_unbind(struct usb_configuration *c, struct usb_function *f) |
381 | { | 381 | { |
382 | obex_string_defs[OBEX_CTRL_IDX].id = 0; | ||
382 | usb_free_all_descriptors(f); | 383 | usb_free_all_descriptors(f); |
383 | kfree(func_to_obex(f)); | 384 | kfree(func_to_obex(f)); |
384 | } | 385 | } |
@@ -418,22 +419,16 @@ int __init obex_bind_config(struct usb_configuration *c, u8 port_num) | |||
418 | if (!can_support_obex(c)) | 419 | if (!can_support_obex(c)) |
419 | return -EINVAL; | 420 | return -EINVAL; |
420 | 421 | ||
421 | /* maybe allocate device-global string IDs, and patch descriptors */ | ||
422 | if (obex_string_defs[OBEX_CTRL_IDX].id == 0) { | 422 | if (obex_string_defs[OBEX_CTRL_IDX].id == 0) { |
423 | status = usb_string_id(c->cdev); | 423 | status = usb_string_ids_tab(c->cdev, obex_string_defs); |
424 | if (status < 0) | 424 | if (status < 0) |
425 | return status; | 425 | return status; |
426 | obex_string_defs[OBEX_CTRL_IDX].id = status; | 426 | obex_control_intf.iInterface = |
427 | obex_string_defs[OBEX_CTRL_IDX].id; | ||
427 | 428 | ||
428 | obex_control_intf.iInterface = status; | 429 | status = obex_string_defs[OBEX_DATA_IDX].id; |
429 | 430 | obex_data_nop_intf.iInterface = status; | |
430 | status = usb_string_id(c->cdev); | 431 | obex_data_intf.iInterface = status; |
431 | if (status < 0) | ||
432 | return status; | ||
433 | obex_string_defs[OBEX_DATA_IDX].id = status; | ||
434 | |||
435 | obex_data_nop_intf.iInterface = | ||
436 | obex_data_intf.iInterface = status; | ||
437 | } | 432 | } |
438 | 433 | ||
439 | /* allocate and initialize one new instance */ | 434 | /* allocate and initialize one new instance */ |
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) | |||
795 | 795 | ||
796 | rndis_deregister(rndis->config); | 796 | rndis_deregister(rndis->config); |
797 | rndis_exit(); | 797 | rndis_exit(); |
798 | rndis_string_defs[0].id = 0; | ||
799 | 798 | ||
799 | rndis_string_defs[0].id = 0; | ||
800 | usb_free_all_descriptors(f); | 800 | usb_free_all_descriptors(f); |
801 | 801 | ||
802 | kfree(rndis->notify_req->buf); | 802 | kfree(rndis->notify_req->buf); |
@@ -822,34 +822,19 @@ rndis_bind_config_vendor(struct usb_configuration *c, u8 ethaddr[ETH_ALEN], | |||
822 | if (!can_support_rndis(c) || !ethaddr) | 822 | if (!can_support_rndis(c) || !ethaddr) |
823 | return -EINVAL; | 823 | return -EINVAL; |
824 | 824 | ||
825 | /* maybe allocate device-global string IDs */ | ||
826 | if (rndis_string_defs[0].id == 0) { | 825 | if (rndis_string_defs[0].id == 0) { |
827 | |||
828 | /* ... and setup RNDIS itself */ | 826 | /* ... and setup RNDIS itself */ |
829 | status = rndis_init(); | 827 | status = rndis_init(); |
830 | if (status < 0) | 828 | if (status < 0) |
831 | return status; | 829 | return status; |
832 | 830 | ||
833 | /* control interface label */ | 831 | status = usb_string_ids_tab(c->cdev, rndis_string_defs); |
834 | status = usb_string_id(c->cdev); | 832 | if (status) |
835 | if (status < 0) | ||
836 | return status; | 833 | return status; |
837 | rndis_string_defs[0].id = status; | ||
838 | rndis_control_intf.iInterface = status; | ||
839 | 834 | ||
840 | /* data interface label */ | 835 | rndis_control_intf.iInterface = rndis_string_defs[0].id; |
841 | status = usb_string_id(c->cdev); | 836 | rndis_data_intf.iInterface = rndis_string_defs[1].id; |
842 | if (status < 0) | 837 | rndis_iad_descriptor.iFunction = rndis_string_defs[2].id; |
843 | return status; | ||
844 | rndis_string_defs[1].id = status; | ||
845 | rndis_data_intf.iInterface = status; | ||
846 | |||
847 | /* IAD iFunction label */ | ||
848 | status = usb_string_id(c->cdev); | ||
849 | if (status < 0) | ||
850 | return status; | ||
851 | rndis_string_defs[2].id = status; | ||
852 | rndis_iad_descriptor.iFunction = status; | ||
853 | } | 838 | } |
854 | 839 | ||
855 | /* allocate and initialize one new instance */ | 840 | /* allocate and initialize one new instance */ |
diff --git a/drivers/usb/gadget/f_subset.c b/drivers/usb/gadget/f_subset.c index 856dbae586f1..f172bd152fbb 100644 --- a/drivers/usb/gadget/f_subset.c +++ b/drivers/usb/gadget/f_subset.c | |||
@@ -236,7 +236,7 @@ static struct usb_descriptor_header *ss_eth_function[] = { | |||
236 | 236 | ||
237 | static struct usb_string geth_string_defs[] = { | 237 | static struct usb_string geth_string_defs[] = { |
238 | [0].s = "CDC Ethernet Subset/SAFE", | 238 | [0].s = "CDC Ethernet Subset/SAFE", |
239 | [1].s = NULL /* DYNAMIC */, | 239 | [1].s = "", |
240 | { } /* end of list */ | 240 | { } /* end of list */ |
241 | }; | 241 | }; |
242 | 242 | ||
@@ -363,8 +363,8 @@ fail: | |||
363 | static void | 363 | static void |
364 | geth_unbind(struct usb_configuration *c, struct usb_function *f) | 364 | geth_unbind(struct usb_configuration *c, struct usb_function *f) |
365 | { | 365 | { |
366 | geth_string_defs[0].id = 0; | ||
366 | usb_free_all_descriptors(f); | 367 | usb_free_all_descriptors(f); |
367 | geth_string_defs[1].s = NULL; | ||
368 | kfree(func_to_geth(f)); | 368 | kfree(func_to_geth(f)); |
369 | } | 369 | } |
370 | 370 | ||
@@ -390,20 +390,11 @@ int geth_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN]) | |||
390 | 390 | ||
391 | /* maybe allocate device-global string IDs */ | 391 | /* maybe allocate device-global string IDs */ |
392 | if (geth_string_defs[0].id == 0) { | 392 | if (geth_string_defs[0].id == 0) { |
393 | 393 | status = usb_string_ids_tab(c->cdev, geth_string_defs); | |
394 | /* interface label */ | ||
395 | status = usb_string_id(c->cdev); | ||
396 | if (status < 0) | ||
397 | return status; | ||
398 | geth_string_defs[0].id = status; | ||
399 | subset_data_intf.iInterface = status; | ||
400 | |||
401 | /* MAC address */ | ||
402 | status = usb_string_id(c->cdev); | ||
403 | if (status < 0) | 394 | if (status < 0) |
404 | return status; | 395 | return status; |
405 | geth_string_defs[1].id = status; | 396 | subset_data_intf.iInterface = geth_string_defs[0].id; |
406 | ether_desc.iMACAddress = status; | 397 | ether_desc.iMACAddress = geth_string_defs[1].id; |
407 | } | 398 | } |
408 | 399 | ||
409 | /* allocate and initialize one new instance */ | 400 | /* allocate and initialize one new instance */ |
@@ -425,9 +416,7 @@ int geth_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN]) | |||
425 | geth->port.func.disable = geth_disable; | 416 | geth->port.func.disable = geth_disable; |
426 | 417 | ||
427 | status = usb_add_function(c, &geth->port.func); | 418 | status = usb_add_function(c, &geth->port.func); |
428 | if (status) { | 419 | if (status) |
429 | geth_string_defs[1].s = NULL; | ||
430 | kfree(geth); | 420 | kfree(geth); |
431 | } | ||
432 | return status; | 421 | return status; |
433 | } | 422 | } |
diff --git a/drivers/usb/gadget/f_uac2.c b/drivers/usb/gadget/f_uac2.c index 2840f1819065..91396a1683eb 100644 --- a/drivers/usb/gadget/f_uac2.c +++ b/drivers/usb/gadget/f_uac2.c | |||
@@ -1312,7 +1312,7 @@ afunc_setup(struct usb_function *fn, const struct usb_ctrlrequest *cr) | |||
1312 | 1312 | ||
1313 | static int audio_bind_config(struct usb_configuration *cfg) | 1313 | static int audio_bind_config(struct usb_configuration *cfg) |
1314 | { | 1314 | { |
1315 | int id, res; | 1315 | int res; |
1316 | 1316 | ||
1317 | agdev_g = kzalloc(sizeof *agdev_g, GFP_KERNEL); | 1317 | agdev_g = kzalloc(sizeof *agdev_g, GFP_KERNEL); |
1318 | if (agdev_g == NULL) { | 1318 | if (agdev_g == NULL) { |
@@ -1320,89 +1320,21 @@ static int audio_bind_config(struct usb_configuration *cfg) | |||
1320 | return -ENOMEM; | 1320 | return -ENOMEM; |
1321 | } | 1321 | } |
1322 | 1322 | ||
1323 | id = usb_string_id(cfg->cdev); | 1323 | res = usb_string_ids_tab(cfg->cdev, strings_fn); |
1324 | if (id < 0) | 1324 | if (res) |
1325 | return id; | 1325 | return res; |
1326 | 1326 | iad_desc.iFunction = strings_fn[STR_ASSOC].id; | |
1327 | strings_fn[STR_ASSOC].id = id; | 1327 | std_ac_if_desc.iInterface = strings_fn[STR_IF_CTRL].id; |
1328 | iad_desc.iFunction = id, | 1328 | in_clk_src_desc.iClockSource = strings_fn[STR_CLKSRC_IN].id; |
1329 | 1329 | out_clk_src_desc.iClockSource = strings_fn[STR_CLKSRC_OUT].id; | |
1330 | id = usb_string_id(cfg->cdev); | 1330 | usb_out_it_desc.iTerminal = strings_fn[STR_USB_IT].id; |
1331 | if (id < 0) | 1331 | io_in_it_desc.iTerminal = strings_fn[STR_IO_IT].id; |
1332 | return id; | 1332 | usb_in_ot_desc.iTerminal = strings_fn[STR_USB_OT].id; |
1333 | 1333 | io_out_ot_desc.iTerminal = strings_fn[STR_IO_OT].id; | |
1334 | strings_fn[STR_IF_CTRL].id = id; | 1334 | std_as_out_if0_desc.iInterface = strings_fn[STR_AS_OUT_ALT0].id; |
1335 | std_ac_if_desc.iInterface = id, | 1335 | std_as_out_if1_desc.iInterface = strings_fn[STR_AS_OUT_ALT1].id; |
1336 | 1336 | std_as_in_if0_desc.iInterface = strings_fn[STR_AS_IN_ALT0].id; | |
1337 | id = usb_string_id(cfg->cdev); | 1337 | std_as_in_if1_desc.iInterface = strings_fn[STR_AS_IN_ALT1].id; |
1338 | if (id < 0) | ||
1339 | return id; | ||
1340 | |||
1341 | strings_fn[STR_CLKSRC_IN].id = id; | ||
1342 | in_clk_src_desc.iClockSource = id, | ||
1343 | |||
1344 | id = usb_string_id(cfg->cdev); | ||
1345 | if (id < 0) | ||
1346 | return id; | ||
1347 | |||
1348 | strings_fn[STR_CLKSRC_OUT].id = id; | ||
1349 | out_clk_src_desc.iClockSource = id, | ||
1350 | |||
1351 | id = usb_string_id(cfg->cdev); | ||
1352 | if (id < 0) | ||
1353 | return id; | ||
1354 | |||
1355 | strings_fn[STR_USB_IT].id = id; | ||
1356 | usb_out_it_desc.iTerminal = id, | ||
1357 | |||
1358 | id = usb_string_id(cfg->cdev); | ||
1359 | if (id < 0) | ||
1360 | return id; | ||
1361 | |||
1362 | strings_fn[STR_IO_IT].id = id; | ||
1363 | io_in_it_desc.iTerminal = id; | ||
1364 | |||
1365 | id = usb_string_id(cfg->cdev); | ||
1366 | if (id < 0) | ||
1367 | return id; | ||
1368 | |||
1369 | strings_fn[STR_USB_OT].id = id; | ||
1370 | usb_in_ot_desc.iTerminal = id; | ||
1371 | |||
1372 | id = usb_string_id(cfg->cdev); | ||
1373 | if (id < 0) | ||
1374 | return id; | ||
1375 | |||
1376 | strings_fn[STR_IO_OT].id = id; | ||
1377 | io_out_ot_desc.iTerminal = id; | ||
1378 | |||
1379 | id = usb_string_id(cfg->cdev); | ||
1380 | if (id < 0) | ||
1381 | return id; | ||
1382 | |||
1383 | strings_fn[STR_AS_OUT_ALT0].id = id; | ||
1384 | std_as_out_if0_desc.iInterface = id; | ||
1385 | |||
1386 | id = usb_string_id(cfg->cdev); | ||
1387 | if (id < 0) | ||
1388 | return id; | ||
1389 | |||
1390 | strings_fn[STR_AS_OUT_ALT1].id = id; | ||
1391 | std_as_out_if1_desc.iInterface = id; | ||
1392 | |||
1393 | id = usb_string_id(cfg->cdev); | ||
1394 | if (id < 0) | ||
1395 | return id; | ||
1396 | |||
1397 | strings_fn[STR_AS_IN_ALT0].id = id; | ||
1398 | std_as_in_if0_desc.iInterface = id; | ||
1399 | |||
1400 | id = usb_string_id(cfg->cdev); | ||
1401 | if (id < 0) | ||
1402 | return id; | ||
1403 | |||
1404 | strings_fn[STR_AS_IN_ALT1].id = id; | ||
1405 | std_as_in_if1_desc.iInterface = id; | ||
1406 | 1338 | ||
1407 | agdev_g->func.name = "uac2_func"; | 1339 | agdev_g->func.name = "uac2_func"; |
1408 | agdev_g->func.strings = fn_strings; | 1340 | agdev_g->func.strings = fn_strings; |
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) | |||
580 | uvc->control_ep->driver_data = NULL; | 580 | uvc->control_ep->driver_data = NULL; |
581 | uvc->video.ep->driver_data = NULL; | 581 | uvc->video.ep->driver_data = NULL; |
582 | 582 | ||
583 | uvc_en_us_strings[UVC_STRING_ASSOCIATION_IDX].id = 0; | ||
583 | usb_ep_free_request(cdev->gadget->ep0, uvc->control_req); | 584 | usb_ep_free_request(cdev->gadget->ep0, uvc->control_req); |
584 | kfree(uvc->control_buf); | 585 | kfree(uvc->control_buf); |
585 | 586 | ||
@@ -798,25 +799,16 @@ uvc_bind_config(struct usb_configuration *c, | |||
798 | uvc->desc.hs_streaming = hs_streaming; | 799 | uvc->desc.hs_streaming = hs_streaming; |
799 | uvc->desc.ss_streaming = ss_streaming; | 800 | uvc->desc.ss_streaming = ss_streaming; |
800 | 801 | ||
801 | /* maybe allocate device-global string IDs, and patch descriptors */ | 802 | /* Allocate string descriptor numbers. */ |
802 | if (uvc_en_us_strings[UVC_STRING_ASSOCIATION_IDX].id == 0) { | 803 | if (uvc_en_us_strings[UVC_STRING_ASSOCIATION_IDX].id == 0) { |
803 | /* Allocate string descriptor numbers. */ | 804 | ret = usb_string_ids_tab(c->cdev, uvc_en_us_strings); |
804 | ret = usb_string_id(c->cdev); | 805 | if (ret) |
805 | if (ret < 0) | ||
806 | goto error; | 806 | goto error; |
807 | uvc_en_us_strings[UVC_STRING_ASSOCIATION_IDX].id = ret; | 807 | uvc_iad.iFunction = |
808 | uvc_iad.iFunction = ret; | 808 | uvc_en_us_strings[UVC_STRING_ASSOCIATION_IDX].id; |
809 | 809 | uvc_control_intf.iInterface = | |
810 | ret = usb_string_id(c->cdev); | 810 | uvc_en_us_strings[UVC_STRING_CONTROL_IDX].id; |
811 | if (ret < 0) | 811 | ret = uvc_en_us_strings[UVC_STRING_STREAMING_IDX].id; |
812 | goto error; | ||
813 | uvc_en_us_strings[UVC_STRING_CONTROL_IDX].id = ret; | ||
814 | uvc_control_intf.iInterface = ret; | ||
815 | |||
816 | ret = usb_string_id(c->cdev); | ||
817 | if (ret < 0) | ||
818 | goto error; | ||
819 | uvc_en_us_strings[UVC_STRING_STREAMING_IDX].id = ret; | ||
820 | uvc_streaming_intf_alt0.iInterface = ret; | 812 | uvc_streaming_intf_alt0.iInterface = ret; |
821 | uvc_streaming_intf_alt1.iInterface = ret; | 813 | uvc_streaming_intf_alt1.iInterface = ret; |
822 | } | 814 | } |