aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/gadget/f_rndis.c
diff options
context:
space:
mode:
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>2012-10-22 16:15:06 -0400
committerFelipe Balbi <balbi@ti.com>2012-10-31 09:09:44 -0400
commit10287baec761d33f0a82d84b46e37a44030350d8 (patch)
treeb769a6dddfd4ccf81a986386bf5771182d1b0c55 /drivers/usb/gadget/f_rndis.c
parent0f9df939385527049c8062a099fbfa1479fe7ce0 (diff)
usb: gadget: always update HS/SS descriptors and create a copy of them
HS and SS descriptors are staticaly created. They are updated during the bind process with the endpoint address, string id or interface numbers. After that, the descriptor chain is linked to struct usb_function which is used by composite in order to serve the GET_DESCRIPTOR requests, number of available configs and so on. There is no need to assign the HS descriptor only if the UDC supports HS speed because composite won't report those to the host if HS support has not been reached. The same reasoning is valid for SS. This patch makes sure each function updates HS/SS descriptors unconditionally and uses the newly introduced helper function to create a copy the descriptors for the speed which is supported by the UDC. While at that, also rename f->descriptors to f->fs_descriptors in order to make it more explicit what that means. Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/gadget/f_rndis.c')
-rw-r--r--drivers/usb/gadget/f_rndis.c55
1 files changed, 13 insertions, 42 deletions
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
790fail: 770fail:
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);