aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/gadget/f_rndis.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/gadget/f_rndis.c')
-rw-r--r--drivers/usb/gadget/f_rndis.c45
1 files changed, 13 insertions, 32 deletions
diff --git a/drivers/usb/gadget/f_rndis.c b/drivers/usb/gadget/f_rndis.c
index 4646254a892..b324efa0773 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
79struct rndis_ep_descs {
80 struct usb_endpoint_descriptor *in;
81 struct usb_endpoint_descriptor *out;
82 struct usb_endpoint_descriptor *notify;
83};
84
85struct f_rndis { 79struct 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;