aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/gadget/f_hid.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/gadget/f_hid.c')
-rw-r--r--drivers/usb/gadget/f_hid.c30
1 files changed, 10 insertions, 20 deletions
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);