diff options
author | Johan Hovold <johan@kernel.org> | 2017-03-17 06:35:40 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-03-23 08:53:53 -0400 |
commit | 2707ca16c2d400c8e2e619944470fb72ea96489f (patch) | |
tree | 9fcf1fbefc6b79aeb679fcacceecc55db29af7f9 /drivers/usb/misc/ldusb.c | |
parent | 920df8d7facde29e4124cae95ebb8de1661e17e5 (diff) |
USB: ldusb: refactor endpoint retrieval
Use the new endpoint helpers to lookup the required interrupt-in
endpoint and optional interrupt-out endpoint.
Note that the descriptors are searched in reverse order to avoid any
regressions.
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/misc/ldusb.c')
-rw-r--r-- | drivers/usb/misc/ldusb.c | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/drivers/usb/misc/ldusb.c b/drivers/usb/misc/ldusb.c index 77b76b468307..9d9487c66f87 100644 --- a/drivers/usb/misc/ldusb.c +++ b/drivers/usb/misc/ldusb.c | |||
@@ -650,10 +650,9 @@ static int ld_usb_probe(struct usb_interface *intf, const struct usb_device_id * | |||
650 | struct usb_device *udev = interface_to_usbdev(intf); | 650 | struct usb_device *udev = interface_to_usbdev(intf); |
651 | struct ld_usb *dev = NULL; | 651 | struct ld_usb *dev = NULL; |
652 | struct usb_host_interface *iface_desc; | 652 | struct usb_host_interface *iface_desc; |
653 | struct usb_endpoint_descriptor *endpoint; | ||
654 | char *buffer; | 653 | char *buffer; |
655 | int i; | ||
656 | int retval = -ENOMEM; | 654 | int retval = -ENOMEM; |
655 | int res; | ||
657 | 656 | ||
658 | /* allocate memory for our device state and initialize it */ | 657 | /* allocate memory for our device state and initialize it */ |
659 | 658 | ||
@@ -681,21 +680,17 @@ static int ld_usb_probe(struct usb_interface *intf, const struct usb_device_id * | |||
681 | 680 | ||
682 | iface_desc = intf->cur_altsetting; | 681 | iface_desc = intf->cur_altsetting; |
683 | 682 | ||
684 | /* set up the endpoint information */ | 683 | res = usb_find_last_int_in_endpoint(iface_desc, |
685 | for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) { | 684 | &dev->interrupt_in_endpoint); |
686 | endpoint = &iface_desc->endpoint[i].desc; | 685 | if (res) { |
687 | |||
688 | if (usb_endpoint_is_int_in(endpoint)) | ||
689 | dev->interrupt_in_endpoint = endpoint; | ||
690 | |||
691 | if (usb_endpoint_is_int_out(endpoint)) | ||
692 | dev->interrupt_out_endpoint = endpoint; | ||
693 | } | ||
694 | if (dev->interrupt_in_endpoint == NULL) { | ||
695 | dev_err(&intf->dev, "Interrupt in endpoint not found\n"); | 686 | dev_err(&intf->dev, "Interrupt in endpoint not found\n"); |
687 | retval = res; | ||
696 | goto error; | 688 | goto error; |
697 | } | 689 | } |
698 | if (dev->interrupt_out_endpoint == NULL) | 690 | |
691 | res = usb_find_last_int_out_endpoint(iface_desc, | ||
692 | &dev->interrupt_out_endpoint); | ||
693 | if (res) | ||
699 | dev_warn(&intf->dev, "Interrupt out endpoint not found (using control endpoint instead)\n"); | 694 | dev_warn(&intf->dev, "Interrupt out endpoint not found (using control endpoint instead)\n"); |
700 | 695 | ||
701 | dev->interrupt_in_endpoint_size = usb_endpoint_maxp(dev->interrupt_in_endpoint); | 696 | dev->interrupt_in_endpoint_size = usb_endpoint_maxp(dev->interrupt_in_endpoint); |