Commit 1616e99d42a8b427b8dcada347ef0ee0df1a1b7b
Committed by
Felipe Balbi
1 parent
b36c347966
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
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>
Showing 8 changed files with 71 additions and 233 deletions Side-by-side Diff
drivers/usb/gadget/f_acm.c
... | ... | @@ -705,6 +705,7 @@ |
705 | 705 | { |
706 | 706 | struct f_acm *acm = func_to_acm(f); |
707 | 707 | |
708 | + acm_string_defs[0].id = 0; | |
708 | 709 | usb_free_all_descriptors(f); |
709 | 710 | gs_free_req(acm->notify, acm->notify_req); |
710 | 711 | kfree(acm); |
711 | 712 | |
... | ... | @@ -742,27 +743,15 @@ |
742 | 743 | */ |
743 | 744 | |
744 | 745 | /* maybe allocate device-global string IDs, and patch descriptors */ |
745 | - if (acm_string_defs[ACM_CTRL_IDX].id == 0) { | |
746 | - status = usb_string_id(c->cdev); | |
746 | + if (acm_string_defs[0].id == 0) { | |
747 | + status = usb_string_ids_tab(c->cdev, acm_string_defs); | |
747 | 748 | if (status < 0) |
748 | 749 | return status; |
749 | - acm_string_defs[ACM_CTRL_IDX].id = status; | |
750 | - | |
751 | - acm_control_interface_desc.iInterface = status; | |
752 | - | |
753 | - status = usb_string_id(c->cdev); | |
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; | |
750 | + acm_control_interface_desc.iInterface = | |
751 | + acm_string_defs[ACM_CTRL_IDX].id; | |
752 | + acm_data_interface_desc.iInterface = | |
753 | + acm_string_defs[ACM_DATA_IDX].id; | |
754 | + acm_iad_descriptor.iFunction = acm_string_defs[ACM_IAD_IDX].id; | |
766 | 755 | } |
767 | 756 | |
768 | 757 | /* allocate and initialize one new instance */ |
drivers/usb/gadget/f_ecm.c
... | ... | @@ -354,7 +354,7 @@ |
354 | 354 | |
355 | 355 | static struct usb_string ecm_string_defs[] = { |
356 | 356 | [0].s = "CDC Ethernet Control Model (ECM)", |
357 | - [1].s = NULL /* DYNAMIC */, | |
357 | + [1].s = "", | |
358 | 358 | [2].s = "CDC Ethernet Data", |
359 | 359 | [3].s = "CDC ECM", |
360 | 360 | { } /* end of list */ |
361 | 361 | |
... | ... | @@ -803,12 +803,11 @@ |
803 | 803 | |
804 | 804 | DBG(c->cdev, "ecm unbind\n"); |
805 | 805 | |
806 | + ecm_string_defs[0].id = 0; | |
806 | 807 | usb_free_all_descriptors(f); |
807 | 808 | |
808 | 809 | kfree(ecm->notify_req->buf); |
809 | 810 | usb_ep_free_request(ecm->notify, ecm->notify_req); |
810 | - | |
811 | - ecm_string_defs[1].s = NULL; | |
812 | 811 | kfree(ecm); |
813 | 812 | } |
814 | 813 | |
815 | 814 | |
816 | 815 | |
817 | 816 | |
... | ... | @@ -833,36 +832,15 @@ |
833 | 832 | if (!can_support_ecm(c->cdev->gadget) || !ethaddr) |
834 | 833 | return -EINVAL; |
835 | 834 | |
836 | - /* maybe allocate device-global string IDs */ | |
837 | 835 | if (ecm_string_defs[0].id == 0) { |
838 | - | |
839 | - /* control interface label */ | |
840 | - status = usb_string_id(c->cdev); | |
841 | - if (status < 0) | |
836 | + status = usb_string_ids_tab(c->cdev, ecm_string_defs); | |
837 | + if (status) | |
842 | 838 | return status; |
843 | - ecm_string_defs[0].id = status; | |
844 | - ecm_control_intf.iInterface = status; | |
845 | 839 | |
846 | - /* data interface label */ | |
847 | - status = usb_string_id(c->cdev); | |
848 | - if (status < 0) | |
849 | - return status; | |
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; | |
840 | + ecm_control_intf.iInterface = ecm_string_defs[0].id; | |
841 | + ecm_data_intf.iInterface = ecm_string_defs[2].id; | |
842 | + ecm_desc.iMACAddress = ecm_string_defs[1].id; | |
843 | + ecm_iad_descriptor.iFunction = ecm_string_defs[3].id; | |
866 | 844 | } |
867 | 845 | |
868 | 846 | /* allocate and initialize one new instance */ |
869 | 847 | |
... | ... | @@ -887,10 +865,8 @@ |
887 | 865 | ecm->port.func.disable = ecm_disable; |
888 | 866 | |
889 | 867 | status = usb_add_function(c, &ecm->port.func); |
890 | - if (status) { | |
891 | - ecm_string_defs[1].s = NULL; | |
868 | + if (status) | |
892 | 869 | kfree(ecm); |
893 | - } | |
894 | 870 | return status; |
895 | 871 | } |
drivers/usb/gadget/f_ncm.c
... | ... | @@ -321,7 +321,7 @@ |
321 | 321 | |
322 | 322 | static struct usb_string ncm_string_defs[] = { |
323 | 323 | [STRING_CTRL_IDX].s = "CDC Network Control Model (NCM)", |
324 | - [STRING_MAC_IDX].s = NULL /* DYNAMIC */, | |
324 | + [STRING_MAC_IDX].s = "", | |
325 | 325 | [STRING_DATA_IDX].s = "CDC Network Data", |
326 | 326 | [STRING_IAD_IDX].s = "CDC NCM", |
327 | 327 | { } /* end of list */ |
328 | 328 | |
... | ... | @@ -1262,12 +1262,12 @@ |
1262 | 1262 | |
1263 | 1263 | DBG(c->cdev, "ncm unbind\n"); |
1264 | 1264 | |
1265 | + ncm_string_defs[0].id = 0; | |
1265 | 1266 | usb_free_all_descriptors(f); |
1266 | 1267 | |
1267 | 1268 | kfree(ncm->notify_req->buf); |
1268 | 1269 | usb_ep_free_request(ncm->notify, ncm->notify_req); |
1269 | 1270 | |
1270 | - ncm_string_defs[1].s = NULL; | |
1271 | 1271 | kfree(ncm); |
1272 | 1272 | } |
1273 | 1273 | |
1274 | 1274 | |
1275 | 1275 | |
1276 | 1276 | |
1277 | 1277 | |
... | ... | @@ -1291,37 +1291,19 @@ |
1291 | 1291 | if (!can_support_ecm(c->cdev->gadget) || !ethaddr) |
1292 | 1292 | return -EINVAL; |
1293 | 1293 | |
1294 | - /* maybe allocate device-global string IDs */ | |
1295 | 1294 | if (ncm_string_defs[0].id == 0) { |
1296 | - | |
1297 | - /* control interface label */ | |
1298 | - status = usb_string_id(c->cdev); | |
1295 | + status = usb_string_ids_tab(c->cdev, ncm_string_defs); | |
1299 | 1296 | if (status < 0) |
1300 | 1297 | return status; |
1301 | - ncm_string_defs[STRING_CTRL_IDX].id = status; | |
1302 | - ncm_control_intf.iInterface = status; | |
1298 | + ncm_control_intf.iInterface = | |
1299 | + ncm_string_defs[STRING_CTRL_IDX].id; | |
1303 | 1300 | |
1304 | - /* data interface label */ | |
1305 | - status = usb_string_id(c->cdev); | |
1306 | - if (status < 0) | |
1307 | - return status; | |
1308 | - ncm_string_defs[STRING_DATA_IDX].id = status; | |
1301 | + status = ncm_string_defs[STRING_DATA_IDX].id; | |
1309 | 1302 | ncm_data_nop_intf.iInterface = status; |
1310 | 1303 | ncm_data_intf.iInterface = status; |
1311 | 1304 | |
1312 | - /* MAC address */ | |
1313 | - status = usb_string_id(c->cdev); | |
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; | |
1305 | + ecm_desc.iMACAddress = ncm_string_defs[STRING_MAC_IDX].id; | |
1306 | + ncm_iad_desc.iFunction = ncm_string_defs[STRING_IAD_IDX].id; | |
1325 | 1307 | } |
1326 | 1308 | |
1327 | 1309 | /* allocate and initialize one new instance */ |
... | ... | @@ -1331,7 +1313,7 @@ |
1331 | 1313 | |
1332 | 1314 | /* export host's Ethernet address in CDC format */ |
1333 | 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 | 1318 | spin_lock_init(&ncm->lock); |
1337 | 1319 | ncm_reset_values(ncm); |
1338 | 1320 | |
... | ... | @@ -1351,10 +1333,8 @@ |
1351 | 1333 | ncm->port.unwrap = ncm_unwrap_ntb; |
1352 | 1334 | |
1353 | 1335 | status = usb_add_function(c, &ncm->port.func); |
1354 | - if (status) { | |
1355 | - ncm_string_defs[1].s = NULL; | |
1336 | + if (status) | |
1356 | 1337 | kfree(ncm); |
1357 | - } | |
1358 | 1338 | return status; |
1359 | 1339 | } |
drivers/usb/gadget/f_obex.c
... | ... | @@ -379,6 +379,7 @@ |
379 | 379 | static void |
380 | 380 | obex_unbind(struct usb_configuration *c, struct usb_function *f) |
381 | 381 | { |
382 | + obex_string_defs[OBEX_CTRL_IDX].id = 0; | |
382 | 383 | usb_free_all_descriptors(f); |
383 | 384 | kfree(func_to_obex(f)); |
384 | 385 | } |
385 | 386 | |
386 | 387 | |
387 | 388 | |
... | ... | @@ -418,22 +419,16 @@ |
418 | 419 | if (!can_support_obex(c)) |
419 | 420 | return -EINVAL; |
420 | 421 | |
421 | - /* maybe allocate device-global string IDs, and patch descriptors */ | |
422 | 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 | 424 | if (status < 0) |
425 | 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 | - | |
430 | - status = usb_string_id(c->cdev); | |
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; | |
429 | + status = obex_string_defs[OBEX_DATA_IDX].id; | |
430 | + obex_data_nop_intf.iInterface = status; | |
431 | + obex_data_intf.iInterface = status; | |
437 | 432 | } |
438 | 433 | |
439 | 434 | /* allocate and initialize one new instance */ |
drivers/usb/gadget/f_rndis.c
... | ... | @@ -795,8 +795,8 @@ |
795 | 795 | |
796 | 796 | rndis_deregister(rndis->config); |
797 | 797 | rndis_exit(); |
798 | - rndis_string_defs[0].id = 0; | |
799 | 798 | |
799 | + rndis_string_defs[0].id = 0; | |
800 | 800 | usb_free_all_descriptors(f); |
801 | 801 | |
802 | 802 | kfree(rndis->notify_req->buf); |
803 | 803 | |
804 | 804 | |
805 | 805 | |
806 | 806 | |
... | ... | @@ -822,34 +822,19 @@ |
822 | 822 | if (!can_support_rndis(c) || !ethaddr) |
823 | 823 | return -EINVAL; |
824 | 824 | |
825 | - /* maybe allocate device-global string IDs */ | |
826 | 825 | if (rndis_string_defs[0].id == 0) { |
827 | - | |
828 | 826 | /* ... and setup RNDIS itself */ |
829 | 827 | status = rndis_init(); |
830 | 828 | if (status < 0) |
831 | 829 | return status; |
832 | 830 | |
833 | - /* control interface label */ | |
834 | - status = usb_string_id(c->cdev); | |
835 | - if (status < 0) | |
831 | + status = usb_string_ids_tab(c->cdev, rndis_string_defs); | |
832 | + if (status) | |
836 | 833 | return status; |
837 | - rndis_string_defs[0].id = status; | |
838 | - rndis_control_intf.iInterface = status; | |
839 | 834 | |
840 | - /* data interface label */ | |
841 | - status = usb_string_id(c->cdev); | |
842 | - if (status < 0) | |
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; | |
835 | + rndis_control_intf.iInterface = rndis_string_defs[0].id; | |
836 | + rndis_data_intf.iInterface = rndis_string_defs[1].id; | |
837 | + rndis_iad_descriptor.iFunction = rndis_string_defs[2].id; | |
853 | 838 | } |
854 | 839 | |
855 | 840 | /* allocate and initialize one new instance */ |
drivers/usb/gadget/f_subset.c
... | ... | @@ -236,7 +236,7 @@ |
236 | 236 | |
237 | 237 | static struct usb_string geth_string_defs[] = { |
238 | 238 | [0].s = "CDC Ethernet Subset/SAFE", |
239 | - [1].s = NULL /* DYNAMIC */, | |
239 | + [1].s = "", | |
240 | 240 | { } /* end of list */ |
241 | 241 | }; |
242 | 242 | |
243 | 243 | |
... | ... | @@ -363,8 +363,8 @@ |
363 | 363 | static void |
364 | 364 | geth_unbind(struct usb_configuration *c, struct usb_function *f) |
365 | 365 | { |
366 | + geth_string_defs[0].id = 0; | |
366 | 367 | usb_free_all_descriptors(f); |
367 | - geth_string_defs[1].s = NULL; | |
368 | 368 | kfree(func_to_geth(f)); |
369 | 369 | } |
370 | 370 | |
371 | 371 | |
... | ... | @@ -390,20 +390,11 @@ |
390 | 390 | |
391 | 391 | /* maybe allocate device-global string IDs */ |
392 | 392 | if (geth_string_defs[0].id == 0) { |
393 | - | |
394 | - /* interface label */ | |
395 | - status = usb_string_id(c->cdev); | |
393 | + status = usb_string_ids_tab(c->cdev, geth_string_defs); | |
396 | 394 | if (status < 0) |
397 | 395 | 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) | |
404 | - return status; | |
405 | - geth_string_defs[1].id = status; | |
406 | - ether_desc.iMACAddress = status; | |
396 | + subset_data_intf.iInterface = geth_string_defs[0].id; | |
397 | + ether_desc.iMACAddress = geth_string_defs[1].id; | |
407 | 398 | } |
408 | 399 | |
409 | 400 | /* allocate and initialize one new instance */ |
410 | 401 | |
... | ... | @@ -425,10 +416,8 @@ |
425 | 416 | geth->port.func.disable = geth_disable; |
426 | 417 | |
427 | 418 | status = usb_add_function(c, &geth->port.func); |
428 | - if (status) { | |
429 | - geth_string_defs[1].s = NULL; | |
419 | + if (status) | |
430 | 420 | kfree(geth); |
431 | - } | |
432 | 421 | return status; |
433 | 422 | } |
drivers/usb/gadget/f_uac2.c
... | ... | @@ -1312,7 +1312,7 @@ |
1312 | 1312 | |
1313 | 1313 | static int audio_bind_config(struct usb_configuration *cfg) |
1314 | 1314 | { |
1315 | - int id, res; | |
1315 | + int res; | |
1316 | 1316 | |
1317 | 1317 | agdev_g = kzalloc(sizeof *agdev_g, GFP_KERNEL); |
1318 | 1318 | if (agdev_g == NULL) { |
... | ... | @@ -1320,89 +1320,21 @@ |
1320 | 1320 | return -ENOMEM; |
1321 | 1321 | } |
1322 | 1322 | |
1323 | - id = usb_string_id(cfg->cdev); | |
1324 | - if (id < 0) | |
1325 | - return id; | |
1326 | - | |
1327 | - strings_fn[STR_ASSOC].id = id; | |
1328 | - iad_desc.iFunction = id, | |
1329 | - | |
1330 | - id = usb_string_id(cfg->cdev); | |
1331 | - if (id < 0) | |
1332 | - return id; | |
1333 | - | |
1334 | - strings_fn[STR_IF_CTRL].id = id; | |
1335 | - std_ac_if_desc.iInterface = id, | |
1336 | - | |
1337 | - id = usb_string_id(cfg->cdev); | |
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; | |
1323 | + res = usb_string_ids_tab(cfg->cdev, strings_fn); | |
1324 | + if (res) | |
1325 | + return res; | |
1326 | + iad_desc.iFunction = strings_fn[STR_ASSOC].id; | |
1327 | + std_ac_if_desc.iInterface = strings_fn[STR_IF_CTRL].id; | |
1328 | + in_clk_src_desc.iClockSource = strings_fn[STR_CLKSRC_IN].id; | |
1329 | + out_clk_src_desc.iClockSource = strings_fn[STR_CLKSRC_OUT].id; | |
1330 | + usb_out_it_desc.iTerminal = strings_fn[STR_USB_IT].id; | |
1331 | + io_in_it_desc.iTerminal = strings_fn[STR_IO_IT].id; | |
1332 | + usb_in_ot_desc.iTerminal = strings_fn[STR_USB_OT].id; | |
1333 | + io_out_ot_desc.iTerminal = strings_fn[STR_IO_OT].id; | |
1334 | + std_as_out_if0_desc.iInterface = strings_fn[STR_AS_OUT_ALT0].id; | |
1335 | + std_as_out_if1_desc.iInterface = strings_fn[STR_AS_OUT_ALT1].id; | |
1336 | + std_as_in_if0_desc.iInterface = strings_fn[STR_AS_IN_ALT0].id; | |
1337 | + std_as_in_if1_desc.iInterface = strings_fn[STR_AS_IN_ALT1].id; | |
1406 | 1338 | |
1407 | 1339 | agdev_g->func.name = "uac2_func"; |
1408 | 1340 | agdev_g->func.strings = fn_strings; |
drivers/usb/gadget/f_uvc.c
... | ... | @@ -580,6 +580,7 @@ |
580 | 580 | uvc->control_ep->driver_data = NULL; |
581 | 581 | uvc->video.ep->driver_data = NULL; |
582 | 582 | |
583 | + uvc_en_us_strings[UVC_STRING_ASSOCIATION_IDX].id = 0; | |
583 | 584 | usb_ep_free_request(cdev->gadget->ep0, uvc->control_req); |
584 | 585 | kfree(uvc->control_buf); |
585 | 586 | |
586 | 587 | |
587 | 588 | |
... | ... | @@ -798,25 +799,16 @@ |
798 | 799 | uvc->desc.hs_streaming = hs_streaming; |
799 | 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 | 803 | if (uvc_en_us_strings[UVC_STRING_ASSOCIATION_IDX].id == 0) { |
803 | - /* Allocate string descriptor numbers. */ | |
804 | - ret = usb_string_id(c->cdev); | |
805 | - if (ret < 0) | |
804 | + ret = usb_string_ids_tab(c->cdev, uvc_en_us_strings); | |
805 | + if (ret) | |
806 | 806 | goto error; |
807 | - uvc_en_us_strings[UVC_STRING_ASSOCIATION_IDX].id = ret; | |
808 | - uvc_iad.iFunction = ret; | |
809 | - | |
810 | - ret = usb_string_id(c->cdev); | |
811 | - if (ret < 0) | |
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; | |
807 | + uvc_iad.iFunction = | |
808 | + uvc_en_us_strings[UVC_STRING_ASSOCIATION_IDX].id; | |
809 | + uvc_control_intf.iInterface = | |
810 | + uvc_en_us_strings[UVC_STRING_CONTROL_IDX].id; | |
811 | + ret = uvc_en_us_strings[UVC_STRING_STREAMING_IDX].id; | |
820 | 812 | uvc_streaming_intf_alt0.iInterface = ret; |
821 | 813 | uvc_streaming_intf_alt1.iInterface = ret; |
822 | 814 | } |