diff options
author | Tatyana Brokhman <tlinder@codeaurora.org> | 2011-06-28 09:33:50 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2011-06-28 14:14:37 -0400 |
commit | ea2a1df7b2b1de839a72217d85bfb4b7b049010c (patch) | |
tree | 89c10a2a18bba8a1d448b8b1f1281cf52b2287c6 | |
parent | 48767a4e8263620c347c3fa17812c943dd0fc2fa (diff) |
usb: gadget: use config_ep_by_speed() instead of ep_choose()
Remove obsolete functions:
1. ep_choose()
2. usb_find_endpoint()
Signed-off-by: Tatyana Brokhman <tlinder@codeaurora.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | drivers/usb/gadget/config.c | 25 | ||||
-rw-r--r-- | drivers/usb/gadget/f_acm.c | 47 | ||||
-rw-r--r-- | drivers/usb/gadget/f_ecm.c | 45 | ||||
-rw-r--r-- | drivers/usb/gadget/f_eem.c | 32 | ||||
-rw-r--r-- | drivers/usb/gadget/f_hid.c | 19 | ||||
-rw-r--r-- | drivers/usb/gadget/f_loopback.c | 11 | ||||
-rw-r--r-- | drivers/usb/gadget/f_mass_storage.c | 34 | ||||
-rw-r--r-- | drivers/usb/gadget/f_ncm.c | 49 | ||||
-rw-r--r-- | drivers/usb/gadget/f_obex.c | 32 | ||||
-rw-r--r-- | drivers/usb/gadget/f_phonet.c | 12 | ||||
-rw-r--r-- | drivers/usb/gadget/f_rndis.c | 45 | ||||
-rw-r--r-- | drivers/usb/gadget/f_serial.c | 32 | ||||
-rw-r--r-- | drivers/usb/gadget/f_sourcesink.c | 8 | ||||
-rw-r--r-- | drivers/usb/gadget/f_subset.c | 29 | ||||
-rw-r--r-- | include/linux/usb/composite.h | 15 | ||||
-rw-r--r-- | include/linux/usb/gadget.h | 6 |
16 files changed, 126 insertions, 315 deletions
diff --git a/drivers/usb/gadget/config.c b/drivers/usb/gadget/config.c index 09084fd646ab..b2c001334876 100644 --- a/drivers/usb/gadget/config.c +++ b/drivers/usb/gadget/config.c | |||
@@ -165,28 +165,3 @@ usb_copy_descriptors(struct usb_descriptor_header **src) | |||
165 | return ret; | 165 | return ret; |
166 | } | 166 | } |
167 | 167 | ||
168 | /** | ||
169 | * usb_find_endpoint - find a copy of an endpoint descriptor | ||
170 | * @src: original vector of descriptors | ||
171 | * @copy: copy of @src | ||
172 | * @match: endpoint descriptor found in @src | ||
173 | * | ||
174 | * This returns the copy of the @match descriptor made for @copy. Its | ||
175 | * intended use is to help remembering the endpoint descriptor to use | ||
176 | * when enabling a given endpoint. | ||
177 | */ | ||
178 | struct usb_endpoint_descriptor * | ||
179 | usb_find_endpoint( | ||
180 | struct usb_descriptor_header **src, | ||
181 | struct usb_descriptor_header **copy, | ||
182 | struct usb_endpoint_descriptor *match | ||
183 | ) | ||
184 | { | ||
185 | while (*src) { | ||
186 | if (*src == (void *) match) | ||
187 | return (void *)*copy; | ||
188 | src++; | ||
189 | copy++; | ||
190 | } | ||
191 | return NULL; | ||
192 | } | ||
diff --git a/drivers/usb/gadget/f_acm.c b/drivers/usb/gadget/f_acm.c index d04b4a68220d..3f8849339ade 100644 --- a/drivers/usb/gadget/f_acm.c +++ b/drivers/usb/gadget/f_acm.c | |||
@@ -39,12 +39,6 @@ | |||
39 | * descriptors (roughly equivalent to CDC Unions) may sometimes help. | 39 | * descriptors (roughly equivalent to CDC Unions) may sometimes help. |
40 | */ | 40 | */ |
41 | 41 | ||
42 | struct acm_ep_descs { | ||
43 | struct usb_endpoint_descriptor *in; | ||
44 | struct usb_endpoint_descriptor *out; | ||
45 | struct usb_endpoint_descriptor *notify; | ||
46 | }; | ||
47 | |||
48 | struct f_acm { | 42 | struct f_acm { |
49 | struct gserial port; | 43 | struct gserial port; |
50 | u8 ctrl_id, data_id; | 44 | u8 ctrl_id, data_id; |
@@ -58,9 +52,6 @@ struct f_acm { | |||
58 | */ | 52 | */ |
59 | spinlock_t lock; | 53 | spinlock_t lock; |
60 | 54 | ||
61 | struct acm_ep_descs fs; | ||
62 | struct acm_ep_descs hs; | ||
63 | |||
64 | struct usb_ep *notify; | 55 | struct usb_ep *notify; |
65 | struct usb_request *notify_req; | 56 | struct usb_request *notify_req; |
66 | 57 | ||
@@ -404,9 +395,8 @@ static int acm_set_alt(struct usb_function *f, unsigned intf, unsigned alt) | |||
404 | usb_ep_disable(acm->notify); | 395 | usb_ep_disable(acm->notify); |
405 | } else { | 396 | } else { |
406 | VDBG(cdev, "init acm ctrl interface %d\n", intf); | 397 | VDBG(cdev, "init acm ctrl interface %d\n", intf); |
407 | acm->notify->desc = ep_choose(cdev->gadget, | 398 | if (config_ep_by_speed(cdev->gadget, f, acm->notify)) |
408 | acm->hs.notify, | 399 | return -EINVAL; |
409 | acm->fs.notify); | ||
410 | } | 400 | } |
411 | usb_ep_enable(acm->notify); | 401 | usb_ep_enable(acm->notify); |
412 | acm->notify->driver_data = acm; | 402 | acm->notify->driver_data = acm; |
@@ -415,12 +405,17 @@ static int acm_set_alt(struct usb_function *f, unsigned intf, unsigned alt) | |||
415 | if (acm->port.in->driver_data) { | 405 | if (acm->port.in->driver_data) { |
416 | DBG(cdev, "reset acm ttyGS%d\n", acm->port_num); | 406 | DBG(cdev, "reset acm ttyGS%d\n", acm->port_num); |
417 | gserial_disconnect(&acm->port); | 407 | gserial_disconnect(&acm->port); |
418 | } else { | 408 | } |
409 | if (!acm->port.in->desc || !acm->port.out->desc) { | ||
419 | DBG(cdev, "activate acm ttyGS%d\n", acm->port_num); | 410 | DBG(cdev, "activate acm ttyGS%d\n", acm->port_num); |
420 | acm->port.in->desc = ep_choose(cdev->gadget, | 411 | if (config_ep_by_speed(cdev->gadget, f, |
421 | acm->hs.in, acm->fs.in); | 412 | acm->port.in) || |
422 | acm->port.out->desc = ep_choose(cdev->gadget, | 413 | config_ep_by_speed(cdev->gadget, f, |
423 | acm->hs.out, acm->fs.out); | 414 | acm->port.out)) { |
415 | acm->port.in->desc = NULL; | ||
416 | acm->port.out->desc = NULL; | ||
417 | return -EINVAL; | ||
418 | } | ||
424 | } | 419 | } |
425 | gserial_connect(&acm->port, acm->port_num); | 420 | gserial_connect(&acm->port, acm->port_num); |
426 | 421 | ||
@@ -628,18 +623,11 @@ acm_bind(struct usb_configuration *c, struct usb_function *f) | |||
628 | acm->notify_req->complete = acm_cdc_notify_complete; | 623 | acm->notify_req->complete = acm_cdc_notify_complete; |
629 | acm->notify_req->context = acm; | 624 | acm->notify_req->context = acm; |
630 | 625 | ||
631 | /* copy descriptors, and track endpoint copies */ | 626 | /* copy descriptors */ |
632 | f->descriptors = usb_copy_descriptors(acm_fs_function); | 627 | f->descriptors = usb_copy_descriptors(acm_fs_function); |
633 | if (!f->descriptors) | 628 | if (!f->descriptors) |
634 | goto fail; | 629 | goto fail; |
635 | 630 | ||
636 | acm->fs.in = usb_find_endpoint(acm_fs_function, | ||
637 | f->descriptors, &acm_fs_in_desc); | ||
638 | acm->fs.out = usb_find_endpoint(acm_fs_function, | ||
639 | f->descriptors, &acm_fs_out_desc); | ||
640 | acm->fs.notify = usb_find_endpoint(acm_fs_function, | ||
641 | f->descriptors, &acm_fs_notify_desc); | ||
642 | |||
643 | /* support all relevant hardware speeds... we expect that when | 631 | /* support all relevant hardware speeds... we expect that when |
644 | * hardware is dual speed, all bulk-capable endpoints work at | 632 | * hardware is dual speed, all bulk-capable endpoints work at |
645 | * both speeds | 633 | * both speeds |
@@ -652,15 +640,8 @@ acm_bind(struct usb_configuration *c, struct usb_function *f) | |||
652 | acm_hs_notify_desc.bEndpointAddress = | 640 | acm_hs_notify_desc.bEndpointAddress = |
653 | acm_fs_notify_desc.bEndpointAddress; | 641 | acm_fs_notify_desc.bEndpointAddress; |
654 | 642 | ||
655 | /* copy descriptors, and track endpoint copies */ | 643 | /* copy descriptors */ |
656 | f->hs_descriptors = usb_copy_descriptors(acm_hs_function); | 644 | f->hs_descriptors = usb_copy_descriptors(acm_hs_function); |
657 | |||
658 | acm->hs.in = usb_find_endpoint(acm_hs_function, | ||
659 | f->hs_descriptors, &acm_hs_in_desc); | ||
660 | acm->hs.out = usb_find_endpoint(acm_hs_function, | ||
661 | f->hs_descriptors, &acm_hs_out_desc); | ||
662 | acm->hs.notify = usb_find_endpoint(acm_hs_function, | ||
663 | f->hs_descriptors, &acm_hs_notify_desc); | ||
664 | } | 645 | } |
665 | 646 | ||
666 | DBG(cdev, "acm ttyGS%d: %s speed IN/%s OUT/%s NOTIFY/%s\n", | 647 | DBG(cdev, "acm ttyGS%d: %s speed IN/%s OUT/%s NOTIFY/%s\n", |
diff --git a/drivers/usb/gadget/f_ecm.c b/drivers/usb/gadget/f_ecm.c index 7c996f271ccb..ddedbc83bc37 100644 --- a/drivers/usb/gadget/f_ecm.c +++ b/drivers/usb/gadget/f_ecm.c | |||
@@ -46,11 +46,6 @@ | |||
46 | * and also means that a get_alt() method is required. | 46 | * and also means that a get_alt() method is required. |
47 | */ | 47 | */ |
48 | 48 | ||
49 | struct ecm_ep_descs { | ||
50 | struct usb_endpoint_descriptor *in; | ||
51 | struct usb_endpoint_descriptor *out; | ||
52 | struct usb_endpoint_descriptor *notify; | ||
53 | }; | ||
54 | 49 | ||
55 | enum ecm_notify_state { | 50 | enum ecm_notify_state { |
56 | ECM_NOTIFY_NONE, /* don't notify */ | 51 | ECM_NOTIFY_NONE, /* don't notify */ |
@@ -64,9 +59,6 @@ struct f_ecm { | |||
64 | 59 | ||
65 | char ethaddr[14]; | 60 | char ethaddr[14]; |
66 | 61 | ||
67 | struct ecm_ep_descs fs; | ||
68 | struct ecm_ep_descs hs; | ||
69 | |||
70 | struct usb_ep *notify; | 62 | struct usb_ep *notify; |
71 | struct usb_request *notify_req; | 63 | struct usb_request *notify_req; |
72 | u8 notify_state; | 64 | u8 notify_state; |
@@ -463,11 +455,11 @@ static int ecm_set_alt(struct usb_function *f, unsigned intf, unsigned alt) | |||
463 | if (ecm->notify->driver_data) { | 455 | if (ecm->notify->driver_data) { |
464 | VDBG(cdev, "reset ecm control %d\n", intf); | 456 | VDBG(cdev, "reset ecm control %d\n", intf); |
465 | usb_ep_disable(ecm->notify); | 457 | usb_ep_disable(ecm->notify); |
466 | } else { | 458 | } |
459 | if (!(ecm->notify->desc)) { | ||
467 | VDBG(cdev, "init ecm ctrl %d\n", intf); | 460 | VDBG(cdev, "init ecm ctrl %d\n", intf); |
468 | ecm->notify->desc = ep_choose(cdev->gadget, | 461 | if (config_ep_by_speed(cdev->gadget, f, ecm->notify)) |
469 | ecm->hs.notify, | 462 | goto fail; |
470 | ecm->fs.notify); | ||
471 | } | 463 | } |
472 | usb_ep_enable(ecm->notify); | 464 | usb_ep_enable(ecm->notify); |
473 | ecm->notify->driver_data = ecm; | 465 | ecm->notify->driver_data = ecm; |
@@ -482,12 +474,17 @@ static int ecm_set_alt(struct usb_function *f, unsigned intf, unsigned alt) | |||
482 | gether_disconnect(&ecm->port); | 474 | gether_disconnect(&ecm->port); |
483 | } | 475 | } |
484 | 476 | ||
485 | if (!ecm->port.in_ep->desc) { | 477 | if (!ecm->port.in_ep->desc || |
478 | !ecm->port.out_ep->desc) { | ||
486 | DBG(cdev, "init ecm\n"); | 479 | DBG(cdev, "init ecm\n"); |
487 | ecm->port.in_ep->desc = ep_choose(cdev->gadget, | 480 | if (config_ep_by_speed(cdev->gadget, f, |
488 | ecm->hs.in, ecm->fs.in); | 481 | ecm->port.in_ep) || |
489 | ecm->port.out_ep->desc = ep_choose(cdev->gadget, | 482 | config_ep_by_speed(cdev->gadget, f, |
490 | ecm->hs.out, ecm->fs.out); | 483 | ecm->port.out_ep)) { |
484 | ecm->port.in_ep->desc = NULL; | ||
485 | ecm->port.out_ep->desc = NULL; | ||
486 | goto fail; | ||
487 | } | ||
491 | } | 488 | } |
492 | 489 | ||
493 | /* CDC Ethernet only sends data in non-default altsettings. | 490 | /* CDC Ethernet only sends data in non-default altsettings. |
@@ -664,13 +661,6 @@ ecm_bind(struct usb_configuration *c, struct usb_function *f) | |||
664 | if (!f->descriptors) | 661 | if (!f->descriptors) |
665 | goto fail; | 662 | goto fail; |
666 | 663 | ||
667 | ecm->fs.in = usb_find_endpoint(ecm_fs_function, | ||
668 | f->descriptors, &fs_ecm_in_desc); | ||
669 | ecm->fs.out = usb_find_endpoint(ecm_fs_function, | ||
670 | f->descriptors, &fs_ecm_out_desc); | ||
671 | ecm->fs.notify = usb_find_endpoint(ecm_fs_function, | ||
672 | f->descriptors, &fs_ecm_notify_desc); | ||
673 | |||
674 | /* support all relevant hardware speeds... we expect that when | 664 | /* support all relevant hardware speeds... we expect that when |
675 | * hardware is dual speed, all bulk-capable endpoints work at | 665 | * hardware is dual speed, all bulk-capable endpoints work at |
676 | * both speeds | 666 | * both speeds |
@@ -687,13 +677,6 @@ ecm_bind(struct usb_configuration *c, struct usb_function *f) | |||
687 | f->hs_descriptors = usb_copy_descriptors(ecm_hs_function); | 677 | f->hs_descriptors = usb_copy_descriptors(ecm_hs_function); |
688 | if (!f->hs_descriptors) | 678 | if (!f->hs_descriptors) |
689 | goto fail; | 679 | goto fail; |
690 | |||
691 | ecm->hs.in = usb_find_endpoint(ecm_hs_function, | ||
692 | f->hs_descriptors, &hs_ecm_in_desc); | ||
693 | ecm->hs.out = usb_find_endpoint(ecm_hs_function, | ||
694 | f->hs_descriptors, &hs_ecm_out_desc); | ||
695 | ecm->hs.notify = usb_find_endpoint(ecm_hs_function, | ||
696 | f->hs_descriptors, &hs_ecm_notify_desc); | ||
697 | } | 680 | } |
698 | 681 | ||
699 | /* NOTE: all that is done without knowing or caring about | 682 | /* NOTE: all that is done without knowing or caring about |
diff --git a/drivers/usb/gadget/f_eem.c b/drivers/usb/gadget/f_eem.c index fea8e3b08b5f..3e412740e2ef 100644 --- a/drivers/usb/gadget/f_eem.c +++ b/drivers/usb/gadget/f_eem.c | |||
@@ -35,17 +35,9 @@ | |||
35 | * Ethernet link. | 35 | * Ethernet link. |
36 | */ | 36 | */ |
37 | 37 | ||
38 | struct eem_ep_descs { | ||
39 | struct usb_endpoint_descriptor *in; | ||
40 | struct usb_endpoint_descriptor *out; | ||
41 | }; | ||
42 | |||
43 | struct f_eem { | 38 | struct f_eem { |
44 | struct gether port; | 39 | struct gether port; |
45 | u8 ctrl_id; | 40 | u8 ctrl_id; |
46 | |||
47 | struct eem_ep_descs fs; | ||
48 | struct eem_ep_descs hs; | ||
49 | }; | 41 | }; |
50 | 42 | ||
51 | static inline struct f_eem *func_to_eem(struct usb_function *f) | 43 | static inline struct f_eem *func_to_eem(struct usb_function *f) |
@@ -176,12 +168,16 @@ static int eem_set_alt(struct usb_function *f, unsigned intf, unsigned alt) | |||
176 | gether_disconnect(&eem->port); | 168 | gether_disconnect(&eem->port); |
177 | } | 169 | } |
178 | 170 | ||
179 | if (!eem->port.in_ep->desc) { | 171 | if (!eem->port.in_ep->desc || !eem->port.out_ep->desc) { |
180 | DBG(cdev, "init eem\n"); | 172 | DBG(cdev, "init eem\n"); |
181 | eem->port.in_ep->desc = ep_choose(cdev->gadget, | 173 | if (config_ep_by_speed(cdev->gadget, f, |
182 | eem->hs.in, eem->fs.in); | 174 | eem->port.in_ep) || |
183 | eem->port.out_ep->desc = ep_choose(cdev->gadget, | 175 | config_ep_by_speed(cdev->gadget, f, |
184 | eem->hs.out, eem->fs.out); | 176 | eem->port.out_ep)) { |
177 | eem->port.in_ep->desc = NULL; | ||
178 | eem->port.out_ep->desc = NULL; | ||
179 | goto fail; | ||
180 | } | ||
185 | } | 181 | } |
186 | 182 | ||
187 | /* zlps should not occur because zero-length EEM packets | 183 | /* zlps should not occur because zero-length EEM packets |
@@ -253,11 +249,6 @@ eem_bind(struct usb_configuration *c, struct usb_function *f) | |||
253 | if (!f->descriptors) | 249 | if (!f->descriptors) |
254 | goto fail; | 250 | goto fail; |
255 | 251 | ||
256 | eem->fs.in = usb_find_endpoint(eem_fs_function, | ||
257 | f->descriptors, &eem_fs_in_desc); | ||
258 | eem->fs.out = usb_find_endpoint(eem_fs_function, | ||
259 | f->descriptors, &eem_fs_out_desc); | ||
260 | |||
261 | /* support all relevant hardware speeds... we expect that when | 252 | /* support all relevant hardware speeds... we expect that when |
262 | * hardware is dual speed, all bulk-capable endpoints work at | 253 | * hardware is dual speed, all bulk-capable endpoints work at |
263 | * both speeds | 254 | * both speeds |
@@ -272,11 +263,6 @@ eem_bind(struct usb_configuration *c, struct usb_function *f) | |||
272 | f->hs_descriptors = usb_copy_descriptors(eem_hs_function); | 263 | f->hs_descriptors = usb_copy_descriptors(eem_hs_function); |
273 | if (!f->hs_descriptors) | 264 | if (!f->hs_descriptors) |
274 | goto fail; | 265 | goto fail; |
275 | |||
276 | eem->hs.in = usb_find_endpoint(eem_hs_function, | ||
277 | f->hs_descriptors, &eem_hs_in_desc); | ||
278 | eem->hs.out = usb_find_endpoint(eem_hs_function, | ||
279 | f->hs_descriptors, &eem_hs_out_desc); | ||
280 | } | 266 | } |
281 | 267 | ||
282 | DBG(cdev, "CDC Ethernet (EEM): %s speed IN/%s OUT/%s\n", | 268 | DBG(cdev, "CDC Ethernet (EEM): %s speed IN/%s OUT/%s\n", |
diff --git a/drivers/usb/gadget/f_hid.c b/drivers/usb/gadget/f_hid.c index 12879b6f787c..403a48bcf560 100644 --- a/drivers/usb/gadget/f_hid.c +++ b/drivers/usb/gadget/f_hid.c | |||
@@ -59,8 +59,6 @@ struct f_hidg { | |||
59 | struct cdev cdev; | 59 | struct cdev cdev; |
60 | struct usb_function func; | 60 | struct usb_function func; |
61 | struct usb_ep *in_ep; | 61 | struct usb_ep *in_ep; |
62 | struct usb_endpoint_descriptor *fs_in_ep_desc; | ||
63 | struct usb_endpoint_descriptor *hs_in_ep_desc; | ||
64 | }; | 62 | }; |
65 | 63 | ||
66 | static inline struct f_hidg *func_to_hidg(struct usb_function *f) | 64 | static inline struct f_hidg *func_to_hidg(struct usb_function *f) |
@@ -425,8 +423,12 @@ static int hidg_set_alt(struct usb_function *f, unsigned intf, unsigned alt) | |||
425 | if (hidg->in_ep->driver_data != NULL) | 423 | if (hidg->in_ep->driver_data != NULL) |
426 | usb_ep_disable(hidg->in_ep); | 424 | usb_ep_disable(hidg->in_ep); |
427 | 425 | ||
428 | hidg->in_ep->desc = ep_choose(f->config->cdev->gadget, | 426 | status = config_ep_by_speed(f->config->cdev->gadget, f, |
429 | hidg->hs_in_ep_desc, hidg->fs_in_ep_desc); | 427 | hidg->in_ep); |
428 | if (status) { | ||
429 | ERROR(cdev, "config_ep_by_speed FAILED!\n"); | ||
430 | goto fail; | ||
431 | } | ||
430 | status = usb_ep_enable(hidg->in_ep); | 432 | status = usb_ep_enable(hidg->in_ep); |
431 | if (status < 0) { | 433 | if (status < 0) { |
432 | ERROR(cdev, "Enable endpoint FAILED!\n"); | 434 | ERROR(cdev, "Enable endpoint FAILED!\n"); |
@@ -497,21 +499,12 @@ static int __init hidg_bind(struct usb_configuration *c, struct usb_function *f) | |||
497 | if (!f->descriptors) | 499 | if (!f->descriptors) |
498 | goto fail; | 500 | goto fail; |
499 | 501 | ||
500 | hidg->fs_in_ep_desc = usb_find_endpoint(hidg_fs_descriptors, | ||
501 | f->descriptors, | ||
502 | &hidg_fs_in_ep_desc); | ||
503 | |||
504 | if (gadget_is_dualspeed(c->cdev->gadget)) { | 502 | if (gadget_is_dualspeed(c->cdev->gadget)) { |
505 | hidg_hs_in_ep_desc.bEndpointAddress = | 503 | hidg_hs_in_ep_desc.bEndpointAddress = |
506 | hidg_fs_in_ep_desc.bEndpointAddress; | 504 | hidg_fs_in_ep_desc.bEndpointAddress; |
507 | f->hs_descriptors = usb_copy_descriptors(hidg_hs_descriptors); | 505 | f->hs_descriptors = usb_copy_descriptors(hidg_hs_descriptors); |
508 | if (!f->hs_descriptors) | 506 | if (!f->hs_descriptors) |
509 | goto fail; | 507 | goto fail; |
510 | hidg->hs_in_ep_desc = usb_find_endpoint(hidg_hs_descriptors, | ||
511 | f->hs_descriptors, | ||
512 | &hidg_hs_in_ep_desc); | ||
513 | } else { | ||
514 | hidg->hs_in_ep_desc = NULL; | ||
515 | } | 508 | } |
516 | 509 | ||
517 | mutex_init(&hidg->lock); | 510 | mutex_init(&hidg->lock); |
diff --git a/drivers/usb/gadget/f_loopback.c b/drivers/usb/gadget/f_loopback.c index 34e3ccaf0884..375632659a03 100644 --- a/drivers/usb/gadget/f_loopback.c +++ b/drivers/usb/gadget/f_loopback.c | |||
@@ -256,8 +256,9 @@ enable_loopback(struct usb_composite_dev *cdev, struct f_loopback *loop) | |||
256 | 256 | ||
257 | /* one endpoint writes data back IN to the host */ | 257 | /* one endpoint writes data back IN to the host */ |
258 | ep = loop->in_ep; | 258 | ep = loop->in_ep; |
259 | ep->desc = ep_choose(cdev->gadget, | 259 | result = config_ep_by_speed(cdev->gadget, &(loop->function), ep); |
260 | &hs_loop_source_desc, &fs_loop_source_desc); | 260 | if (result) |
261 | return result; | ||
261 | result = usb_ep_enable(ep); | 262 | result = usb_ep_enable(ep); |
262 | if (result < 0) | 263 | if (result < 0) |
263 | return result; | 264 | return result; |
@@ -265,8 +266,10 @@ enable_loopback(struct usb_composite_dev *cdev, struct f_loopback *loop) | |||
265 | 266 | ||
266 | /* one endpoint just reads OUT packets */ | 267 | /* one endpoint just reads OUT packets */ |
267 | ep = loop->out_ep; | 268 | ep = loop->out_ep; |
268 | ep->desc = ep_choose(cdev->gadget, | 269 | result = config_ep_by_speed(cdev->gadget, &(loop->function), ep); |
269 | &hs_loop_sink_desc, &fs_loop_sink_desc); | 270 | if (result) |
271 | goto fail0; | ||
272 | |||
270 | result = usb_ep_enable(ep); | 273 | result = usb_ep_enable(ep); |
271 | if (result < 0) { | 274 | if (result < 0) { |
272 | fail0: | 275 | fail0: |
diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c index 4eee43412121..5b9339582007 100644 --- a/drivers/usb/gadget/f_mass_storage.c +++ b/drivers/usb/gadget/f_mass_storage.c | |||
@@ -2324,19 +2324,6 @@ static int get_next_command(struct fsg_common *common) | |||
2324 | 2324 | ||
2325 | /*-------------------------------------------------------------------------*/ | 2325 | /*-------------------------------------------------------------------------*/ |
2326 | 2326 | ||
2327 | static int enable_endpoint(struct fsg_common *common, struct usb_ep *ep, | ||
2328 | const struct usb_endpoint_descriptor *d) | ||
2329 | { | ||
2330 | int rc; | ||
2331 | |||
2332 | ep->driver_data = common; | ||
2333 | ep->desc = (struct usb_endpoint_descriptor *)d; | ||
2334 | rc = usb_ep_enable(ep); | ||
2335 | if (rc) | ||
2336 | ERROR(common, "can't enable %s, result %d\n", ep->name, rc); | ||
2337 | return rc; | ||
2338 | } | ||
2339 | |||
2340 | static int alloc_request(struct fsg_common *common, struct usb_ep *ep, | 2327 | static int alloc_request(struct fsg_common *common, struct usb_ep *ep, |
2341 | struct usb_request **preq) | 2328 | struct usb_request **preq) |
2342 | { | 2329 | { |
@@ -2350,7 +2337,6 @@ static int alloc_request(struct fsg_common *common, struct usb_ep *ep, | |||
2350 | /* Reset interface setting and re-init endpoint state (toggle etc). */ | 2337 | /* Reset interface setting and re-init endpoint state (toggle etc). */ |
2351 | static int do_set_interface(struct fsg_common *common, struct fsg_dev *new_fsg) | 2338 | static int do_set_interface(struct fsg_common *common, struct fsg_dev *new_fsg) |
2352 | { | 2339 | { |
2353 | const struct usb_endpoint_descriptor *d; | ||
2354 | struct fsg_dev *fsg; | 2340 | struct fsg_dev *fsg; |
2355 | int i, rc = 0; | 2341 | int i, rc = 0; |
2356 | 2342 | ||
@@ -2397,20 +2383,26 @@ reset: | |||
2397 | fsg = common->fsg; | 2383 | fsg = common->fsg; |
2398 | 2384 | ||
2399 | /* Enable the endpoints */ | 2385 | /* Enable the endpoints */ |
2400 | d = fsg_ep_desc(common->gadget, | 2386 | rc = config_ep_by_speed(common->gadget, &(fsg->function), fsg->bulk_in); |
2401 | &fsg_fs_bulk_in_desc, &fsg_hs_bulk_in_desc); | 2387 | if (rc) |
2402 | rc = enable_endpoint(common, fsg->bulk_in, d); | 2388 | goto reset; |
2389 | rc = usb_ep_enable(fsg->bulk_in); | ||
2403 | if (rc) | 2390 | if (rc) |
2404 | goto reset; | 2391 | goto reset; |
2392 | fsg->bulk_in->driver_data = common; | ||
2405 | fsg->bulk_in_enabled = 1; | 2393 | fsg->bulk_in_enabled = 1; |
2406 | 2394 | ||
2407 | d = fsg_ep_desc(common->gadget, | 2395 | rc = config_ep_by_speed(common->gadget, &(fsg->function), |
2408 | &fsg_fs_bulk_out_desc, &fsg_hs_bulk_out_desc); | 2396 | fsg->bulk_out); |
2409 | rc = enable_endpoint(common, fsg->bulk_out, d); | 2397 | if (rc) |
2398 | goto reset; | ||
2399 | rc = usb_ep_enable(fsg->bulk_out); | ||
2410 | if (rc) | 2400 | if (rc) |
2411 | goto reset; | 2401 | goto reset; |
2402 | fsg->bulk_out->driver_data = common; | ||
2412 | fsg->bulk_out_enabled = 1; | 2403 | fsg->bulk_out_enabled = 1; |
2413 | common->bulk_out_maxpacket = le16_to_cpu(d->wMaxPacketSize); | 2404 | common->bulk_out_maxpacket = |
2405 | le16_to_cpu(fsg->bulk_out->desc->wMaxPacketSize); | ||
2414 | clear_bit(IGNORE_BULK_OUT, &fsg->atomic_bitflags); | 2406 | clear_bit(IGNORE_BULK_OUT, &fsg->atomic_bitflags); |
2415 | 2407 | ||
2416 | /* Allocate the requests */ | 2408 | /* Allocate the requests */ |
diff --git a/drivers/usb/gadget/f_ncm.c b/drivers/usb/gadget/f_ncm.c index 06daa1bc9ffd..ae69ed7e6b99 100644 --- a/drivers/usb/gadget/f_ncm.c +++ b/drivers/usb/gadget/f_ncm.c | |||
@@ -48,12 +48,6 @@ | |||
48 | #define NCM_NDP_HDR_CRC 0x01000000 | 48 | #define NCM_NDP_HDR_CRC 0x01000000 |
49 | #define NCM_NDP_HDR_NOCRC 0x00000000 | 49 | #define NCM_NDP_HDR_NOCRC 0x00000000 |
50 | 50 | ||
51 | struct ncm_ep_descs { | ||
52 | struct usb_endpoint_descriptor *in; | ||
53 | struct usb_endpoint_descriptor *out; | ||
54 | struct usb_endpoint_descriptor *notify; | ||
55 | }; | ||
56 | |||
57 | enum ncm_notify_state { | 51 | enum ncm_notify_state { |
58 | NCM_NOTIFY_NONE, /* don't notify */ | 52 | NCM_NOTIFY_NONE, /* don't notify */ |
59 | NCM_NOTIFY_CONNECT, /* issue CONNECT next */ | 53 | NCM_NOTIFY_CONNECT, /* issue CONNECT next */ |
@@ -66,9 +60,6 @@ struct f_ncm { | |||
66 | 60 | ||
67 | char ethaddr[14]; | 61 | char ethaddr[14]; |
68 | 62 | ||
69 | struct ncm_ep_descs fs; | ||
70 | struct ncm_ep_descs hs; | ||
71 | |||
72 | struct usb_ep *notify; | 63 | struct usb_ep *notify; |
73 | struct usb_request *notify_req; | 64 | struct usb_request *notify_req; |
74 | u8 notify_state; | 65 | u8 notify_state; |
@@ -801,11 +792,12 @@ static int ncm_set_alt(struct usb_function *f, unsigned intf, unsigned alt) | |||
801 | if (ncm->notify->driver_data) { | 792 | if (ncm->notify->driver_data) { |
802 | DBG(cdev, "reset ncm control %d\n", intf); | 793 | DBG(cdev, "reset ncm control %d\n", intf); |
803 | usb_ep_disable(ncm->notify); | 794 | usb_ep_disable(ncm->notify); |
804 | } else { | 795 | } |
796 | |||
797 | if (!(ncm->notify->desc)) { | ||
805 | DBG(cdev, "init ncm ctrl %d\n", intf); | 798 | DBG(cdev, "init ncm ctrl %d\n", intf); |
806 | ncm->notify->desc = ep_choose(cdev->gadget, | 799 | if (config_ep_by_speed(cdev->gadget, f, ncm->notify)) |
807 | ncm->hs.notify, | 800 | goto fail; |
808 | ncm->fs.notify); | ||
809 | } | 801 | } |
810 | usb_ep_enable(ncm->notify); | 802 | usb_ep_enable(ncm->notify); |
811 | ncm->notify->driver_data = ncm; | 803 | ncm->notify->driver_data = ncm; |
@@ -828,14 +820,17 @@ static int ncm_set_alt(struct usb_function *f, unsigned intf, unsigned alt) | |||
828 | if (alt == 1) { | 820 | if (alt == 1) { |
829 | struct net_device *net; | 821 | struct net_device *net; |
830 | 822 | ||
831 | if (!ncm->port.in_ep->desc) { | 823 | if (!ncm->port.in_ep->desc || |
824 | !ncm->port.out_ep->desc) { | ||
832 | DBG(cdev, "init ncm\n"); | 825 | DBG(cdev, "init ncm\n"); |
833 | ncm->port.in_ep->desc = ep_choose(cdev->gadget, | 826 | if (config_ep_by_speed(cdev->gadget, f, |
834 | ncm->hs.in, | 827 | ncm->port.in_ep) || |
835 | ncm->fs.in); | 828 | config_ep_by_speed(cdev->gadget, f, |
836 | ncm->port.out_ep->desc = ep_choose(cdev->gadget, | 829 | ncm->port.out_ep)) { |
837 | ncm->hs.out, | 830 | ncm->port.in_ep->desc = NULL; |
838 | ncm->fs.out); | 831 | ncm->port.out_ep->desc = NULL; |
832 | goto fail; | ||
833 | } | ||
839 | } | 834 | } |
840 | 835 | ||
841 | /* TODO */ | 836 | /* TODO */ |
@@ -1227,13 +1222,6 @@ ncm_bind(struct usb_configuration *c, struct usb_function *f) | |||
1227 | if (!f->descriptors) | 1222 | if (!f->descriptors) |
1228 | goto fail; | 1223 | goto fail; |
1229 | 1224 | ||
1230 | ncm->fs.in = usb_find_endpoint(ncm_fs_function, | ||
1231 | f->descriptors, &fs_ncm_in_desc); | ||
1232 | ncm->fs.out = usb_find_endpoint(ncm_fs_function, | ||
1233 | f->descriptors, &fs_ncm_out_desc); | ||
1234 | ncm->fs.notify = usb_find_endpoint(ncm_fs_function, | ||
1235 | f->descriptors, &fs_ncm_notify_desc); | ||
1236 | |||
1237 | /* | 1225 | /* |
1238 | * support all relevant hardware speeds... we expect that when | 1226 | * support all relevant hardware speeds... we expect that when |
1239 | * hardware is dual speed, all bulk-capable endpoints work at | 1227 | * hardware is dual speed, all bulk-capable endpoints work at |
@@ -1251,13 +1239,6 @@ ncm_bind(struct usb_configuration *c, struct usb_function *f) | |||
1251 | f->hs_descriptors = usb_copy_descriptors(ncm_hs_function); | 1239 | f->hs_descriptors = usb_copy_descriptors(ncm_hs_function); |
1252 | if (!f->hs_descriptors) | 1240 | if (!f->hs_descriptors) |
1253 | goto fail; | 1241 | goto fail; |
1254 | |||
1255 | ncm->hs.in = usb_find_endpoint(ncm_hs_function, | ||
1256 | f->hs_descriptors, &hs_ncm_in_desc); | ||
1257 | ncm->hs.out = usb_find_endpoint(ncm_hs_function, | ||
1258 | f->hs_descriptors, &hs_ncm_out_desc); | ||
1259 | ncm->hs.notify = usb_find_endpoint(ncm_hs_function, | ||
1260 | f->hs_descriptors, &hs_ncm_notify_desc); | ||
1261 | } | 1242 | } |
1262 | 1243 | ||
1263 | /* | 1244 | /* |
diff --git a/drivers/usb/gadget/f_obex.c b/drivers/usb/gadget/f_obex.c index a6dbda090ca5..394502abeb96 100644 --- a/drivers/usb/gadget/f_obex.c +++ b/drivers/usb/gadget/f_obex.c | |||
@@ -39,20 +39,12 @@ | |||
39 | * ready to handle the commands. | 39 | * ready to handle the commands. |
40 | */ | 40 | */ |
41 | 41 | ||
42 | struct obex_ep_descs { | ||
43 | struct usb_endpoint_descriptor *obex_in; | ||
44 | struct usb_endpoint_descriptor *obex_out; | ||
45 | }; | ||
46 | |||
47 | struct f_obex { | 42 | struct f_obex { |
48 | struct gserial port; | 43 | struct gserial port; |
49 | u8 ctrl_id; | 44 | u8 ctrl_id; |
50 | u8 data_id; | 45 | u8 data_id; |
51 | u8 port_num; | 46 | u8 port_num; |
52 | u8 can_activate; | 47 | u8 can_activate; |
53 | |||
54 | struct obex_ep_descs fs; | ||
55 | struct obex_ep_descs hs; | ||
56 | }; | 48 | }; |
57 | 49 | ||
58 | static inline struct f_obex *func_to_obex(struct usb_function *f) | 50 | static inline struct f_obex *func_to_obex(struct usb_function *f) |
@@ -227,12 +219,16 @@ static int obex_set_alt(struct usb_function *f, unsigned intf, unsigned alt) | |||
227 | gserial_disconnect(&obex->port); | 219 | gserial_disconnect(&obex->port); |
228 | } | 220 | } |
229 | 221 | ||
230 | if (!obex->port.in->desc) { | 222 | if (!obex->port.in->desc || !obex->port.out->desc) { |
231 | DBG(cdev, "init obex ttyGS%d\n", obex->port_num); | 223 | DBG(cdev, "init obex ttyGS%d\n", obex->port_num); |
232 | obex->port.in->desc = ep_choose(cdev->gadget, | 224 | if (config_ep_by_speed(cdev->gadget, f, |
233 | obex->hs.obex_in, obex->fs.obex_in); | 225 | obex->port.in) || |
234 | obex->port.out->desc = ep_choose(cdev->gadget, | 226 | config_ep_by_speed(cdev->gadget, f, |
235 | obex->hs.obex_out, obex->fs.obex_out); | 227 | obex->port.out)) { |
228 | obex->port.out->desc = NULL; | ||
229 | obex->port.in->desc = NULL; | ||
230 | goto fail; | ||
231 | } | ||
236 | } | 232 | } |
237 | 233 | ||
238 | if (alt == 1) { | 234 | if (alt == 1) { |
@@ -346,11 +342,6 @@ obex_bind(struct usb_configuration *c, struct usb_function *f) | |||
346 | /* copy descriptors, and track endpoint copies */ | 342 | /* copy descriptors, and track endpoint copies */ |
347 | f->descriptors = usb_copy_descriptors(fs_function); | 343 | f->descriptors = usb_copy_descriptors(fs_function); |
348 | 344 | ||
349 | obex->fs.obex_in = usb_find_endpoint(fs_function, | ||
350 | f->descriptors, &obex_fs_ep_in_desc); | ||
351 | obex->fs.obex_out = usb_find_endpoint(fs_function, | ||
352 | f->descriptors, &obex_fs_ep_out_desc); | ||
353 | |||
354 | /* support all relevant hardware speeds... we expect that when | 345 | /* support all relevant hardware speeds... we expect that when |
355 | * hardware is dual speed, all bulk-capable endpoints work at | 346 | * hardware is dual speed, all bulk-capable endpoints work at |
356 | * both speeds | 347 | * both speeds |
@@ -364,11 +355,6 @@ obex_bind(struct usb_configuration *c, struct usb_function *f) | |||
364 | 355 | ||
365 | /* copy descriptors, and track endpoint copies */ | 356 | /* copy descriptors, and track endpoint copies */ |
366 | f->hs_descriptors = usb_copy_descriptors(hs_function); | 357 | f->hs_descriptors = usb_copy_descriptors(hs_function); |
367 | |||
368 | obex->hs.obex_in = usb_find_endpoint(hs_function, | ||
369 | f->hs_descriptors, &obex_hs_ep_in_desc); | ||
370 | obex->hs.obex_out = usb_find_endpoint(hs_function, | ||
371 | f->hs_descriptors, &obex_hs_ep_out_desc); | ||
372 | } | 358 | } |
373 | 359 | ||
374 | /* Avoid letting this gadget enumerate until the userspace | 360 | /* Avoid letting this gadget enumerate until the userspace |
diff --git a/drivers/usb/gadget/f_phonet.c b/drivers/usb/gadget/f_phonet.c index dc63f161a10a..0d6d26090da9 100644 --- a/drivers/usb/gadget/f_phonet.c +++ b/drivers/usb/gadget/f_phonet.c | |||
@@ -429,12 +429,12 @@ static int pn_set_alt(struct usb_function *f, unsigned intf, unsigned alt) | |||
429 | if (alt == 1) { | 429 | if (alt == 1) { |
430 | int i; | 430 | int i; |
431 | 431 | ||
432 | fp->out_ep->desc = ep_choose(gadget, | 432 | if (config_ep_by_speed(gadget, f, fp->in_ep) || |
433 | &pn_hs_sink_desc, | 433 | config_ep_by_speed(gadget, f, fp->out_ep)) { |
434 | &pn_fs_sink_desc); | 434 | fp->in_ep->desc = NULL; |
435 | fp->in_ep->desc = ep_choose(gadget, | 435 | fp->out_ep->desc = NULL; |
436 | &pn_hs_source_desc, | 436 | return -EINVAL; |
437 | &pn_fs_source_desc); | 437 | } |
438 | usb_ep_enable(fp->out_ep); | 438 | usb_ep_enable(fp->out_ep); |
439 | usb_ep_enable(fp->in_ep); | 439 | usb_ep_enable(fp->in_ep); |
440 | 440 | ||
diff --git a/drivers/usb/gadget/f_rndis.c b/drivers/usb/gadget/f_rndis.c index 4646254a8924..b324efa07733 100644 --- a/drivers/usb/gadget/f_rndis.c +++ b/drivers/usb/gadget/f_rndis.c | |||
@@ -76,21 +76,12 @@ | |||
76 | * - MS-Windows drivers sometimes emit undocumented requests. | 76 | * - MS-Windows drivers sometimes emit undocumented requests. |
77 | */ | 77 | */ |
78 | 78 | ||
79 | struct rndis_ep_descs { | ||
80 | struct usb_endpoint_descriptor *in; | ||
81 | struct usb_endpoint_descriptor *out; | ||
82 | struct usb_endpoint_descriptor *notify; | ||
83 | }; | ||
84 | |||
85 | struct f_rndis { | 79 | struct f_rndis { |
86 | struct gether port; | 80 | struct gether port; |
87 | u8 ctrl_id, data_id; | 81 | u8 ctrl_id, data_id; |
88 | u8 ethaddr[ETH_ALEN]; | 82 | u8 ethaddr[ETH_ALEN]; |
89 | int config; | 83 | int config; |
90 | 84 | ||
91 | struct rndis_ep_descs fs; | ||
92 | struct rndis_ep_descs hs; | ||
93 | |||
94 | struct usb_ep *notify; | 85 | struct usb_ep *notify; |
95 | struct usb_request *notify_req; | 86 | struct usb_request *notify_req; |
96 | atomic_t notify_count; | 87 | atomic_t notify_count; |
@@ -483,11 +474,11 @@ static int rndis_set_alt(struct usb_function *f, unsigned intf, unsigned alt) | |||
483 | if (rndis->notify->driver_data) { | 474 | if (rndis->notify->driver_data) { |
484 | VDBG(cdev, "reset rndis control %d\n", intf); | 475 | VDBG(cdev, "reset rndis control %d\n", intf); |
485 | usb_ep_disable(rndis->notify); | 476 | usb_ep_disable(rndis->notify); |
486 | } else { | 477 | } |
478 | if (!rndis->notify->desc) { | ||
487 | VDBG(cdev, "init rndis ctrl %d\n", intf); | 479 | VDBG(cdev, "init rndis ctrl %d\n", intf); |
488 | rndis->notify->desc = ep_choose(cdev->gadget, | 480 | if (config_ep_by_speed(cdev->gadget, f, rndis->notify)) |
489 | rndis->hs.notify, | 481 | goto fail; |
490 | rndis->fs.notify); | ||
491 | } | 482 | } |
492 | usb_ep_enable(rndis->notify); | 483 | usb_ep_enable(rndis->notify); |
493 | rndis->notify->driver_data = rndis; | 484 | rndis->notify->driver_data = rndis; |
@@ -500,12 +491,16 @@ static int rndis_set_alt(struct usb_function *f, unsigned intf, unsigned alt) | |||
500 | gether_disconnect(&rndis->port); | 491 | gether_disconnect(&rndis->port); |
501 | } | 492 | } |
502 | 493 | ||
503 | if (!rndis->port.in_ep->desc) { | 494 | if (!rndis->port.in_ep->desc || !rndis->port.out_ep->desc) { |
504 | DBG(cdev, "init rndis\n"); | 495 | DBG(cdev, "init rndis\n"); |
505 | rndis->port.in_ep->desc = ep_choose(cdev->gadget, | 496 | if (config_ep_by_speed(cdev->gadget, f, |
506 | rndis->hs.in, rndis->fs.in); | 497 | rndis->port.in_ep) || |
507 | rndis->port.out_ep->desc = ep_choose(cdev->gadget, | 498 | config_ep_by_speed(cdev->gadget, f, |
508 | rndis->hs.out, rndis->fs.out); | 499 | rndis->port.out_ep)) { |
500 | rndis->port.in_ep->desc = NULL; | ||
501 | rndis->port.out_ep->desc = NULL; | ||
502 | goto fail; | ||
503 | } | ||
509 | } | 504 | } |
510 | 505 | ||
511 | /* Avoid ZLPs; they can be troublesome. */ | 506 | /* Avoid ZLPs; they can be troublesome. */ |
@@ -661,13 +656,6 @@ rndis_bind(struct usb_configuration *c, struct usb_function *f) | |||
661 | if (!f->descriptors) | 656 | if (!f->descriptors) |
662 | goto fail; | 657 | goto fail; |
663 | 658 | ||
664 | rndis->fs.in = usb_find_endpoint(eth_fs_function, | ||
665 | f->descriptors, &fs_in_desc); | ||
666 | rndis->fs.out = usb_find_endpoint(eth_fs_function, | ||
667 | f->descriptors, &fs_out_desc); | ||
668 | rndis->fs.notify = usb_find_endpoint(eth_fs_function, | ||
669 | f->descriptors, &fs_notify_desc); | ||
670 | |||
671 | /* support all relevant hardware speeds... we expect that when | 659 | /* support all relevant hardware speeds... we expect that when |
672 | * hardware is dual speed, all bulk-capable endpoints work at | 660 | * hardware is dual speed, all bulk-capable endpoints work at |
673 | * both speeds | 661 | * both speeds |
@@ -685,13 +673,6 @@ rndis_bind(struct usb_configuration *c, struct usb_function *f) | |||
685 | 673 | ||
686 | if (!f->hs_descriptors) | 674 | if (!f->hs_descriptors) |
687 | goto fail; | 675 | goto fail; |
688 | |||
689 | rndis->hs.in = usb_find_endpoint(eth_hs_function, | ||
690 | f->hs_descriptors, &hs_in_desc); | ||
691 | rndis->hs.out = usb_find_endpoint(eth_hs_function, | ||
692 | f->hs_descriptors, &hs_out_desc); | ||
693 | rndis->hs.notify = usb_find_endpoint(eth_hs_function, | ||
694 | f->hs_descriptors, &hs_notify_desc); | ||
695 | } | 676 | } |
696 | 677 | ||
697 | rndis->port.open = rndis_open; | 678 | rndis->port.open = rndis_open; |
diff --git a/drivers/usb/gadget/f_serial.c b/drivers/usb/gadget/f_serial.c index a9ce6261d156..91fdf790ed20 100644 --- a/drivers/usb/gadget/f_serial.c +++ b/drivers/usb/gadget/f_serial.c | |||
@@ -27,18 +27,10 @@ | |||
27 | * if you can arrange appropriate host side drivers. | 27 | * if you can arrange appropriate host side drivers. |
28 | */ | 28 | */ |
29 | 29 | ||
30 | struct gser_descs { | ||
31 | struct usb_endpoint_descriptor *in; | ||
32 | struct usb_endpoint_descriptor *out; | ||
33 | }; | ||
34 | |||
35 | struct f_gser { | 30 | struct f_gser { |
36 | struct gserial port; | 31 | struct gserial port; |
37 | u8 data_id; | 32 | u8 data_id; |
38 | u8 port_num; | 33 | u8 port_num; |
39 | |||
40 | struct gser_descs fs; | ||
41 | struct gser_descs hs; | ||
42 | }; | 34 | }; |
43 | 35 | ||
44 | static inline struct f_gser *func_to_gser(struct usb_function *f) | 36 | static inline struct f_gser *func_to_gser(struct usb_function *f) |
@@ -136,12 +128,15 @@ static int gser_set_alt(struct usb_function *f, unsigned intf, unsigned alt) | |||
136 | if (gser->port.in->driver_data) { | 128 | if (gser->port.in->driver_data) { |
137 | DBG(cdev, "reset generic ttyGS%d\n", gser->port_num); | 129 | DBG(cdev, "reset generic ttyGS%d\n", gser->port_num); |
138 | gserial_disconnect(&gser->port); | 130 | gserial_disconnect(&gser->port); |
139 | } else { | 131 | } |
132 | if (!gser->port.in->desc || !gser->port.out->desc) { | ||
140 | DBG(cdev, "activate generic ttyGS%d\n", gser->port_num); | 133 | DBG(cdev, "activate generic ttyGS%d\n", gser->port_num); |
141 | gser->port.in->desc = ep_choose(cdev->gadget, | 134 | if (!config_ep_by_speed(cdev->gadget, f, gser->port.in) || |
142 | gser->hs.in, gser->fs.in); | 135 | !config_ep_by_speed(cdev->gadget, f, gser->port.out)) { |
143 | gser->port.out->desc = ep_choose(cdev->gadget, | 136 | gser->port.in->desc = NULL; |
144 | gser->hs.out, gser->fs.out); | 137 | gser->port.out->desc = NULL; |
138 | return -EINVAL; | ||
139 | } | ||
145 | } | 140 | } |
146 | gserial_connect(&gser->port, gser->port_num); | 141 | gserial_connect(&gser->port, gser->port_num); |
147 | return 0; | 142 | return 0; |
@@ -193,12 +188,6 @@ gser_bind(struct usb_configuration *c, struct usb_function *f) | |||
193 | /* copy descriptors, and track endpoint copies */ | 188 | /* copy descriptors, and track endpoint copies */ |
194 | f->descriptors = usb_copy_descriptors(gser_fs_function); | 189 | f->descriptors = usb_copy_descriptors(gser_fs_function); |
195 | 190 | ||
196 | gser->fs.in = usb_find_endpoint(gser_fs_function, | ||
197 | f->descriptors, &gser_fs_in_desc); | ||
198 | gser->fs.out = usb_find_endpoint(gser_fs_function, | ||
199 | f->descriptors, &gser_fs_out_desc); | ||
200 | |||
201 | |||
202 | /* support all relevant hardware speeds... we expect that when | 191 | /* support all relevant hardware speeds... we expect that when |
203 | * hardware is dual speed, all bulk-capable endpoints work at | 192 | * hardware is dual speed, all bulk-capable endpoints work at |
204 | * both speeds | 193 | * both speeds |
@@ -211,11 +200,6 @@ gser_bind(struct usb_configuration *c, struct usb_function *f) | |||
211 | 200 | ||
212 | /* copy descriptors, and track endpoint copies */ | 201 | /* copy descriptors, and track endpoint copies */ |
213 | f->hs_descriptors = usb_copy_descriptors(gser_hs_function); | 202 | f->hs_descriptors = usb_copy_descriptors(gser_hs_function); |
214 | |||
215 | gser->hs.in = usb_find_endpoint(gser_hs_function, | ||
216 | f->hs_descriptors, &gser_hs_in_desc); | ||
217 | gser->hs.out = usb_find_endpoint(gser_hs_function, | ||
218 | f->hs_descriptors, &gser_hs_out_desc); | ||
219 | } | 203 | } |
220 | 204 | ||
221 | DBG(cdev, "generic ttyGS%d: %s speed IN/%s OUT/%s\n", | 205 | DBG(cdev, "generic ttyGS%d: %s speed IN/%s OUT/%s\n", |
diff --git a/drivers/usb/gadget/f_sourcesink.c b/drivers/usb/gadget/f_sourcesink.c index 0ffddd33a55c..caf2f95e0346 100644 --- a/drivers/usb/gadget/f_sourcesink.c +++ b/drivers/usb/gadget/f_sourcesink.c | |||
@@ -347,7 +347,9 @@ enable_source_sink(struct usb_composite_dev *cdev, struct f_sourcesink *ss) | |||
347 | 347 | ||
348 | /* one endpoint writes (sources) zeroes IN (to the host) */ | 348 | /* one endpoint writes (sources) zeroes IN (to the host) */ |
349 | ep = ss->in_ep; | 349 | ep = ss->in_ep; |
350 | ep->desc = ep_choose(cdev->gadget, &hs_source_desc, &fs_source_desc); | 350 | result = config_ep_by_speed(cdev->gadget, &(ss->function), ep); |
351 | if (result) | ||
352 | return result; | ||
351 | result = usb_ep_enable(ep); | 353 | result = usb_ep_enable(ep); |
352 | if (result < 0) | 354 | if (result < 0) |
353 | return result; | 355 | return result; |
@@ -364,7 +366,9 @@ fail: | |||
364 | 366 | ||
365 | /* one endpoint reads (sinks) anything OUT (from the host) */ | 367 | /* one endpoint reads (sinks) anything OUT (from the host) */ |
366 | ep = ss->out_ep; | 368 | ep = ss->out_ep; |
367 | ep->desc = ep_choose(cdev->gadget, &hs_sink_desc, &fs_sink_desc); | 369 | result = config_ep_by_speed(cdev->gadget, &(ss->function), ep); |
370 | if (result) | ||
371 | goto fail; | ||
368 | result = usb_ep_enable(ep); | 372 | result = usb_ep_enable(ep); |
369 | if (result < 0) | 373 | if (result < 0) |
370 | goto fail; | 374 | goto fail; |
diff --git a/drivers/usb/gadget/f_subset.c b/drivers/usb/gadget/f_subset.c index aecaed1724aa..93bf676ef507 100644 --- a/drivers/usb/gadget/f_subset.c +++ b/drivers/usb/gadget/f_subset.c | |||
@@ -57,18 +57,10 @@ | |||
57 | * caring about specific product and vendor IDs. | 57 | * caring about specific product and vendor IDs. |
58 | */ | 58 | */ |
59 | 59 | ||
60 | struct geth_descs { | ||
61 | struct usb_endpoint_descriptor *in; | ||
62 | struct usb_endpoint_descriptor *out; | ||
63 | }; | ||
64 | |||
65 | struct f_gether { | 60 | struct f_gether { |
66 | struct gether port; | 61 | struct gether port; |
67 | 62 | ||
68 | char ethaddr[14]; | 63 | char ethaddr[14]; |
69 | |||
70 | struct geth_descs fs; | ||
71 | struct geth_descs hs; | ||
72 | }; | 64 | }; |
73 | 65 | ||
74 | static inline struct f_gether *func_to_geth(struct usb_function *f) | 66 | static inline struct f_gether *func_to_geth(struct usb_function *f) |
@@ -243,10 +235,12 @@ static int geth_set_alt(struct usb_function *f, unsigned intf, unsigned alt) | |||
243 | } | 235 | } |
244 | 236 | ||
245 | DBG(cdev, "init + activate cdc subset\n"); | 237 | DBG(cdev, "init + activate cdc subset\n"); |
246 | geth->port.in_ep->desc = ep_choose(cdev->gadget, | 238 | if (config_ep_by_speed(cdev->gadget, f, geth->port.in_ep) || |
247 | geth->hs.in, geth->fs.in); | 239 | config_ep_by_speed(cdev->gadget, f, geth->port.out_ep)) { |
248 | geth->port.out_ep->desc = ep_choose(cdev->gadget, | 240 | geth->port.in_ep->desc = NULL; |
249 | geth->hs.out, geth->fs.out); | 241 | geth->port.out_ep->desc = NULL; |
242 | return -EINVAL; | ||
243 | } | ||
250 | 244 | ||
251 | net = gether_connect(&geth->port); | 245 | net = gether_connect(&geth->port); |
252 | return IS_ERR(net) ? PTR_ERR(net) : 0; | 246 | return IS_ERR(net) ? PTR_ERR(net) : 0; |
@@ -297,12 +291,6 @@ geth_bind(struct usb_configuration *c, struct usb_function *f) | |||
297 | /* copy descriptors, and track endpoint copies */ | 291 | /* copy descriptors, and track endpoint copies */ |
298 | f->descriptors = usb_copy_descriptors(fs_eth_function); | 292 | f->descriptors = usb_copy_descriptors(fs_eth_function); |
299 | 293 | ||
300 | geth->fs.in = usb_find_endpoint(fs_eth_function, | ||
301 | f->descriptors, &fs_subset_in_desc); | ||
302 | geth->fs.out = usb_find_endpoint(fs_eth_function, | ||
303 | f->descriptors, &fs_subset_out_desc); | ||
304 | |||
305 | |||
306 | /* support all relevant hardware speeds... we expect that when | 294 | /* support all relevant hardware speeds... we expect that when |
307 | * hardware is dual speed, all bulk-capable endpoints work at | 295 | * hardware is dual speed, all bulk-capable endpoints work at |
308 | * both speeds | 296 | * both speeds |
@@ -315,11 +303,6 @@ geth_bind(struct usb_configuration *c, struct usb_function *f) | |||
315 | 303 | ||
316 | /* copy descriptors, and track endpoint copies */ | 304 | /* copy descriptors, and track endpoint copies */ |
317 | f->hs_descriptors = usb_copy_descriptors(hs_eth_function); | 305 | f->hs_descriptors = usb_copy_descriptors(hs_eth_function); |
318 | |||
319 | geth->hs.in = usb_find_endpoint(hs_eth_function, | ||
320 | f->hs_descriptors, &hs_subset_in_desc); | ||
321 | geth->hs.out = usb_find_endpoint(hs_eth_function, | ||
322 | f->hs_descriptors, &hs_subset_out_desc); | ||
323 | } | 306 | } |
324 | 307 | ||
325 | /* NOTE: all that is done without knowing or caring about | 308 | /* NOTE: all that is done without knowing or caring about |
diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h index 2014d6b1babc..99830d63d8f1 100644 --- a/include/linux/usb/composite.h +++ b/include/linux/usb/composite.h | |||
@@ -148,21 +148,6 @@ int usb_interface_id(struct usb_configuration *, struct usb_function *); | |||
148 | int config_ep_by_speed(struct usb_gadget *g, struct usb_function *f, | 148 | int config_ep_by_speed(struct usb_gadget *g, struct usb_function *f, |
149 | struct usb_ep *_ep); | 149 | struct usb_ep *_ep); |
150 | 150 | ||
151 | /** | ||
152 | * ep_choose - select descriptor endpoint at current device speed | ||
153 | * @g: gadget, connected and running at some speed | ||
154 | * @hs: descriptor to use for high speed operation | ||
155 | * @fs: descriptor to use for full or low speed operation | ||
156 | */ | ||
157 | static inline struct usb_endpoint_descriptor * | ||
158 | ep_choose(struct usb_gadget *g, struct usb_endpoint_descriptor *hs, | ||
159 | struct usb_endpoint_descriptor *fs) | ||
160 | { | ||
161 | if (gadget_is_dualspeed(g) && g->speed == USB_SPEED_HIGH) | ||
162 | return hs; | ||
163 | return fs; | ||
164 | } | ||
165 | |||
166 | #define MAX_CONFIG_INTERFACES 16 /* arbitrary; max 255 */ | 151 | #define MAX_CONFIG_INTERFACES 16 /* arbitrary; max 255 */ |
167 | 152 | ||
168 | /** | 153 | /** |
diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h index 0bcc2b76bcd8..d22b4a4936cb 100644 --- a/include/linux/usb/gadget.h +++ b/include/linux/usb/gadget.h | |||
@@ -879,12 +879,6 @@ int usb_gadget_config_buf(const struct usb_config_descriptor *config, | |||
879 | struct usb_descriptor_header **usb_copy_descriptors( | 879 | struct usb_descriptor_header **usb_copy_descriptors( |
880 | struct usb_descriptor_header **); | 880 | struct usb_descriptor_header **); |
881 | 881 | ||
882 | /* return copy of endpoint descriptor given original descriptor set */ | ||
883 | struct usb_endpoint_descriptor *usb_find_endpoint( | ||
884 | struct usb_descriptor_header **src, | ||
885 | struct usb_descriptor_header **copy, | ||
886 | struct usb_endpoint_descriptor *match); | ||
887 | |||
888 | /** | 882 | /** |
889 | * usb_free_descriptors - free descriptors returned by usb_copy_descriptors() | 883 | * usb_free_descriptors - free descriptors returned by usb_copy_descriptors() |
890 | * @v: vector of descriptors | 884 | * @v: vector of descriptors |