diff options
Diffstat (limited to 'drivers/usb/gadget')
-rw-r--r-- | drivers/usb/gadget/composite.c | 8 | ||||
-rw-r--r-- | drivers/usb/gadget/config.c | 39 | ||||
-rw-r--r-- | drivers/usb/gadget/f_acm.c | 45 | ||||
-rw-r--r-- | drivers/usb/gadget/f_ecm.c | 57 | ||||
-rw-r--r-- | drivers/usb/gadget/f_eem.c | 46 | ||||
-rw-r--r-- | drivers/usb/gadget/f_fs.c | 4 | ||||
-rw-r--r-- | drivers/usb/gadget/f_hid.c | 30 | ||||
-rw-r--r-- | drivers/usb/gadget/f_loopback.c | 28 | ||||
-rw-r--r-- | drivers/usb/gadget/f_mass_storage.c | 59 | ||||
-rw-r--r-- | drivers/usb/gadget/f_midi.c | 8 | ||||
-rw-r--r-- | drivers/usb/gadget/f_ncm.c | 32 | ||||
-rw-r--r-- | drivers/usb/gadget/f_obex.c | 23 | ||||
-rw-r--r-- | drivers/usb/gadget/f_phonet.c | 15 | ||||
-rw-r--r-- | drivers/usb/gadget/f_rndis.c | 55 | ||||
-rw-r--r-- | drivers/usb/gadget/f_serial.c | 38 | ||||
-rw-r--r-- | drivers/usb/gadget/f_sourcesink.c | 104 | ||||
-rw-r--r-- | drivers/usb/gadget/f_subset.c | 48 | ||||
-rw-r--r-- | drivers/usb/gadget/f_uac1.c | 22 | ||||
-rw-r--r-- | drivers/usb/gadget/f_uac2.c | 16 | ||||
-rw-r--r-- | drivers/usb/gadget/f_uvc.c | 79 | ||||
-rw-r--r-- | drivers/usb/gadget/printer.c | 12 | ||||
-rw-r--r-- | drivers/usb/gadget/tcm_usb_gadget.c | 10 |
22 files changed, 299 insertions, 479 deletions
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index 957f973dd96a..2a6bfe759c29 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c | |||
@@ -107,7 +107,7 @@ int config_ep_by_speed(struct usb_gadget *g, | |||
107 | } | 107 | } |
108 | /* else: fall through */ | 108 | /* else: fall through */ |
109 | default: | 109 | default: |
110 | speed_desc = f->descriptors; | 110 | speed_desc = f->fs_descriptors; |
111 | } | 111 | } |
112 | /* find descriptors */ | 112 | /* find descriptors */ |
113 | for_each_ep_desc(speed_desc, d_spd) { | 113 | for_each_ep_desc(speed_desc, d_spd) { |
@@ -200,7 +200,7 @@ int usb_add_function(struct usb_configuration *config, | |||
200 | * as full speed ... it's the function drivers that will need | 200 | * as full speed ... it's the function drivers that will need |
201 | * to avoid bulk and ISO transfers. | 201 | * to avoid bulk and ISO transfers. |
202 | */ | 202 | */ |
203 | if (!config->fullspeed && function->descriptors) | 203 | if (!config->fullspeed && function->fs_descriptors) |
204 | config->fullspeed = true; | 204 | config->fullspeed = true; |
205 | if (!config->highspeed && function->hs_descriptors) | 205 | if (!config->highspeed && function->hs_descriptors) |
206 | config->highspeed = true; | 206 | config->highspeed = true; |
@@ -363,7 +363,7 @@ static int config_buf(struct usb_configuration *config, | |||
363 | descriptors = f->hs_descriptors; | 363 | descriptors = f->hs_descriptors; |
364 | break; | 364 | break; |
365 | default: | 365 | default: |
366 | descriptors = f->descriptors; | 366 | descriptors = f->fs_descriptors; |
367 | } | 367 | } |
368 | 368 | ||
369 | if (!descriptors) | 369 | if (!descriptors) |
@@ -620,7 +620,7 @@ static int set_config(struct usb_composite_dev *cdev, | |||
620 | descriptors = f->hs_descriptors; | 620 | descriptors = f->hs_descriptors; |
621 | break; | 621 | break; |
622 | default: | 622 | default: |
623 | descriptors = f->descriptors; | 623 | descriptors = f->fs_descriptors; |
624 | } | 624 | } |
625 | 625 | ||
626 | for (; *descriptors; ++descriptors) { | 626 | for (; *descriptors; ++descriptors) { |
diff --git a/drivers/usb/gadget/config.c b/drivers/usb/gadget/config.c index e3a98929d346..34e12fc52c23 100644 --- a/drivers/usb/gadget/config.c +++ b/drivers/usb/gadget/config.c | |||
@@ -19,7 +19,7 @@ | |||
19 | 19 | ||
20 | #include <linux/usb/ch9.h> | 20 | #include <linux/usb/ch9.h> |
21 | #include <linux/usb/gadget.h> | 21 | #include <linux/usb/gadget.h> |
22 | 22 | #include <linux/usb/composite.h> | |
23 | 23 | ||
24 | /** | 24 | /** |
25 | * usb_descriptor_fillbuf - fill buffer with descriptors | 25 | * usb_descriptor_fillbuf - fill buffer with descriptors |
@@ -158,3 +158,40 @@ usb_copy_descriptors(struct usb_descriptor_header **src) | |||
158 | return ret; | 158 | return ret; |
159 | } | 159 | } |
160 | EXPORT_SYMBOL_GPL(usb_copy_descriptors); | 160 | EXPORT_SYMBOL_GPL(usb_copy_descriptors); |
161 | |||
162 | int usb_assign_descriptors(struct usb_function *f, | ||
163 | struct usb_descriptor_header **fs, | ||
164 | struct usb_descriptor_header **hs, | ||
165 | struct usb_descriptor_header **ss) | ||
166 | { | ||
167 | struct usb_gadget *g = f->config->cdev->gadget; | ||
168 | |||
169 | if (fs) { | ||
170 | f->fs_descriptors = usb_copy_descriptors(fs); | ||
171 | if (!f->fs_descriptors) | ||
172 | goto err; | ||
173 | } | ||
174 | if (hs && gadget_is_dualspeed(g)) { | ||
175 | f->hs_descriptors = usb_copy_descriptors(hs); | ||
176 | if (!f->hs_descriptors) | ||
177 | goto err; | ||
178 | } | ||
179 | if (ss && gadget_is_superspeed(g)) { | ||
180 | f->ss_descriptors = usb_copy_descriptors(ss); | ||
181 | if (!f->ss_descriptors) | ||
182 | goto err; | ||
183 | } | ||
184 | return 0; | ||
185 | err: | ||
186 | usb_free_all_descriptors(f); | ||
187 | return -ENOMEM; | ||
188 | } | ||
189 | EXPORT_SYMBOL_GPL(usb_assign_descriptors); | ||
190 | |||
191 | void usb_free_all_descriptors(struct usb_function *f) | ||
192 | { | ||
193 | usb_free_descriptors(f->fs_descriptors); | ||
194 | usb_free_descriptors(f->hs_descriptors); | ||
195 | usb_free_descriptors(f->ss_descriptors); | ||
196 | } | ||
197 | EXPORT_SYMBOL_GPL(usb_free_all_descriptors); | ||
diff --git a/drivers/usb/gadget/f_acm.c b/drivers/usb/gadget/f_acm.c index 7c30bb49850b..308242b5d6e0 100644 --- a/drivers/usb/gadget/f_acm.c +++ b/drivers/usb/gadget/f_acm.c | |||
@@ -658,37 +658,22 @@ acm_bind(struct usb_configuration *c, struct usb_function *f) | |||
658 | acm->notify_req->complete = acm_cdc_notify_complete; | 658 | acm->notify_req->complete = acm_cdc_notify_complete; |
659 | acm->notify_req->context = acm; | 659 | acm->notify_req->context = acm; |
660 | 660 | ||
661 | /* copy descriptors */ | ||
662 | f->descriptors = usb_copy_descriptors(acm_fs_function); | ||
663 | if (!f->descriptors) | ||
664 | goto fail; | ||
665 | |||
666 | /* support all relevant hardware speeds... we expect that when | 661 | /* support all relevant hardware speeds... we expect that when |
667 | * hardware is dual speed, all bulk-capable endpoints work at | 662 | * hardware is dual speed, all bulk-capable endpoints work at |
668 | * both speeds | 663 | * both speeds |
669 | */ | 664 | */ |
670 | if (gadget_is_dualspeed(c->cdev->gadget)) { | 665 | acm_hs_in_desc.bEndpointAddress = acm_fs_in_desc.bEndpointAddress; |
671 | acm_hs_in_desc.bEndpointAddress = | 666 | acm_hs_out_desc.bEndpointAddress = acm_fs_out_desc.bEndpointAddress; |
672 | acm_fs_in_desc.bEndpointAddress; | 667 | acm_hs_notify_desc.bEndpointAddress = |
673 | acm_hs_out_desc.bEndpointAddress = | 668 | acm_fs_notify_desc.bEndpointAddress; |
674 | acm_fs_out_desc.bEndpointAddress; | 669 | |
675 | acm_hs_notify_desc.bEndpointAddress = | 670 | acm_ss_in_desc.bEndpointAddress = acm_fs_in_desc.bEndpointAddress; |
676 | acm_fs_notify_desc.bEndpointAddress; | 671 | acm_ss_out_desc.bEndpointAddress = acm_fs_out_desc.bEndpointAddress; |
677 | 672 | ||
678 | /* copy descriptors */ | 673 | status = usb_assign_descriptors(f, acm_fs_function, acm_hs_function, |
679 | f->hs_descriptors = usb_copy_descriptors(acm_hs_function); | 674 | acm_ss_function); |
680 | } | 675 | if (status) |
681 | if (gadget_is_superspeed(c->cdev->gadget)) { | 676 | goto fail; |
682 | acm_ss_in_desc.bEndpointAddress = | ||
683 | acm_fs_in_desc.bEndpointAddress; | ||
684 | acm_ss_out_desc.bEndpointAddress = | ||
685 | acm_fs_out_desc.bEndpointAddress; | ||
686 | |||
687 | /* copy descriptors, and track endpoint copies */ | ||
688 | f->ss_descriptors = usb_copy_descriptors(acm_ss_function); | ||
689 | if (!f->ss_descriptors) | ||
690 | goto fail; | ||
691 | } | ||
692 | 677 | ||
693 | DBG(cdev, "acm ttyGS%d: %s speed IN/%s OUT/%s NOTIFY/%s\n", | 678 | DBG(cdev, "acm ttyGS%d: %s speed IN/%s OUT/%s NOTIFY/%s\n", |
694 | acm->port_num, | 679 | acm->port_num, |
@@ -720,11 +705,7 @@ acm_unbind(struct usb_configuration *c, struct usb_function *f) | |||
720 | { | 705 | { |
721 | struct f_acm *acm = func_to_acm(f); | 706 | struct f_acm *acm = func_to_acm(f); |
722 | 707 | ||
723 | if (gadget_is_dualspeed(c->cdev->gadget)) | 708 | usb_free_all_descriptors(f); |
724 | usb_free_descriptors(f->hs_descriptors); | ||
725 | if (gadget_is_superspeed(c->cdev->gadget)) | ||
726 | usb_free_descriptors(f->ss_descriptors); | ||
727 | usb_free_descriptors(f->descriptors); | ||
728 | gs_free_req(acm->notify, acm->notify_req); | 709 | gs_free_req(acm->notify, acm->notify_req); |
729 | kfree(acm); | 710 | kfree(acm); |
730 | } | 711 | } |
diff --git a/drivers/usb/gadget/f_ecm.c b/drivers/usb/gadget/f_ecm.c index a158740255ce..2d3c5a46de8e 100644 --- a/drivers/usb/gadget/f_ecm.c +++ b/drivers/usb/gadget/f_ecm.c | |||
@@ -743,42 +743,24 @@ ecm_bind(struct usb_configuration *c, struct usb_function *f) | |||
743 | ecm->notify_req->context = ecm; | 743 | ecm->notify_req->context = ecm; |
744 | ecm->notify_req->complete = ecm_notify_complete; | 744 | ecm->notify_req->complete = ecm_notify_complete; |
745 | 745 | ||
746 | /* copy descriptors, and track endpoint copies */ | ||
747 | f->descriptors = usb_copy_descriptors(ecm_fs_function); | ||
748 | if (!f->descriptors) | ||
749 | goto fail; | ||
750 | |||
751 | /* support all relevant hardware speeds... we expect that when | 746 | /* support all relevant hardware speeds... we expect that when |
752 | * hardware is dual speed, all bulk-capable endpoints work at | 747 | * hardware is dual speed, all bulk-capable endpoints work at |
753 | * both speeds | 748 | * both speeds |
754 | */ | 749 | */ |
755 | if (gadget_is_dualspeed(c->cdev->gadget)) { | 750 | hs_ecm_in_desc.bEndpointAddress = fs_ecm_in_desc.bEndpointAddress; |
756 | hs_ecm_in_desc.bEndpointAddress = | 751 | hs_ecm_out_desc.bEndpointAddress = fs_ecm_out_desc.bEndpointAddress; |
757 | fs_ecm_in_desc.bEndpointAddress; | 752 | hs_ecm_notify_desc.bEndpointAddress = |
758 | hs_ecm_out_desc.bEndpointAddress = | 753 | fs_ecm_notify_desc.bEndpointAddress; |
759 | fs_ecm_out_desc.bEndpointAddress; | 754 | |
760 | hs_ecm_notify_desc.bEndpointAddress = | 755 | ss_ecm_in_desc.bEndpointAddress = fs_ecm_in_desc.bEndpointAddress; |
761 | fs_ecm_notify_desc.bEndpointAddress; | 756 | ss_ecm_out_desc.bEndpointAddress = fs_ecm_out_desc.bEndpointAddress; |
762 | 757 | ss_ecm_notify_desc.bEndpointAddress = | |
763 | /* copy descriptors, and track endpoint copies */ | 758 | fs_ecm_notify_desc.bEndpointAddress; |
764 | f->hs_descriptors = usb_copy_descriptors(ecm_hs_function); | 759 | |
765 | if (!f->hs_descriptors) | 760 | status = usb_assign_descriptors(f, ecm_fs_function, ecm_hs_function, |
766 | goto fail; | 761 | ecm_ss_function); |
767 | } | 762 | if (status) |
768 | 763 | goto fail; | |
769 | if (gadget_is_superspeed(c->cdev->gadget)) { | ||
770 | ss_ecm_in_desc.bEndpointAddress = | ||
771 | fs_ecm_in_desc.bEndpointAddress; | ||
772 | ss_ecm_out_desc.bEndpointAddress = | ||
773 | fs_ecm_out_desc.bEndpointAddress; | ||
774 | ss_ecm_notify_desc.bEndpointAddress = | ||
775 | fs_ecm_notify_desc.bEndpointAddress; | ||
776 | |||
777 | /* copy descriptors, and track endpoint copies */ | ||
778 | f->ss_descriptors = usb_copy_descriptors(ecm_ss_function); | ||
779 | if (!f->ss_descriptors) | ||
780 | goto fail; | ||
781 | } | ||
782 | 764 | ||
783 | /* NOTE: all that is done without knowing or caring about | 765 | /* NOTE: all that is done without knowing or caring about |
784 | * the network link ... which is unavailable to this code | 766 | * the network link ... which is unavailable to this code |
@@ -796,11 +778,6 @@ ecm_bind(struct usb_configuration *c, struct usb_function *f) | |||
796 | return 0; | 778 | return 0; |
797 | 779 | ||
798 | fail: | 780 | fail: |
799 | if (f->descriptors) | ||
800 | usb_free_descriptors(f->descriptors); | ||
801 | if (f->hs_descriptors) | ||
802 | usb_free_descriptors(f->hs_descriptors); | ||
803 | |||
804 | if (ecm->notify_req) { | 781 | if (ecm->notify_req) { |
805 | kfree(ecm->notify_req->buf); | 782 | kfree(ecm->notify_req->buf); |
806 | usb_ep_free_request(ecm->notify, ecm->notify_req); | 783 | usb_ep_free_request(ecm->notify, ecm->notify_req); |
@@ -826,11 +803,7 @@ ecm_unbind(struct usb_configuration *c, struct usb_function *f) | |||
826 | 803 | ||
827 | DBG(c->cdev, "ecm unbind\n"); | 804 | DBG(c->cdev, "ecm unbind\n"); |
828 | 805 | ||
829 | if (gadget_is_superspeed(c->cdev->gadget)) | 806 | usb_free_all_descriptors(f); |
830 | usb_free_descriptors(f->ss_descriptors); | ||
831 | if (gadget_is_dualspeed(c->cdev->gadget)) | ||
832 | usb_free_descriptors(f->hs_descriptors); | ||
833 | usb_free_descriptors(f->descriptors); | ||
834 | 807 | ||
835 | kfree(ecm->notify_req->buf); | 808 | kfree(ecm->notify_req->buf); |
836 | usb_ep_free_request(ecm->notify, ecm->notify_req); | 809 | usb_ep_free_request(ecm->notify, ecm->notify_req); |
diff --git a/drivers/usb/gadget/f_eem.c b/drivers/usb/gadget/f_eem.c index a9cf20522ffa..cf0ebee85563 100644 --- a/drivers/usb/gadget/f_eem.c +++ b/drivers/usb/gadget/f_eem.c | |||
@@ -274,38 +274,20 @@ eem_bind(struct usb_configuration *c, struct usb_function *f) | |||
274 | 274 | ||
275 | status = -ENOMEM; | 275 | status = -ENOMEM; |
276 | 276 | ||
277 | /* copy descriptors, and track endpoint copies */ | ||
278 | f->descriptors = usb_copy_descriptors(eem_fs_function); | ||
279 | if (!f->descriptors) | ||
280 | goto fail; | ||
281 | |||
282 | /* support all relevant hardware speeds... we expect that when | 277 | /* support all relevant hardware speeds... we expect that when |
283 | * hardware is dual speed, all bulk-capable endpoints work at | 278 | * hardware is dual speed, all bulk-capable endpoints work at |
284 | * both speeds | 279 | * both speeds |
285 | */ | 280 | */ |
286 | if (gadget_is_dualspeed(c->cdev->gadget)) { | 281 | eem_hs_in_desc.bEndpointAddress = eem_fs_in_desc.bEndpointAddress; |
287 | eem_hs_in_desc.bEndpointAddress = | 282 | eem_hs_out_desc.bEndpointAddress = eem_fs_out_desc.bEndpointAddress; |
288 | eem_fs_in_desc.bEndpointAddress; | ||
289 | eem_hs_out_desc.bEndpointAddress = | ||
290 | eem_fs_out_desc.bEndpointAddress; | ||
291 | |||
292 | /* copy descriptors, and track endpoint copies */ | ||
293 | f->hs_descriptors = usb_copy_descriptors(eem_hs_function); | ||
294 | if (!f->hs_descriptors) | ||
295 | goto fail; | ||
296 | } | ||
297 | 283 | ||
298 | if (gadget_is_superspeed(c->cdev->gadget)) { | 284 | eem_ss_in_desc.bEndpointAddress = eem_fs_in_desc.bEndpointAddress; |
299 | eem_ss_in_desc.bEndpointAddress = | 285 | eem_ss_out_desc.bEndpointAddress = eem_fs_out_desc.bEndpointAddress; |
300 | eem_fs_in_desc.bEndpointAddress; | ||
301 | eem_ss_out_desc.bEndpointAddress = | ||
302 | eem_fs_out_desc.bEndpointAddress; | ||
303 | 286 | ||
304 | /* copy descriptors, and track endpoint copies */ | 287 | status = usb_assign_descriptors(f, eem_fs_function, eem_hs_function, |
305 | f->ss_descriptors = usb_copy_descriptors(eem_ss_function); | 288 | eem_ss_function); |
306 | if (!f->ss_descriptors) | 289 | if (status) |
307 | goto fail; | 290 | goto fail; |
308 | } | ||
309 | 291 | ||
310 | DBG(cdev, "CDC Ethernet (EEM): %s speed IN/%s OUT/%s\n", | 292 | DBG(cdev, "CDC Ethernet (EEM): %s speed IN/%s OUT/%s\n", |
311 | gadget_is_superspeed(c->cdev->gadget) ? "super" : | 293 | gadget_is_superspeed(c->cdev->gadget) ? "super" : |
@@ -314,11 +296,7 @@ eem_bind(struct usb_configuration *c, struct usb_function *f) | |||
314 | return 0; | 296 | return 0; |
315 | 297 | ||
316 | fail: | 298 | fail: |
317 | if (f->descriptors) | 299 | usb_free_all_descriptors(f); |
318 | usb_free_descriptors(f->descriptors); | ||
319 | if (f->hs_descriptors) | ||
320 | usb_free_descriptors(f->hs_descriptors); | ||
321 | |||
322 | if (eem->port.out_ep) | 300 | if (eem->port.out_ep) |
323 | eem->port.out_ep->driver_data = NULL; | 301 | eem->port.out_ep->driver_data = NULL; |
324 | if (eem->port.in_ep) | 302 | if (eem->port.in_ep) |
@@ -336,11 +314,7 @@ eem_unbind(struct usb_configuration *c, struct usb_function *f) | |||
336 | 314 | ||
337 | DBG(c->cdev, "eem unbind\n"); | 315 | DBG(c->cdev, "eem unbind\n"); |
338 | 316 | ||
339 | if (gadget_is_superspeed(c->cdev->gadget)) | 317 | usb_free_all_descriptors(f); |
340 | usb_free_descriptors(f->ss_descriptors); | ||
341 | if (gadget_is_dualspeed(c->cdev->gadget)) | ||
342 | usb_free_descriptors(f->hs_descriptors); | ||
343 | usb_free_descriptors(f->descriptors); | ||
344 | kfree(eem); | 318 | kfree(eem); |
345 | } | 319 | } |
346 | 320 | ||
diff --git a/drivers/usb/gadget/f_fs.c b/drivers/usb/gadget/f_fs.c index 64c4ec10d1fc..4a6961c517f2 100644 --- a/drivers/usb/gadget/f_fs.c +++ b/drivers/usb/gadget/f_fs.c | |||
@@ -2097,7 +2097,7 @@ static int __ffs_func_bind_do_descs(enum ffs_entity_type type, u8 *valuep, | |||
2097 | if (isHS) | 2097 | if (isHS) |
2098 | func->function.hs_descriptors[(long)valuep] = desc; | 2098 | func->function.hs_descriptors[(long)valuep] = desc; |
2099 | else | 2099 | else |
2100 | func->function.descriptors[(long)valuep] = desc; | 2100 | func->function.fs_descriptors[(long)valuep] = desc; |
2101 | 2101 | ||
2102 | if (!desc || desc->bDescriptorType != USB_DT_ENDPOINT) | 2102 | if (!desc || desc->bDescriptorType != USB_DT_ENDPOINT) |
2103 | return 0; | 2103 | return 0; |
@@ -2249,7 +2249,7 @@ static int ffs_func_bind(struct usb_configuration *c, | |||
2249 | * numbers without worrying that it may be described later on. | 2249 | * numbers without worrying that it may be described later on. |
2250 | */ | 2250 | */ |
2251 | if (likely(full)) { | 2251 | if (likely(full)) { |
2252 | func->function.descriptors = data->fs_descs; | 2252 | func->function.fs_descriptors = data->fs_descs; |
2253 | ret = ffs_do_descs(ffs->fs_descs_count, | 2253 | ret = ffs_do_descs(ffs->fs_descs_count, |
2254 | data->raw_descs, | 2254 | data->raw_descs, |
2255 | sizeof data->raw_descs, | 2255 | sizeof data->raw_descs, |
diff --git a/drivers/usb/gadget/f_hid.c b/drivers/usb/gadget/f_hid.c index 511e527178e2..6e69a8e8d22a 100644 --- a/drivers/usb/gadget/f_hid.c +++ b/drivers/usb/gadget/f_hid.c | |||
@@ -573,7 +573,6 @@ static int __init hidg_bind(struct usb_configuration *c, struct usb_function *f) | |||
573 | goto fail; | 573 | goto fail; |
574 | hidg_interface_desc.bInterfaceNumber = status; | 574 | hidg_interface_desc.bInterfaceNumber = status; |
575 | 575 | ||
576 | |||
577 | /* allocate instance-specific endpoints */ | 576 | /* allocate instance-specific endpoints */ |
578 | status = -ENODEV; | 577 | status = -ENODEV; |
579 | ep = usb_ep_autoconfig(c->cdev->gadget, &hidg_fs_in_ep_desc); | 578 | ep = usb_ep_autoconfig(c->cdev->gadget, &hidg_fs_in_ep_desc); |
@@ -609,20 +608,15 @@ static int __init hidg_bind(struct usb_configuration *c, struct usb_function *f) | |||
609 | hidg_desc.desc[0].wDescriptorLength = | 608 | hidg_desc.desc[0].wDescriptorLength = |
610 | cpu_to_le16(hidg->report_desc_length); | 609 | cpu_to_le16(hidg->report_desc_length); |
611 | 610 | ||
612 | /* copy descriptors */ | 611 | hidg_hs_in_ep_desc.bEndpointAddress = |
613 | f->descriptors = usb_copy_descriptors(hidg_fs_descriptors); | 612 | hidg_fs_in_ep_desc.bEndpointAddress; |
614 | if (!f->descriptors) | 613 | hidg_hs_out_ep_desc.bEndpointAddress = |
615 | goto fail; | 614 | hidg_fs_out_ep_desc.bEndpointAddress; |
616 | 615 | ||
617 | if (gadget_is_dualspeed(c->cdev->gadget)) { | 616 | status = usb_assign_descriptors(f, hidg_fs_descriptors, |
618 | hidg_hs_in_ep_desc.bEndpointAddress = | 617 | hidg_hs_descriptors, NULL); |
619 | hidg_fs_in_ep_desc.bEndpointAddress; | 618 | if (status) |
620 | hidg_hs_out_ep_desc.bEndpointAddress = | 619 | goto fail; |
621 | hidg_fs_out_ep_desc.bEndpointAddress; | ||
622 | f->hs_descriptors = usb_copy_descriptors(hidg_hs_descriptors); | ||
623 | if (!f->hs_descriptors) | ||
624 | goto fail; | ||
625 | } | ||
626 | 620 | ||
627 | mutex_init(&hidg->lock); | 621 | mutex_init(&hidg->lock); |
628 | spin_lock_init(&hidg->spinlock); | 622 | spin_lock_init(&hidg->spinlock); |
@@ -649,9 +643,7 @@ fail: | |||
649 | usb_ep_free_request(hidg->in_ep, hidg->req); | 643 | usb_ep_free_request(hidg->in_ep, hidg->req); |
650 | } | 644 | } |
651 | 645 | ||
652 | usb_free_descriptors(f->hs_descriptors); | 646 | usb_free_all_descriptors(f); |
653 | usb_free_descriptors(f->descriptors); | ||
654 | |||
655 | return status; | 647 | return status; |
656 | } | 648 | } |
657 | 649 | ||
@@ -668,9 +660,7 @@ static void hidg_unbind(struct usb_configuration *c, struct usb_function *f) | |||
668 | kfree(hidg->req->buf); | 660 | kfree(hidg->req->buf); |
669 | usb_ep_free_request(hidg->in_ep, hidg->req); | 661 | usb_ep_free_request(hidg->in_ep, hidg->req); |
670 | 662 | ||
671 | /* free descriptors copies */ | 663 | usb_free_all_descriptors(f); |
672 | usb_free_descriptors(f->hs_descriptors); | ||
673 | usb_free_descriptors(f->descriptors); | ||
674 | 664 | ||
675 | kfree(hidg->report_desc); | 665 | kfree(hidg->report_desc); |
676 | kfree(hidg); | 666 | kfree(hidg); |
diff --git a/drivers/usb/gadget/f_loopback.c b/drivers/usb/gadget/f_loopback.c index 7275706caeb0..bb39cb2bb3a3 100644 --- a/drivers/usb/gadget/f_loopback.c +++ b/drivers/usb/gadget/f_loopback.c | |||
@@ -177,6 +177,7 @@ loopback_bind(struct usb_configuration *c, struct usb_function *f) | |||
177 | struct usb_composite_dev *cdev = c->cdev; | 177 | struct usb_composite_dev *cdev = c->cdev; |
178 | struct f_loopback *loop = func_to_loop(f); | 178 | struct f_loopback *loop = func_to_loop(f); |
179 | int id; | 179 | int id; |
180 | int ret; | ||
180 | 181 | ||
181 | /* allocate interface ID(s) */ | 182 | /* allocate interface ID(s) */ |
182 | id = usb_interface_id(c, f); | 183 | id = usb_interface_id(c, f); |
@@ -201,22 +202,19 @@ autoconf_fail: | |||
201 | loop->out_ep->driver_data = cdev; /* claim */ | 202 | loop->out_ep->driver_data = cdev; /* claim */ |
202 | 203 | ||
203 | /* support high speed hardware */ | 204 | /* support high speed hardware */ |
204 | if (gadget_is_dualspeed(c->cdev->gadget)) { | 205 | hs_loop_source_desc.bEndpointAddress = |
205 | hs_loop_source_desc.bEndpointAddress = | 206 | fs_loop_source_desc.bEndpointAddress; |
206 | fs_loop_source_desc.bEndpointAddress; | 207 | hs_loop_sink_desc.bEndpointAddress = fs_loop_sink_desc.bEndpointAddress; |
207 | hs_loop_sink_desc.bEndpointAddress = | ||
208 | fs_loop_sink_desc.bEndpointAddress; | ||
209 | f->hs_descriptors = hs_loopback_descs; | ||
210 | } | ||
211 | 208 | ||
212 | /* support super speed hardware */ | 209 | /* support super speed hardware */ |
213 | if (gadget_is_superspeed(c->cdev->gadget)) { | 210 | ss_loop_source_desc.bEndpointAddress = |
214 | ss_loop_source_desc.bEndpointAddress = | 211 | fs_loop_source_desc.bEndpointAddress; |
215 | fs_loop_source_desc.bEndpointAddress; | 212 | ss_loop_sink_desc.bEndpointAddress = fs_loop_sink_desc.bEndpointAddress; |
216 | ss_loop_sink_desc.bEndpointAddress = | 213 | |
217 | fs_loop_sink_desc.bEndpointAddress; | 214 | ret = usb_assign_descriptors(f, fs_loopback_descs, hs_loopback_descs, |
218 | f->ss_descriptors = ss_loopback_descs; | 215 | ss_loopback_descs); |
219 | } | 216 | if (ret) |
217 | return ret; | ||
220 | 218 | ||
221 | DBG(cdev, "%s speed %s: IN/%s, OUT/%s\n", | 219 | DBG(cdev, "%s speed %s: IN/%s, OUT/%s\n", |
222 | (gadget_is_superspeed(c->cdev->gadget) ? "super" : | 220 | (gadget_is_superspeed(c->cdev->gadget) ? "super" : |
@@ -228,6 +226,7 @@ autoconf_fail: | |||
228 | static void | 226 | static void |
229 | loopback_unbind(struct usb_configuration *c, struct usb_function *f) | 227 | loopback_unbind(struct usb_configuration *c, struct usb_function *f) |
230 | { | 228 | { |
229 | usb_free_all_descriptors(f); | ||
231 | kfree(func_to_loop(f)); | 230 | kfree(func_to_loop(f)); |
232 | } | 231 | } |
233 | 232 | ||
@@ -379,7 +378,6 @@ static int __init loopback_bind_config(struct usb_configuration *c) | |||
379 | return -ENOMEM; | 378 | return -ENOMEM; |
380 | 379 | ||
381 | loop->function.name = "loopback"; | 380 | loop->function.name = "loopback"; |
382 | loop->function.descriptors = fs_loopback_descs; | ||
383 | loop->function.bind = loopback_bind; | 381 | loop->function.bind = loopback_bind; |
384 | loop->function.unbind = loopback_unbind; | 382 | loop->function.unbind = loopback_unbind; |
385 | loop->function.set_alt = loopback_set_alt; | 383 | loop->function.set_alt = loopback_set_alt; |
diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c index 3a7668bde3ef..3433e432a4ae 100644 --- a/drivers/usb/gadget/f_mass_storage.c +++ b/drivers/usb/gadget/f_mass_storage.c | |||
@@ -2904,9 +2904,7 @@ static void fsg_unbind(struct usb_configuration *c, struct usb_function *f) | |||
2904 | } | 2904 | } |
2905 | 2905 | ||
2906 | fsg_common_put(common); | 2906 | fsg_common_put(common); |
2907 | usb_free_descriptors(fsg->function.descriptors); | 2907 | usb_free_all_descriptors(&fsg->function); |
2908 | usb_free_descriptors(fsg->function.hs_descriptors); | ||
2909 | usb_free_descriptors(fsg->function.ss_descriptors); | ||
2910 | kfree(fsg); | 2908 | kfree(fsg); |
2911 | } | 2909 | } |
2912 | 2910 | ||
@@ -2916,6 +2914,8 @@ static int fsg_bind(struct usb_configuration *c, struct usb_function *f) | |||
2916 | struct usb_gadget *gadget = c->cdev->gadget; | 2914 | struct usb_gadget *gadget = c->cdev->gadget; |
2917 | int i; | 2915 | int i; |
2918 | struct usb_ep *ep; | 2916 | struct usb_ep *ep; |
2917 | unsigned max_burst; | ||
2918 | int ret; | ||
2919 | 2919 | ||
2920 | fsg->gadget = gadget; | 2920 | fsg->gadget = gadget; |
2921 | 2921 | ||
@@ -2939,45 +2939,27 @@ static int fsg_bind(struct usb_configuration *c, struct usb_function *f) | |||
2939 | ep->driver_data = fsg->common; /* claim the endpoint */ | 2939 | ep->driver_data = fsg->common; /* claim the endpoint */ |
2940 | fsg->bulk_out = ep; | 2940 | fsg->bulk_out = ep; |
2941 | 2941 | ||
2942 | /* Copy descriptors */ | 2942 | /* Assume endpoint addresses are the same for both speeds */ |
2943 | f->descriptors = usb_copy_descriptors(fsg_fs_function); | 2943 | fsg_hs_bulk_in_desc.bEndpointAddress = |
2944 | if (unlikely(!f->descriptors)) | 2944 | fsg_fs_bulk_in_desc.bEndpointAddress; |
2945 | return -ENOMEM; | 2945 | fsg_hs_bulk_out_desc.bEndpointAddress = |
2946 | 2946 | fsg_fs_bulk_out_desc.bEndpointAddress; | |
2947 | if (gadget_is_dualspeed(gadget)) { | ||
2948 | /* Assume endpoint addresses are the same for both speeds */ | ||
2949 | fsg_hs_bulk_in_desc.bEndpointAddress = | ||
2950 | fsg_fs_bulk_in_desc.bEndpointAddress; | ||
2951 | fsg_hs_bulk_out_desc.bEndpointAddress = | ||
2952 | fsg_fs_bulk_out_desc.bEndpointAddress; | ||
2953 | f->hs_descriptors = usb_copy_descriptors(fsg_hs_function); | ||
2954 | if (unlikely(!f->hs_descriptors)) { | ||
2955 | usb_free_descriptors(f->descriptors); | ||
2956 | return -ENOMEM; | ||
2957 | } | ||
2958 | } | ||
2959 | |||
2960 | if (gadget_is_superspeed(gadget)) { | ||
2961 | unsigned max_burst; | ||
2962 | 2947 | ||
2963 | /* Calculate bMaxBurst, we know packet size is 1024 */ | 2948 | /* Calculate bMaxBurst, we know packet size is 1024 */ |
2964 | max_burst = min_t(unsigned, FSG_BUFLEN / 1024, 15); | 2949 | max_burst = min_t(unsigned, FSG_BUFLEN / 1024, 15); |
2965 | 2950 | ||
2966 | fsg_ss_bulk_in_desc.bEndpointAddress = | 2951 | fsg_ss_bulk_in_desc.bEndpointAddress = |
2967 | fsg_fs_bulk_in_desc.bEndpointAddress; | 2952 | fsg_fs_bulk_in_desc.bEndpointAddress; |
2968 | fsg_ss_bulk_in_comp_desc.bMaxBurst = max_burst; | 2953 | fsg_ss_bulk_in_comp_desc.bMaxBurst = max_burst; |
2969 | 2954 | ||
2970 | fsg_ss_bulk_out_desc.bEndpointAddress = | 2955 | fsg_ss_bulk_out_desc.bEndpointAddress = |
2971 | fsg_fs_bulk_out_desc.bEndpointAddress; | 2956 | fsg_fs_bulk_out_desc.bEndpointAddress; |
2972 | fsg_ss_bulk_out_comp_desc.bMaxBurst = max_burst; | 2957 | fsg_ss_bulk_out_comp_desc.bMaxBurst = max_burst; |
2973 | 2958 | ||
2974 | f->ss_descriptors = usb_copy_descriptors(fsg_ss_function); | 2959 | ret = usb_assign_descriptors(f, fsg_fs_function, fsg_hs_function, |
2975 | if (unlikely(!f->ss_descriptors)) { | 2960 | fsg_ss_function); |
2976 | usb_free_descriptors(f->hs_descriptors); | 2961 | if (ret) |
2977 | usb_free_descriptors(f->descriptors); | 2962 | goto autoconf_fail; |
2978 | return -ENOMEM; | ||
2979 | } | ||
2980 | } | ||
2981 | 2963 | ||
2982 | return 0; | 2964 | return 0; |
2983 | 2965 | ||
@@ -2986,7 +2968,6 @@ autoconf_fail: | |||
2986 | return -ENOTSUPP; | 2968 | return -ENOTSUPP; |
2987 | } | 2969 | } |
2988 | 2970 | ||
2989 | |||
2990 | /****************************** ADD FUNCTION ******************************/ | 2971 | /****************************** ADD FUNCTION ******************************/ |
2991 | 2972 | ||
2992 | static struct usb_gadget_strings *fsg_strings_array[] = { | 2973 | static struct usb_gadget_strings *fsg_strings_array[] = { |
diff --git a/drivers/usb/gadget/f_midi.c b/drivers/usb/gadget/f_midi.c index b265ee8fa5aa..263e721c2694 100644 --- a/drivers/usb/gadget/f_midi.c +++ b/drivers/usb/gadget/f_midi.c | |||
@@ -414,8 +414,7 @@ static void f_midi_unbind(struct usb_configuration *c, struct usb_function *f) | |||
414 | kfree(midi->id); | 414 | kfree(midi->id); |
415 | midi->id = NULL; | 415 | midi->id = NULL; |
416 | 416 | ||
417 | usb_free_descriptors(f->descriptors); | 417 | usb_free_all_descriptors(f); |
418 | usb_free_descriptors(f->hs_descriptors); | ||
419 | kfree(midi); | 418 | kfree(midi); |
420 | } | 419 | } |
421 | 420 | ||
@@ -882,9 +881,10 @@ f_midi_bind(struct usb_configuration *c, struct usb_function *f) | |||
882 | * both speeds | 881 | * both speeds |
883 | */ | 882 | */ |
884 | /* copy descriptors, and track endpoint copies */ | 883 | /* copy descriptors, and track endpoint copies */ |
885 | f->descriptors = usb_copy_descriptors(midi_function); | 884 | f->fs_descriptors = usb_copy_descriptors(midi_function); |
886 | if (!f->descriptors) | 885 | if (!f->fs_descriptors) |
887 | goto fail_f_midi; | 886 | goto fail_f_midi; |
887 | |||
888 | if (gadget_is_dualspeed(c->cdev->gadget)) { | 888 | if (gadget_is_dualspeed(c->cdev->gadget)) { |
889 | bulk_in_desc.wMaxPacketSize = cpu_to_le16(512); | 889 | bulk_in_desc.wMaxPacketSize = cpu_to_le16(512); |
890 | bulk_out_desc.wMaxPacketSize = cpu_to_le16(512); | 890 | bulk_out_desc.wMaxPacketSize = cpu_to_le16(512); |
diff --git a/drivers/usb/gadget/f_ncm.c b/drivers/usb/gadget/f_ncm.c index 424fc3d1cc36..326d7e6c297c 100644 --- a/drivers/usb/gadget/f_ncm.c +++ b/drivers/usb/gadget/f_ncm.c | |||
@@ -1208,30 +1208,18 @@ ncm_bind(struct usb_configuration *c, struct usb_function *f) | |||
1208 | ncm->notify_req->context = ncm; | 1208 | ncm->notify_req->context = ncm; |
1209 | ncm->notify_req->complete = ncm_notify_complete; | 1209 | ncm->notify_req->complete = ncm_notify_complete; |
1210 | 1210 | ||
1211 | /* copy descriptors, and track endpoint copies */ | ||
1212 | f->descriptors = usb_copy_descriptors(ncm_fs_function); | ||
1213 | if (!f->descriptors) | ||
1214 | goto fail; | ||
1215 | |||
1216 | /* | 1211 | /* |
1217 | * support all relevant hardware speeds... we expect that when | 1212 | * support all relevant hardware speeds... we expect that when |
1218 | * hardware is dual speed, all bulk-capable endpoints work at | 1213 | * hardware is dual speed, all bulk-capable endpoints work at |
1219 | * both speeds | 1214 | * both speeds |
1220 | */ | 1215 | */ |
1221 | if (gadget_is_dualspeed(c->cdev->gadget)) { | 1216 | hs_ncm_in_desc.bEndpointAddress = fs_ncm_in_desc.bEndpointAddress; |
1222 | hs_ncm_in_desc.bEndpointAddress = | 1217 | hs_ncm_out_desc.bEndpointAddress = fs_ncm_out_desc.bEndpointAddress; |
1223 | fs_ncm_in_desc.bEndpointAddress; | 1218 | hs_ncm_notify_desc.bEndpointAddress = |
1224 | hs_ncm_out_desc.bEndpointAddress = | 1219 | fs_ncm_notify_desc.bEndpointAddress; |
1225 | fs_ncm_out_desc.bEndpointAddress; | ||
1226 | hs_ncm_notify_desc.bEndpointAddress = | ||
1227 | fs_ncm_notify_desc.bEndpointAddress; | ||
1228 | |||
1229 | /* copy descriptors, and track endpoint copies */ | ||
1230 | f->hs_descriptors = usb_copy_descriptors(ncm_hs_function); | ||
1231 | if (!f->hs_descriptors) | ||
1232 | goto fail; | ||
1233 | } | ||
1234 | 1220 | ||
1221 | status = usb_assign_descriptors(f, ncm_fs_function, ncm_hs_function, | ||
1222 | NULL); | ||
1235 | /* | 1223 | /* |
1236 | * NOTE: all that is done without knowing or caring about | 1224 | * NOTE: all that is done without knowing or caring about |
1237 | * the network link ... which is unavailable to this code | 1225 | * the network link ... which is unavailable to this code |
@@ -1248,9 +1236,7 @@ ncm_bind(struct usb_configuration *c, struct usb_function *f) | |||
1248 | return 0; | 1236 | return 0; |
1249 | 1237 | ||
1250 | fail: | 1238 | fail: |
1251 | if (f->descriptors) | 1239 | usb_free_all_descriptors(f); |
1252 | usb_free_descriptors(f->descriptors); | ||
1253 | |||
1254 | if (ncm->notify_req) { | 1240 | if (ncm->notify_req) { |
1255 | kfree(ncm->notify_req->buf); | 1241 | kfree(ncm->notify_req->buf); |
1256 | usb_ep_free_request(ncm->notify, ncm->notify_req); | 1242 | usb_ep_free_request(ncm->notify, ncm->notify_req); |
@@ -1276,9 +1262,7 @@ ncm_unbind(struct usb_configuration *c, struct usb_function *f) | |||
1276 | 1262 | ||
1277 | DBG(c->cdev, "ncm unbind\n"); | 1263 | DBG(c->cdev, "ncm unbind\n"); |
1278 | 1264 | ||
1279 | if (gadget_is_dualspeed(c->cdev->gadget)) | 1265 | usb_free_all_descriptors(f); |
1280 | usb_free_descriptors(f->hs_descriptors); | ||
1281 | usb_free_descriptors(f->descriptors); | ||
1282 | 1266 | ||
1283 | kfree(ncm->notify_req->buf); | 1267 | kfree(ncm->notify_req->buf); |
1284 | usb_ep_free_request(ncm->notify, ncm->notify_req); | 1268 | usb_ep_free_request(ncm->notify, ncm->notify_req); |
diff --git a/drivers/usb/gadget/f_obex.c b/drivers/usb/gadget/f_obex.c index 5f400f66aa9b..d74491ad82cb 100644 --- a/drivers/usb/gadget/f_obex.c +++ b/drivers/usb/gadget/f_obex.c | |||
@@ -331,23 +331,19 @@ obex_bind(struct usb_configuration *c, struct usb_function *f) | |||
331 | obex->port.out = ep; | 331 | obex->port.out = ep; |
332 | ep->driver_data = cdev; /* claim */ | 332 | ep->driver_data = cdev; /* claim */ |
333 | 333 | ||
334 | /* copy descriptors, and track endpoint copies */ | ||
335 | f->descriptors = usb_copy_descriptors(fs_function); | ||
336 | |||
337 | /* support all relevant hardware speeds... we expect that when | 334 | /* support all relevant hardware speeds... we expect that when |
338 | * hardware is dual speed, all bulk-capable endpoints work at | 335 | * hardware is dual speed, all bulk-capable endpoints work at |
339 | * both speeds | 336 | * both speeds |
340 | */ | 337 | */ |
341 | if (gadget_is_dualspeed(c->cdev->gadget)) { | ||
342 | 338 | ||
343 | obex_hs_ep_in_desc.bEndpointAddress = | 339 | obex_hs_ep_in_desc.bEndpointAddress = |
344 | obex_fs_ep_in_desc.bEndpointAddress; | 340 | obex_fs_ep_in_desc.bEndpointAddress; |
345 | obex_hs_ep_out_desc.bEndpointAddress = | 341 | obex_hs_ep_out_desc.bEndpointAddress = |
346 | obex_fs_ep_out_desc.bEndpointAddress; | 342 | obex_fs_ep_out_desc.bEndpointAddress; |
347 | 343 | ||
348 | /* copy descriptors, and track endpoint copies */ | 344 | status = usb_assign_descriptors(f, fs_function, hs_function, NULL); |
349 | f->hs_descriptors = usb_copy_descriptors(hs_function); | 345 | if (status) |
350 | } | 346 | goto fail; |
351 | 347 | ||
352 | /* Avoid letting this gadget enumerate until the userspace | 348 | /* Avoid letting this gadget enumerate until the userspace |
353 | * OBEX server is active. | 349 | * OBEX server is active. |
@@ -368,6 +364,7 @@ obex_bind(struct usb_configuration *c, struct usb_function *f) | |||
368 | return 0; | 364 | return 0; |
369 | 365 | ||
370 | fail: | 366 | fail: |
367 | usb_free_all_descriptors(f); | ||
371 | /* we might as well release our claims on endpoints */ | 368 | /* we might as well release our claims on endpoints */ |
372 | if (obex->port.out) | 369 | if (obex->port.out) |
373 | obex->port.out->driver_data = NULL; | 370 | obex->port.out->driver_data = NULL; |
@@ -382,9 +379,7 @@ fail: | |||
382 | static void | 379 | static void |
383 | obex_unbind(struct usb_configuration *c, struct usb_function *f) | 380 | obex_unbind(struct usb_configuration *c, struct usb_function *f) |
384 | { | 381 | { |
385 | if (gadget_is_dualspeed(c->cdev->gadget)) | 382 | usb_free_all_descriptors(f); |
386 | usb_free_descriptors(f->hs_descriptors); | ||
387 | usb_free_descriptors(f->descriptors); | ||
388 | kfree(func_to_obex(f)); | 383 | kfree(func_to_obex(f)); |
389 | } | 384 | } |
390 | 385 | ||
diff --git a/drivers/usb/gadget/f_phonet.c b/drivers/usb/gadget/f_phonet.c index a6c19a486d53..b21ab558b6c0 100644 --- a/drivers/usb/gadget/f_phonet.c +++ b/drivers/usb/gadget/f_phonet.c | |||
@@ -515,14 +515,14 @@ int pn_bind(struct usb_configuration *c, struct usb_function *f) | |||
515 | fp->in_ep = ep; | 515 | fp->in_ep = ep; |
516 | ep->driver_data = fp; /* Claim */ | 516 | ep->driver_data = fp; /* Claim */ |
517 | 517 | ||
518 | pn_hs_sink_desc.bEndpointAddress = | 518 | pn_hs_sink_desc.bEndpointAddress = pn_fs_sink_desc.bEndpointAddress; |
519 | pn_fs_sink_desc.bEndpointAddress; | 519 | pn_hs_source_desc.bEndpointAddress = pn_fs_source_desc.bEndpointAddress; |
520 | pn_hs_source_desc.bEndpointAddress = | ||
521 | pn_fs_source_desc.bEndpointAddress; | ||
522 | 520 | ||
523 | /* Do not try to bind Phonet twice... */ | 521 | /* Do not try to bind Phonet twice... */ |
524 | fp->function.descriptors = fs_pn_function; | 522 | status = usb_assign_descriptors(f, fs_pn_function, hs_pn_function, |
525 | fp->function.hs_descriptors = hs_pn_function; | 523 | NULL); |
524 | if (status) | ||
525 | goto err; | ||
526 | 526 | ||
527 | /* Incoming USB requests */ | 527 | /* Incoming USB requests */ |
528 | status = -ENOMEM; | 528 | status = -ENOMEM; |
@@ -551,7 +551,7 @@ err_req: | |||
551 | for (i = 0; i < phonet_rxq_size && fp->out_reqv[i]; i++) | 551 | for (i = 0; i < phonet_rxq_size && fp->out_reqv[i]; i++) |
552 | usb_ep_free_request(fp->out_ep, fp->out_reqv[i]); | 552 | usb_ep_free_request(fp->out_ep, fp->out_reqv[i]); |
553 | err: | 553 | err: |
554 | 554 | usb_free_all_descriptors(f); | |
555 | if (fp->out_ep) | 555 | if (fp->out_ep) |
556 | fp->out_ep->driver_data = NULL; | 556 | fp->out_ep->driver_data = NULL; |
557 | if (fp->in_ep) | 557 | if (fp->in_ep) |
@@ -573,6 +573,7 @@ pn_unbind(struct usb_configuration *c, struct usb_function *f) | |||
573 | if (fp->out_reqv[i]) | 573 | if (fp->out_reqv[i]) |
574 | usb_ep_free_request(fp->out_ep, fp->out_reqv[i]); | 574 | usb_ep_free_request(fp->out_ep, fp->out_reqv[i]); |
575 | 575 | ||
576 | usb_free_all_descriptors(f); | ||
576 | kfree(fp); | 577 | kfree(fp); |
577 | } | 578 | } |
578 | 579 | ||
diff --git a/drivers/usb/gadget/f_rndis.c b/drivers/usb/gadget/f_rndis.c index 7c27626f0235..e7c25105bd8e 100644 --- a/drivers/usb/gadget/f_rndis.c +++ b/drivers/usb/gadget/f_rndis.c | |||
@@ -722,42 +722,22 @@ rndis_bind(struct usb_configuration *c, struct usb_function *f) | |||
722 | rndis->notify_req->context = rndis; | 722 | rndis->notify_req->context = rndis; |
723 | rndis->notify_req->complete = rndis_response_complete; | 723 | rndis->notify_req->complete = rndis_response_complete; |
724 | 724 | ||
725 | /* copy descriptors, and track endpoint copies */ | ||
726 | f->descriptors = usb_copy_descriptors(eth_fs_function); | ||
727 | if (!f->descriptors) | ||
728 | goto fail; | ||
729 | |||
730 | /* support all relevant hardware speeds... we expect that when | 725 | /* support all relevant hardware speeds... we expect that when |
731 | * hardware is dual speed, all bulk-capable endpoints work at | 726 | * hardware is dual speed, all bulk-capable endpoints work at |
732 | * both speeds | 727 | * both speeds |
733 | */ | 728 | */ |
734 | if (gadget_is_dualspeed(c->cdev->gadget)) { | 729 | hs_in_desc.bEndpointAddress = fs_in_desc.bEndpointAddress; |
735 | hs_in_desc.bEndpointAddress = | 730 | hs_out_desc.bEndpointAddress = fs_out_desc.bEndpointAddress; |
736 | fs_in_desc.bEndpointAddress; | 731 | hs_notify_desc.bEndpointAddress = fs_notify_desc.bEndpointAddress; |
737 | hs_out_desc.bEndpointAddress = | ||
738 | fs_out_desc.bEndpointAddress; | ||
739 | hs_notify_desc.bEndpointAddress = | ||
740 | fs_notify_desc.bEndpointAddress; | ||
741 | |||
742 | /* copy descriptors, and track endpoint copies */ | ||
743 | f->hs_descriptors = usb_copy_descriptors(eth_hs_function); | ||
744 | if (!f->hs_descriptors) | ||
745 | goto fail; | ||
746 | } | ||
747 | 732 | ||
748 | if (gadget_is_superspeed(c->cdev->gadget)) { | 733 | ss_in_desc.bEndpointAddress = fs_in_desc.bEndpointAddress; |
749 | ss_in_desc.bEndpointAddress = | 734 | ss_out_desc.bEndpointAddress = fs_out_desc.bEndpointAddress; |
750 | fs_in_desc.bEndpointAddress; | 735 | ss_notify_desc.bEndpointAddress = fs_notify_desc.bEndpointAddress; |
751 | ss_out_desc.bEndpointAddress = | 736 | |
752 | fs_out_desc.bEndpointAddress; | 737 | status = usb_assign_descriptors(f, eth_fs_function, eth_hs_function, |
753 | ss_notify_desc.bEndpointAddress = | 738 | eth_ss_function); |
754 | fs_notify_desc.bEndpointAddress; | 739 | if (status) |
755 | 740 | goto fail; | |
756 | /* copy descriptors, and track endpoint copies */ | ||
757 | f->ss_descriptors = usb_copy_descriptors(eth_ss_function); | ||
758 | if (!f->ss_descriptors) | ||
759 | goto fail; | ||
760 | } | ||
761 | 741 | ||
762 | rndis->port.open = rndis_open; | 742 | rndis->port.open = rndis_open; |
763 | rndis->port.close = rndis_close; | 743 | rndis->port.close = rndis_close; |
@@ -788,12 +768,7 @@ rndis_bind(struct usb_configuration *c, struct usb_function *f) | |||
788 | return 0; | 768 | return 0; |
789 | 769 | ||
790 | fail: | 770 | fail: |
791 | if (gadget_is_superspeed(c->cdev->gadget) && f->ss_descriptors) | 771 | usb_free_all_descriptors(f); |
792 | usb_free_descriptors(f->ss_descriptors); | ||
793 | if (gadget_is_dualspeed(c->cdev->gadget) && f->hs_descriptors) | ||
794 | usb_free_descriptors(f->hs_descriptors); | ||
795 | if (f->descriptors) | ||
796 | usb_free_descriptors(f->descriptors); | ||
797 | 772 | ||
798 | if (rndis->notify_req) { | 773 | if (rndis->notify_req) { |
799 | kfree(rndis->notify_req->buf); | 774 | kfree(rndis->notify_req->buf); |
@@ -822,11 +797,7 @@ rndis_unbind(struct usb_configuration *c, struct usb_function *f) | |||
822 | rndis_exit(); | 797 | rndis_exit(); |
823 | rndis_string_defs[0].id = 0; | 798 | rndis_string_defs[0].id = 0; |
824 | 799 | ||
825 | if (gadget_is_superspeed(c->cdev->gadget)) | 800 | usb_free_all_descriptors(f); |
826 | usb_free_descriptors(f->ss_descriptors); | ||
827 | if (gadget_is_dualspeed(c->cdev->gadget)) | ||
828 | usb_free_descriptors(f->hs_descriptors); | ||
829 | usb_free_descriptors(f->descriptors); | ||
830 | 801 | ||
831 | kfree(rndis->notify_req->buf); | 802 | kfree(rndis->notify_req->buf); |
832 | usb_ep_free_request(rndis->notify, rndis->notify_req); | 803 | usb_ep_free_request(rndis->notify, rndis->notify_req); |
diff --git a/drivers/usb/gadget/f_serial.c b/drivers/usb/gadget/f_serial.c index 07197d63d9b1..98fa7795df5f 100644 --- a/drivers/usb/gadget/f_serial.c +++ b/drivers/usb/gadget/f_serial.c | |||
@@ -213,34 +213,20 @@ gser_bind(struct usb_configuration *c, struct usb_function *f) | |||
213 | gser->port.out = ep; | 213 | gser->port.out = ep; |
214 | ep->driver_data = cdev; /* claim */ | 214 | ep->driver_data = cdev; /* claim */ |
215 | 215 | ||
216 | /* copy descriptors, and track endpoint copies */ | ||
217 | f->descriptors = usb_copy_descriptors(gser_fs_function); | ||
218 | |||
219 | /* support all relevant hardware speeds... we expect that when | 216 | /* support all relevant hardware speeds... we expect that when |
220 | * hardware is dual speed, all bulk-capable endpoints work at | 217 | * hardware is dual speed, all bulk-capable endpoints work at |
221 | * both speeds | 218 | * both speeds |
222 | */ | 219 | */ |
223 | if (gadget_is_dualspeed(c->cdev->gadget)) { | 220 | gser_hs_in_desc.bEndpointAddress = gser_fs_in_desc.bEndpointAddress; |
224 | gser_hs_in_desc.bEndpointAddress = | 221 | gser_hs_out_desc.bEndpointAddress = gser_fs_out_desc.bEndpointAddress; |
225 | gser_fs_in_desc.bEndpointAddress; | ||
226 | gser_hs_out_desc.bEndpointAddress = | ||
227 | gser_fs_out_desc.bEndpointAddress; | ||
228 | |||
229 | /* copy descriptors, and track endpoint copies */ | ||
230 | f->hs_descriptors = usb_copy_descriptors(gser_hs_function); | ||
231 | } | ||
232 | if (gadget_is_superspeed(c->cdev->gadget)) { | ||
233 | gser_ss_in_desc.bEndpointAddress = | ||
234 | gser_fs_in_desc.bEndpointAddress; | ||
235 | gser_ss_out_desc.bEndpointAddress = | ||
236 | gser_fs_out_desc.bEndpointAddress; | ||
237 | |||
238 | /* copy descriptors, and track endpoint copies */ | ||
239 | f->ss_descriptors = usb_copy_descriptors(gser_ss_function); | ||
240 | if (!f->ss_descriptors) | ||
241 | goto fail; | ||
242 | } | ||
243 | 222 | ||
223 | gser_ss_in_desc.bEndpointAddress = gser_fs_in_desc.bEndpointAddress; | ||
224 | gser_ss_out_desc.bEndpointAddress = gser_fs_out_desc.bEndpointAddress; | ||
225 | |||
226 | status = usb_assign_descriptors(f, gser_fs_function, gser_hs_function, | ||
227 | gser_ss_function); | ||
228 | if (status) | ||
229 | goto fail; | ||
244 | DBG(cdev, "generic ttyGS%d: %s speed IN/%s OUT/%s\n", | 230 | DBG(cdev, "generic ttyGS%d: %s speed IN/%s OUT/%s\n", |
245 | gser->port_num, | 231 | gser->port_num, |
246 | gadget_is_superspeed(c->cdev->gadget) ? "super" : | 232 | gadget_is_superspeed(c->cdev->gadget) ? "super" : |
@@ -263,11 +249,7 @@ fail: | |||
263 | static void | 249 | static void |
264 | gser_unbind(struct usb_configuration *c, struct usb_function *f) | 250 | gser_unbind(struct usb_configuration *c, struct usb_function *f) |
265 | { | 251 | { |
266 | if (gadget_is_dualspeed(c->cdev->gadget)) | 252 | usb_free_all_descriptors(f); |
267 | usb_free_descriptors(f->hs_descriptors); | ||
268 | if (gadget_is_superspeed(c->cdev->gadget)) | ||
269 | usb_free_descriptors(f->ss_descriptors); | ||
270 | usb_free_descriptors(f->descriptors); | ||
271 | kfree(func_to_gser(f)); | 253 | kfree(func_to_gser(f)); |
272 | } | 254 | } |
273 | 255 | ||
diff --git a/drivers/usb/gadget/f_sourcesink.c b/drivers/usb/gadget/f_sourcesink.c index 3c126fde6e7e..102d49beb9df 100644 --- a/drivers/usb/gadget/f_sourcesink.c +++ b/drivers/usb/gadget/f_sourcesink.c | |||
@@ -319,6 +319,7 @@ sourcesink_bind(struct usb_configuration *c, struct usb_function *f) | |||
319 | struct usb_composite_dev *cdev = c->cdev; | 319 | struct usb_composite_dev *cdev = c->cdev; |
320 | struct f_sourcesink *ss = func_to_ss(f); | 320 | struct f_sourcesink *ss = func_to_ss(f); |
321 | int id; | 321 | int id; |
322 | int ret; | ||
322 | 323 | ||
323 | /* allocate interface ID(s) */ | 324 | /* allocate interface ID(s) */ |
324 | id = usb_interface_id(c, f); | 325 | id = usb_interface_id(c, f); |
@@ -387,64 +388,57 @@ no_iso: | |||
387 | isoc_maxpacket = 1024; | 388 | isoc_maxpacket = 1024; |
388 | 389 | ||
389 | /* support high speed hardware */ | 390 | /* support high speed hardware */ |
390 | if (gadget_is_dualspeed(c->cdev->gadget)) { | 391 | hs_source_desc.bEndpointAddress = fs_source_desc.bEndpointAddress; |
391 | hs_source_desc.bEndpointAddress = | 392 | hs_sink_desc.bEndpointAddress = fs_sink_desc.bEndpointAddress; |
392 | fs_source_desc.bEndpointAddress; | ||
393 | hs_sink_desc.bEndpointAddress = | ||
394 | fs_sink_desc.bEndpointAddress; | ||
395 | 393 | ||
396 | /* | 394 | /* |
397 | * Fill in the HS isoc descriptors from the module parameters. | 395 | * Fill in the HS isoc descriptors from the module parameters. |
398 | * We assume that the user knows what they are doing and won't | 396 | * We assume that the user knows what they are doing and won't |
399 | * give parameters that their UDC doesn't support. | 397 | * give parameters that their UDC doesn't support. |
400 | */ | 398 | */ |
401 | hs_iso_source_desc.wMaxPacketSize = isoc_maxpacket; | 399 | hs_iso_source_desc.wMaxPacketSize = isoc_maxpacket; |
402 | hs_iso_source_desc.wMaxPacketSize |= isoc_mult << 11; | 400 | hs_iso_source_desc.wMaxPacketSize |= isoc_mult << 11; |
403 | hs_iso_source_desc.bInterval = isoc_interval; | 401 | hs_iso_source_desc.bInterval = isoc_interval; |
404 | hs_iso_source_desc.bEndpointAddress = | 402 | hs_iso_source_desc.bEndpointAddress = |
405 | fs_iso_source_desc.bEndpointAddress; | 403 | fs_iso_source_desc.bEndpointAddress; |
406 | 404 | ||
407 | hs_iso_sink_desc.wMaxPacketSize = isoc_maxpacket; | 405 | hs_iso_sink_desc.wMaxPacketSize = isoc_maxpacket; |
408 | hs_iso_sink_desc.wMaxPacketSize |= isoc_mult << 11; | 406 | hs_iso_sink_desc.wMaxPacketSize |= isoc_mult << 11; |
409 | hs_iso_sink_desc.bInterval = isoc_interval; | 407 | hs_iso_sink_desc.bInterval = isoc_interval; |
410 | hs_iso_sink_desc.bEndpointAddress = | 408 | hs_iso_sink_desc.bEndpointAddress = fs_iso_sink_desc.bEndpointAddress; |
411 | fs_iso_sink_desc.bEndpointAddress; | ||
412 | |||
413 | f->hs_descriptors = hs_source_sink_descs; | ||
414 | } | ||
415 | 409 | ||
416 | /* support super speed hardware */ | 410 | /* support super speed hardware */ |
417 | if (gadget_is_superspeed(c->cdev->gadget)) { | 411 | ss_source_desc.bEndpointAddress = |
418 | ss_source_desc.bEndpointAddress = | 412 | fs_source_desc.bEndpointAddress; |
419 | fs_source_desc.bEndpointAddress; | 413 | ss_sink_desc.bEndpointAddress = |
420 | ss_sink_desc.bEndpointAddress = | 414 | fs_sink_desc.bEndpointAddress; |
421 | fs_sink_desc.bEndpointAddress; | ||
422 | 415 | ||
423 | /* | 416 | /* |
424 | * Fill in the SS isoc descriptors from the module parameters. | 417 | * Fill in the SS isoc descriptors from the module parameters. |
425 | * We assume that the user knows what they are doing and won't | 418 | * We assume that the user knows what they are doing and won't |
426 | * give parameters that their UDC doesn't support. | 419 | * give parameters that their UDC doesn't support. |
427 | */ | 420 | */ |
428 | ss_iso_source_desc.wMaxPacketSize = isoc_maxpacket; | 421 | ss_iso_source_desc.wMaxPacketSize = isoc_maxpacket; |
429 | ss_iso_source_desc.bInterval = isoc_interval; | 422 | ss_iso_source_desc.bInterval = isoc_interval; |
430 | ss_iso_source_comp_desc.bmAttributes = isoc_mult; | 423 | ss_iso_source_comp_desc.bmAttributes = isoc_mult; |
431 | ss_iso_source_comp_desc.bMaxBurst = isoc_maxburst; | 424 | ss_iso_source_comp_desc.bMaxBurst = isoc_maxburst; |
432 | ss_iso_source_comp_desc.wBytesPerInterval = | 425 | ss_iso_source_comp_desc.wBytesPerInterval = |
433 | isoc_maxpacket * (isoc_mult + 1) * (isoc_maxburst + 1); | 426 | isoc_maxpacket * (isoc_mult + 1) * (isoc_maxburst + 1); |
434 | ss_iso_source_desc.bEndpointAddress = | 427 | ss_iso_source_desc.bEndpointAddress = |
435 | fs_iso_source_desc.bEndpointAddress; | 428 | fs_iso_source_desc.bEndpointAddress; |
436 | 429 | ||
437 | ss_iso_sink_desc.wMaxPacketSize = isoc_maxpacket; | 430 | ss_iso_sink_desc.wMaxPacketSize = isoc_maxpacket; |
438 | ss_iso_sink_desc.bInterval = isoc_interval; | 431 | ss_iso_sink_desc.bInterval = isoc_interval; |
439 | ss_iso_sink_comp_desc.bmAttributes = isoc_mult; | 432 | ss_iso_sink_comp_desc.bmAttributes = isoc_mult; |
440 | ss_iso_sink_comp_desc.bMaxBurst = isoc_maxburst; | 433 | ss_iso_sink_comp_desc.bMaxBurst = isoc_maxburst; |
441 | ss_iso_sink_comp_desc.wBytesPerInterval = | 434 | ss_iso_sink_comp_desc.wBytesPerInterval = |
442 | isoc_maxpacket * (isoc_mult + 1) * (isoc_maxburst + 1); | 435 | isoc_maxpacket * (isoc_mult + 1) * (isoc_maxburst + 1); |
443 | ss_iso_sink_desc.bEndpointAddress = | 436 | ss_iso_sink_desc.bEndpointAddress = fs_iso_sink_desc.bEndpointAddress; |
444 | fs_iso_sink_desc.bEndpointAddress; | 437 | |
445 | 438 | ret = usb_assign_descriptors(f, fs_source_sink_descs, | |
446 | f->ss_descriptors = ss_source_sink_descs; | 439 | hs_source_sink_descs, ss_source_sink_descs); |
447 | } | 440 | if (ret) |
441 | return ret; | ||
448 | 442 | ||
449 | DBG(cdev, "%s speed %s: IN/%s, OUT/%s, ISO-IN/%s, ISO-OUT/%s\n", | 443 | DBG(cdev, "%s speed %s: IN/%s, OUT/%s, ISO-IN/%s, ISO-OUT/%s\n", |
450 | (gadget_is_superspeed(c->cdev->gadget) ? "super" : | 444 | (gadget_is_superspeed(c->cdev->gadget) ? "super" : |
@@ -458,6 +452,7 @@ no_iso: | |||
458 | static void | 452 | static void |
459 | sourcesink_unbind(struct usb_configuration *c, struct usb_function *f) | 453 | sourcesink_unbind(struct usb_configuration *c, struct usb_function *f) |
460 | { | 454 | { |
455 | usb_free_all_descriptors(f); | ||
461 | kfree(func_to_ss(f)); | 456 | kfree(func_to_ss(f)); |
462 | } | 457 | } |
463 | 458 | ||
@@ -773,7 +768,6 @@ static int __init sourcesink_bind_config(struct usb_configuration *c) | |||
773 | return -ENOMEM; | 768 | return -ENOMEM; |
774 | 769 | ||
775 | ss->function.name = "source/sink"; | 770 | ss->function.name = "source/sink"; |
776 | ss->function.descriptors = fs_source_sink_descs; | ||
777 | ss->function.bind = sourcesink_bind; | 771 | ss->function.bind = sourcesink_bind; |
778 | ss->function.unbind = sourcesink_unbind; | 772 | ss->function.unbind = sourcesink_unbind; |
779 | ss->function.set_alt = sourcesink_set_alt; | 773 | ss->function.set_alt = sourcesink_set_alt; |
diff --git a/drivers/usb/gadget/f_subset.c b/drivers/usb/gadget/f_subset.c index deb437c3b53e..856dbae586f1 100644 --- a/drivers/usb/gadget/f_subset.c +++ b/drivers/usb/gadget/f_subset.c | |||
@@ -319,38 +319,22 @@ geth_bind(struct usb_configuration *c, struct usb_function *f) | |||
319 | geth->port.out_ep = ep; | 319 | geth->port.out_ep = ep; |
320 | ep->driver_data = cdev; /* claim */ | 320 | ep->driver_data = cdev; /* claim */ |
321 | 321 | ||
322 | /* copy descriptors, and track endpoint copies */ | ||
323 | f->descriptors = usb_copy_descriptors(fs_eth_function); | ||
324 | if (!f->descriptors) | ||
325 | goto fail; | ||
326 | |||
327 | /* support all relevant hardware speeds... we expect that when | 322 | /* support all relevant hardware speeds... we expect that when |
328 | * hardware is dual speed, all bulk-capable endpoints work at | 323 | * hardware is dual speed, all bulk-capable endpoints work at |
329 | * both speeds | 324 | * both speeds |
330 | */ | 325 | */ |
331 | if (gadget_is_dualspeed(c->cdev->gadget)) { | 326 | hs_subset_in_desc.bEndpointAddress = fs_subset_in_desc.bEndpointAddress; |
332 | hs_subset_in_desc.bEndpointAddress = | 327 | hs_subset_out_desc.bEndpointAddress = |
333 | fs_subset_in_desc.bEndpointAddress; | 328 | fs_subset_out_desc.bEndpointAddress; |
334 | hs_subset_out_desc.bEndpointAddress = | ||
335 | fs_subset_out_desc.bEndpointAddress; | ||
336 | |||
337 | /* copy descriptors, and track endpoint copies */ | ||
338 | f->hs_descriptors = usb_copy_descriptors(hs_eth_function); | ||
339 | if (!f->hs_descriptors) | ||
340 | goto fail; | ||
341 | } | ||
342 | 329 | ||
343 | if (gadget_is_superspeed(c->cdev->gadget)) { | 330 | ss_subset_in_desc.bEndpointAddress = fs_subset_in_desc.bEndpointAddress; |
344 | ss_subset_in_desc.bEndpointAddress = | 331 | ss_subset_out_desc.bEndpointAddress = |
345 | fs_subset_in_desc.bEndpointAddress; | 332 | fs_subset_out_desc.bEndpointAddress; |
346 | ss_subset_out_desc.bEndpointAddress = | ||
347 | fs_subset_out_desc.bEndpointAddress; | ||
348 | 333 | ||
349 | /* copy descriptors, and track endpoint copies */ | 334 | status = usb_assign_descriptors(f, fs_eth_function, hs_eth_function, |
350 | f->ss_descriptors = usb_copy_descriptors(ss_eth_function); | 335 | ss_eth_function); |
351 | if (!f->ss_descriptors) | 336 | if (status) |
352 | goto fail; | 337 | goto fail; |
353 | } | ||
354 | 338 | ||
355 | /* NOTE: all that is done without knowing or caring about | 339 | /* NOTE: all that is done without knowing or caring about |
356 | * the network link ... which is unavailable to this code | 340 | * the network link ... which is unavailable to this code |
@@ -364,11 +348,7 @@ geth_bind(struct usb_configuration *c, struct usb_function *f) | |||
364 | return 0; | 348 | return 0; |
365 | 349 | ||
366 | fail: | 350 | fail: |
367 | if (f->descriptors) | 351 | usb_free_all_descriptors(f); |
368 | usb_free_descriptors(f->descriptors); | ||
369 | if (f->hs_descriptors) | ||
370 | usb_free_descriptors(f->hs_descriptors); | ||
371 | |||
372 | /* we might as well release our claims on endpoints */ | 352 | /* we might as well release our claims on endpoints */ |
373 | if (geth->port.out_ep) | 353 | if (geth->port.out_ep) |
374 | geth->port.out_ep->driver_data = NULL; | 354 | geth->port.out_ep->driver_data = NULL; |
@@ -383,11 +363,7 @@ fail: | |||
383 | static void | 363 | static void |
384 | geth_unbind(struct usb_configuration *c, struct usb_function *f) | 364 | geth_unbind(struct usb_configuration *c, struct usb_function *f) |
385 | { | 365 | { |
386 | if (gadget_is_superspeed(c->cdev->gadget)) | 366 | usb_free_all_descriptors(f); |
387 | usb_free_descriptors(f->ss_descriptors); | ||
388 | if (gadget_is_dualspeed(c->cdev->gadget)) | ||
389 | usb_free_descriptors(f->hs_descriptors); | ||
390 | usb_free_descriptors(f->descriptors); | ||
391 | geth_string_defs[1].s = NULL; | 367 | geth_string_defs[1].s = NULL; |
392 | kfree(func_to_geth(f)); | 368 | kfree(func_to_geth(f)); |
393 | } | 369 | } |
diff --git a/drivers/usb/gadget/f_uac1.c b/drivers/usb/gadget/f_uac1.c index c8ed41ba1042..f570e667a640 100644 --- a/drivers/usb/gadget/f_uac1.c +++ b/drivers/usb/gadget/f_uac1.c | |||
@@ -630,7 +630,7 @@ f_audio_bind(struct usb_configuration *c, struct usb_function *f) | |||
630 | struct usb_composite_dev *cdev = c->cdev; | 630 | struct usb_composite_dev *cdev = c->cdev; |
631 | struct f_audio *audio = func_to_audio(f); | 631 | struct f_audio *audio = func_to_audio(f); |
632 | int status; | 632 | int status; |
633 | struct usb_ep *ep; | 633 | struct usb_ep *ep = NULL; |
634 | 634 | ||
635 | f_audio_build_desc(audio); | 635 | f_audio_build_desc(audio); |
636 | 636 | ||
@@ -659,21 +659,14 @@ f_audio_bind(struct usb_configuration *c, struct usb_function *f) | |||
659 | status = -ENOMEM; | 659 | status = -ENOMEM; |
660 | 660 | ||
661 | /* copy descriptors, and track endpoint copies */ | 661 | /* copy descriptors, and track endpoint copies */ |
662 | f->descriptors = usb_copy_descriptors(f_audio_desc); | 662 | status = usb_assign_descriptors(f, f_audio_desc, f_audio_desc, NULL); |
663 | 663 | if (status) | |
664 | /* | 664 | goto fail; |
665 | * support all relevant hardware speeds... we expect that when | ||
666 | * hardware is dual speed, all bulk-capable endpoints work at | ||
667 | * both speeds | ||
668 | */ | ||
669 | if (gadget_is_dualspeed(c->cdev->gadget)) { | ||
670 | f->hs_descriptors = usb_copy_descriptors(f_audio_desc); | ||
671 | } | ||
672 | |||
673 | return 0; | 665 | return 0; |
674 | 666 | ||
675 | fail: | 667 | fail: |
676 | 668 | if (ep) | |
669 | ep->driver_data = NULL; | ||
677 | return status; | 670 | return status; |
678 | } | 671 | } |
679 | 672 | ||
@@ -682,8 +675,7 @@ f_audio_unbind(struct usb_configuration *c, struct usb_function *f) | |||
682 | { | 675 | { |
683 | struct f_audio *audio = func_to_audio(f); | 676 | struct f_audio *audio = func_to_audio(f); |
684 | 677 | ||
685 | usb_free_descriptors(f->descriptors); | 678 | usb_free_all_descriptors(f); |
686 | usb_free_descriptors(f->hs_descriptors); | ||
687 | kfree(audio); | 679 | kfree(audio); |
688 | } | 680 | } |
689 | 681 | ||
diff --git a/drivers/usb/gadget/f_uac2.c b/drivers/usb/gadget/f_uac2.c index f02b8ece5287..730a260e1841 100644 --- a/drivers/usb/gadget/f_uac2.c +++ b/drivers/usb/gadget/f_uac2.c | |||
@@ -998,9 +998,9 @@ afunc_bind(struct usb_configuration *cfg, struct usb_function *fn) | |||
998 | hs_epin_desc.bEndpointAddress = fs_epin_desc.bEndpointAddress; | 998 | hs_epin_desc.bEndpointAddress = fs_epin_desc.bEndpointAddress; |
999 | hs_epin_desc.wMaxPacketSize = fs_epin_desc.wMaxPacketSize; | 999 | hs_epin_desc.wMaxPacketSize = fs_epin_desc.wMaxPacketSize; |
1000 | 1000 | ||
1001 | fn->descriptors = usb_copy_descriptors(fs_audio_desc); | 1001 | ret = usb_assign_descriptors(fn, fs_audio_desc, hs_audio_desc, NULL); |
1002 | if (gadget_is_dualspeed(gadget)) | 1002 | if (ret) |
1003 | fn->hs_descriptors = usb_copy_descriptors(hs_audio_desc); | 1003 | goto err; |
1004 | 1004 | ||
1005 | prm = &agdev->uac2.c_prm; | 1005 | prm = &agdev->uac2.c_prm; |
1006 | prm->max_psize = hs_epout_desc.wMaxPacketSize; | 1006 | prm->max_psize = hs_epout_desc.wMaxPacketSize; |
@@ -1029,8 +1029,7 @@ afunc_bind(struct usb_configuration *cfg, struct usb_function *fn) | |||
1029 | err: | 1029 | err: |
1030 | kfree(agdev->uac2.p_prm.rbuf); | 1030 | kfree(agdev->uac2.p_prm.rbuf); |
1031 | kfree(agdev->uac2.c_prm.rbuf); | 1031 | kfree(agdev->uac2.c_prm.rbuf); |
1032 | usb_free_descriptors(fn->hs_descriptors); | 1032 | usb_free_all_descriptors(fn); |
1033 | usb_free_descriptors(fn->descriptors); | ||
1034 | if (agdev->in_ep) | 1033 | if (agdev->in_ep) |
1035 | agdev->in_ep->driver_data = NULL; | 1034 | agdev->in_ep->driver_data = NULL; |
1036 | if (agdev->out_ep) | 1035 | if (agdev->out_ep) |
@@ -1042,8 +1041,6 @@ static void | |||
1042 | afunc_unbind(struct usb_configuration *cfg, struct usb_function *fn) | 1041 | afunc_unbind(struct usb_configuration *cfg, struct usb_function *fn) |
1043 | { | 1042 | { |
1044 | struct audio_dev *agdev = func_to_agdev(fn); | 1043 | struct audio_dev *agdev = func_to_agdev(fn); |
1045 | struct usb_composite_dev *cdev = cfg->cdev; | ||
1046 | struct usb_gadget *gadget = cdev->gadget; | ||
1047 | struct uac2_rtd_params *prm; | 1044 | struct uac2_rtd_params *prm; |
1048 | 1045 | ||
1049 | alsa_uac2_exit(agdev); | 1046 | alsa_uac2_exit(agdev); |
@@ -1053,10 +1050,7 @@ afunc_unbind(struct usb_configuration *cfg, struct usb_function *fn) | |||
1053 | 1050 | ||
1054 | prm = &agdev->uac2.c_prm; | 1051 | prm = &agdev->uac2.c_prm; |
1055 | kfree(prm->rbuf); | 1052 | kfree(prm->rbuf); |
1056 | 1053 | usb_free_all_descriptors(fn); | |
1057 | if (gadget_is_dualspeed(gadget)) | ||
1058 | usb_free_descriptors(fn->hs_descriptors); | ||
1059 | usb_free_descriptors(fn->descriptors); | ||
1060 | 1054 | ||
1061 | if (agdev->in_ep) | 1055 | if (agdev->in_ep) |
1062 | agdev->in_ep->driver_data = NULL; | 1056 | agdev->in_ep->driver_data = NULL; |
diff --git a/drivers/usb/gadget/f_uvc.c b/drivers/usb/gadget/f_uvc.c index 10f13c1213c7..28ff2546a5b3 100644 --- a/drivers/usb/gadget/f_uvc.c +++ b/drivers/usb/gadget/f_uvc.c | |||
@@ -583,9 +583,7 @@ uvc_function_unbind(struct usb_configuration *c, struct usb_function *f) | |||
583 | usb_ep_free_request(cdev->gadget->ep0, uvc->control_req); | 583 | usb_ep_free_request(cdev->gadget->ep0, uvc->control_req); |
584 | kfree(uvc->control_buf); | 584 | kfree(uvc->control_buf); |
585 | 585 | ||
586 | kfree(f->descriptors); | 586 | usb_free_all_descriptors(f); |
587 | kfree(f->hs_descriptors); | ||
588 | kfree(f->ss_descriptors); | ||
589 | 587 | ||
590 | kfree(uvc); | 588 | kfree(uvc); |
591 | } | 589 | } |
@@ -651,49 +649,40 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f) | |||
651 | /* sanity check the streaming endpoint module parameters */ | 649 | /* sanity check the streaming endpoint module parameters */ |
652 | if (streaming_maxpacket > 1024) | 650 | if (streaming_maxpacket > 1024) |
653 | streaming_maxpacket = 1024; | 651 | streaming_maxpacket = 1024; |
652 | /* | ||
653 | * Fill in the HS descriptors from the module parameters for the Video | ||
654 | * Streaming endpoint. | ||
655 | * NOTE: We assume that the user knows what they are doing and won't | ||
656 | * give parameters that their UDC doesn't support. | ||
657 | */ | ||
658 | uvc_hs_streaming_ep.wMaxPacketSize = streaming_maxpacket; | ||
659 | uvc_hs_streaming_ep.wMaxPacketSize |= streaming_mult << 11; | ||
660 | uvc_hs_streaming_ep.bInterval = streaming_interval; | ||
661 | uvc_hs_streaming_ep.bEndpointAddress = | ||
662 | uvc_fs_streaming_ep.bEndpointAddress; | ||
654 | 663 | ||
655 | /* Copy descriptors for FS. */ | 664 | /* |
656 | f->descriptors = uvc_copy_descriptors(uvc, USB_SPEED_FULL); | 665 | * Fill in the SS descriptors from the module parameters for the Video |
657 | 666 | * Streaming endpoint. | |
658 | /* support high speed hardware */ | 667 | * NOTE: We assume that the user knows what they are doing and won't |
659 | if (gadget_is_dualspeed(cdev->gadget)) { | 668 | * give parameters that their UDC doesn't support. |
660 | /* | 669 | */ |
661 | * Fill in the HS descriptors from the module parameters for the | 670 | uvc_ss_streaming_ep.wMaxPacketSize = streaming_maxpacket; |
662 | * Video Streaming endpoint. | 671 | uvc_ss_streaming_ep.bInterval = streaming_interval; |
663 | * NOTE: We assume that the user knows what they are doing and | 672 | uvc_ss_streaming_comp.bmAttributes = streaming_mult; |
664 | * won't give parameters that their UDC doesn't support. | 673 | uvc_ss_streaming_comp.bMaxBurst = streaming_maxburst; |
665 | */ | 674 | uvc_ss_streaming_comp.wBytesPerInterval = |
666 | uvc_hs_streaming_ep.wMaxPacketSize = streaming_maxpacket; | 675 | streaming_maxpacket * (streaming_mult + 1) * |
667 | uvc_hs_streaming_ep.wMaxPacketSize |= streaming_mult << 11; | 676 | (streaming_maxburst + 1); |
668 | uvc_hs_streaming_ep.bInterval = streaming_interval; | 677 | uvc_ss_streaming_ep.bEndpointAddress = |
669 | uvc_hs_streaming_ep.bEndpointAddress = | 678 | uvc_fs_streaming_ep.bEndpointAddress; |
670 | uvc_fs_streaming_ep.bEndpointAddress; | ||
671 | |||
672 | /* Copy descriptors. */ | ||
673 | f->hs_descriptors = uvc_copy_descriptors(uvc, USB_SPEED_HIGH); | ||
674 | } | ||
675 | 679 | ||
676 | /* support super speed hardware */ | 680 | /* Copy descriptors */ |
677 | if (gadget_is_superspeed(c->cdev->gadget)) { | 681 | f->fs_descriptors = uvc_copy_descriptors(uvc, USB_SPEED_FULL); |
678 | /* | 682 | if (gadget_is_dualspeed(cdev->gadget)) |
679 | * Fill in the SS descriptors from the module parameters for the | 683 | f->hs_descriptors = uvc_copy_descriptors(uvc, USB_SPEED_HIGH); |
680 | * Video Streaming endpoint. | 684 | if (gadget_is_superspeed(c->cdev->gadget)) |
681 | * NOTE: We assume that the user knows what they are doing and | ||
682 | * won't give parameters that their UDC doesn't support. | ||
683 | */ | ||
684 | uvc_ss_streaming_ep.wMaxPacketSize = streaming_maxpacket; | ||
685 | uvc_ss_streaming_ep.bInterval = streaming_interval; | ||
686 | uvc_ss_streaming_comp.bmAttributes = streaming_mult; | ||
687 | uvc_ss_streaming_comp.bMaxBurst = streaming_maxburst; | ||
688 | uvc_ss_streaming_comp.wBytesPerInterval = | ||
689 | streaming_maxpacket * (streaming_mult + 1) * | ||
690 | (streaming_maxburst + 1); | ||
691 | uvc_ss_streaming_ep.bEndpointAddress = | ||
692 | uvc_fs_streaming_ep.bEndpointAddress; | ||
693 | |||
694 | /* Copy descriptors. */ | ||
695 | f->ss_descriptors = uvc_copy_descriptors(uvc, USB_SPEED_SUPER); | 685 | f->ss_descriptors = uvc_copy_descriptors(uvc, USB_SPEED_SUPER); |
696 | } | ||
697 | 686 | ||
698 | /* Preallocate control endpoint request. */ | 687 | /* Preallocate control endpoint request. */ |
699 | uvc->control_req = usb_ep_alloc_request(cdev->gadget->ep0, GFP_KERNEL); | 688 | uvc->control_req = usb_ep_alloc_request(cdev->gadget->ep0, GFP_KERNEL); |
@@ -741,9 +730,7 @@ error: | |||
741 | kfree(uvc->control_buf); | 730 | kfree(uvc->control_buf); |
742 | } | 731 | } |
743 | 732 | ||
744 | kfree(f->descriptors); | 733 | usb_free_all_descriptors(f); |
745 | kfree(f->hs_descriptors); | ||
746 | kfree(f->ss_descriptors); | ||
747 | return ret; | 734 | return ret; |
748 | } | 735 | } |
749 | 736 | ||
diff --git a/drivers/usb/gadget/printer.c b/drivers/usb/gadget/printer.c index e156e3f26727..35bcc83d1e04 100644 --- a/drivers/usb/gadget/printer.c +++ b/drivers/usb/gadget/printer.c | |||
@@ -983,8 +983,10 @@ static int __init printer_func_bind(struct usb_configuration *c, | |||
983 | { | 983 | { |
984 | struct printer_dev *dev = container_of(f, struct printer_dev, function); | 984 | struct printer_dev *dev = container_of(f, struct printer_dev, function); |
985 | struct usb_composite_dev *cdev = c->cdev; | 985 | struct usb_composite_dev *cdev = c->cdev; |
986 | struct usb_ep *in_ep, *out_ep; | 986 | struct usb_ep *in_ep; |
987 | struct usb_ep *out_ep = NULL; | ||
987 | int id; | 988 | int id; |
989 | int ret; | ||
988 | 990 | ||
989 | id = usb_interface_id(c, f); | 991 | id = usb_interface_id(c, f); |
990 | if (id < 0) | 992 | if (id < 0) |
@@ -1010,6 +1012,11 @@ autoconf_fail: | |||
1010 | hs_ep_in_desc.bEndpointAddress = fs_ep_in_desc.bEndpointAddress; | 1012 | hs_ep_in_desc.bEndpointAddress = fs_ep_in_desc.bEndpointAddress; |
1011 | hs_ep_out_desc.bEndpointAddress = fs_ep_out_desc.bEndpointAddress; | 1013 | hs_ep_out_desc.bEndpointAddress = fs_ep_out_desc.bEndpointAddress; |
1012 | 1014 | ||
1015 | ret = usb_assign_descriptors(f, fs_printer_function, | ||
1016 | hs_printer_function, NULL); | ||
1017 | if (ret) | ||
1018 | return ret; | ||
1019 | |||
1013 | dev->in_ep = in_ep; | 1020 | dev->in_ep = in_ep; |
1014 | dev->out_ep = out_ep; | 1021 | dev->out_ep = out_ep; |
1015 | return 0; | 1022 | return 0; |
@@ -1018,6 +1025,7 @@ autoconf_fail: | |||
1018 | static void printer_func_unbind(struct usb_configuration *c, | 1025 | static void printer_func_unbind(struct usb_configuration *c, |
1019 | struct usb_function *f) | 1026 | struct usb_function *f) |
1020 | { | 1027 | { |
1028 | usb_free_all_descriptors(f); | ||
1021 | } | 1029 | } |
1022 | 1030 | ||
1023 | static int printer_func_set_alt(struct usb_function *f, | 1031 | static int printer_func_set_alt(struct usb_function *f, |
@@ -1110,8 +1118,6 @@ static int __init printer_bind_config(struct usb_configuration *c) | |||
1110 | dev = &usb_printer_gadget; | 1118 | dev = &usb_printer_gadget; |
1111 | 1119 | ||
1112 | dev->function.name = shortname; | 1120 | dev->function.name = shortname; |
1113 | dev->function.descriptors = fs_printer_function; | ||
1114 | dev->function.hs_descriptors = hs_printer_function; | ||
1115 | dev->function.bind = printer_func_bind; | 1121 | dev->function.bind = printer_func_bind; |
1116 | dev->function.setup = printer_func_setup; | 1122 | dev->function.setup = printer_func_setup; |
1117 | dev->function.unbind = printer_func_unbind; | 1123 | dev->function.unbind = printer_func_unbind; |
diff --git a/drivers/usb/gadget/tcm_usb_gadget.c b/drivers/usb/gadget/tcm_usb_gadget.c index 49596096b435..27a2337f9868 100644 --- a/drivers/usb/gadget/tcm_usb_gadget.c +++ b/drivers/usb/gadget/tcm_usb_gadget.c | |||
@@ -2240,6 +2240,7 @@ static int usbg_bind(struct usb_configuration *c, struct usb_function *f) | |||
2240 | struct usb_gadget *gadget = c->cdev->gadget; | 2240 | struct usb_gadget *gadget = c->cdev->gadget; |
2241 | struct usb_ep *ep; | 2241 | struct usb_ep *ep; |
2242 | int iface; | 2242 | int iface; |
2243 | int ret; | ||
2243 | 2244 | ||
2244 | iface = usb_interface_id(c, f); | 2245 | iface = usb_interface_id(c, f); |
2245 | if (iface < 0) | 2246 | if (iface < 0) |
@@ -2290,6 +2291,11 @@ static int usbg_bind(struct usb_configuration *c, struct usb_function *f) | |||
2290 | uasp_ss_status_desc.bEndpointAddress; | 2291 | uasp_ss_status_desc.bEndpointAddress; |
2291 | uasp_fs_cmd_desc.bEndpointAddress = uasp_ss_cmd_desc.bEndpointAddress; | 2292 | uasp_fs_cmd_desc.bEndpointAddress = uasp_ss_cmd_desc.bEndpointAddress; |
2292 | 2293 | ||
2294 | ret = usb_assign_descriptors(f, uasp_fs_function_desc, | ||
2295 | uasp_hs_function_desc, uasp_ss_function_desc); | ||
2296 | if (ret) | ||
2297 | goto ep_fail; | ||
2298 | |||
2293 | return 0; | 2299 | return 0; |
2294 | ep_fail: | 2300 | ep_fail: |
2295 | pr_err("Can't claim all required eps\n"); | 2301 | pr_err("Can't claim all required eps\n"); |
@@ -2305,6 +2311,7 @@ static void usbg_unbind(struct usb_configuration *c, struct usb_function *f) | |||
2305 | { | 2311 | { |
2306 | struct f_uas *fu = to_f_uas(f); | 2312 | struct f_uas *fu = to_f_uas(f); |
2307 | 2313 | ||
2314 | usb_free_all_descriptors(f); | ||
2308 | kfree(fu); | 2315 | kfree(fu); |
2309 | } | 2316 | } |
2310 | 2317 | ||
@@ -2385,9 +2392,6 @@ static int usbg_cfg_bind(struct usb_configuration *c) | |||
2385 | if (!fu) | 2392 | if (!fu) |
2386 | return -ENOMEM; | 2393 | return -ENOMEM; |
2387 | fu->function.name = "Target Function"; | 2394 | fu->function.name = "Target Function"; |
2388 | fu->function.descriptors = uasp_fs_function_desc; | ||
2389 | fu->function.hs_descriptors = uasp_hs_function_desc; | ||
2390 | fu->function.ss_descriptors = uasp_ss_function_desc; | ||
2391 | fu->function.bind = usbg_bind; | 2395 | fu->function.bind = usbg_bind; |
2392 | fu->function.unbind = usbg_unbind; | 2396 | fu->function.unbind = usbg_unbind; |
2393 | fu->function.set_alt = usbg_set_alt; | 2397 | fu->function.set_alt = usbg_set_alt; |