aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Hovold <johan@kernel.org>2017-03-17 06:35:39 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-03-23 08:53:52 -0400
commit920df8d7facde29e4124cae95ebb8de1661e17e5 (patch)
tree1921f1b90d6a08ce083f48c6482743c92f3d7728
parentfa38442eaac1f5a3ba883c91bdc772e77d35bf27 (diff)
USB: iowarrior: refactor endpoint retrieval
Use the new endpoint helpers to lookup the required interrupt-in endpoint. IOWarror56 devices also requires an interrupt-out endpoint, which is looked up in a second call. 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>
-rw-r--r--drivers/usb/misc/iowarrior.c25
1 files changed, 8 insertions, 17 deletions
diff --git a/drivers/usb/misc/iowarrior.c b/drivers/usb/misc/iowarrior.c
index 37c63cb39714..77569531b78a 100644
--- a/drivers/usb/misc/iowarrior.c
+++ b/drivers/usb/misc/iowarrior.c
@@ -756,9 +756,8 @@ static int iowarrior_probe(struct usb_interface *interface,
756 struct usb_device *udev = interface_to_usbdev(interface); 756 struct usb_device *udev = interface_to_usbdev(interface);
757 struct iowarrior *dev = NULL; 757 struct iowarrior *dev = NULL;
758 struct usb_host_interface *iface_desc; 758 struct usb_host_interface *iface_desc;
759 struct usb_endpoint_descriptor *endpoint;
760 int i;
761 int retval = -ENOMEM; 759 int retval = -ENOMEM;
760 int res;
762 761
763 /* allocate memory for our device state and initialize it */ 762 /* allocate memory for our device state and initialize it */
764 dev = kzalloc(sizeof(struct iowarrior), GFP_KERNEL); 763 dev = kzalloc(sizeof(struct iowarrior), GFP_KERNEL);
@@ -781,27 +780,19 @@ static int iowarrior_probe(struct usb_interface *interface,
781 iface_desc = interface->cur_altsetting; 780 iface_desc = interface->cur_altsetting;
782 dev->product_id = le16_to_cpu(udev->descriptor.idProduct); 781 dev->product_id = le16_to_cpu(udev->descriptor.idProduct);
783 782
784 /* set up the endpoint information */ 783 res = usb_find_last_int_in_endpoint(iface_desc, &dev->int_in_endpoint);
785 for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) { 784 if (res) {
786 endpoint = &iface_desc->endpoint[i].desc;
787
788 if (usb_endpoint_is_int_in(endpoint))
789 dev->int_in_endpoint = endpoint;
790 if (usb_endpoint_is_int_out(endpoint))
791 /* this one will match for the IOWarrior56 only */
792 dev->int_out_endpoint = endpoint;
793 }
794
795 if (!dev->int_in_endpoint) {
796 dev_err(&interface->dev, "no interrupt-in endpoint found\n"); 785 dev_err(&interface->dev, "no interrupt-in endpoint found\n");
797 retval = -ENODEV; 786 retval = res;
798 goto error; 787 goto error;
799 } 788 }
800 789
801 if (dev->product_id == USB_DEVICE_ID_CODEMERCS_IOW56) { 790 if (dev->product_id == USB_DEVICE_ID_CODEMERCS_IOW56) {
802 if (!dev->int_out_endpoint) { 791 res = usb_find_last_int_out_endpoint(iface_desc,
792 &dev->int_out_endpoint);
793 if (res) {
803 dev_err(&interface->dev, "no interrupt-out endpoint found\n"); 794 dev_err(&interface->dev, "no interrupt-out endpoint found\n");
804 retval = -ENODEV; 795 retval = res;
805 goto error; 796 goto error;
806 } 797 }
807 } 798 }