[PATCH 08/16] USB: iowarrior: refactor endpoint retrieval

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 drivers/usb/misc/iowarrior.c | 24 ++++++++----------------
 1 file changed, 8 insertions(+), 16 deletions(-)

diff --git a/drivers/usb/misc/iowarrior.c b/drivers/usb/misc/iowarrior.c
index 37c63cb39714..c3d069a4a9b9 100644
--- a/drivers/usb/misc/iowarrior.c
+++ b/drivers/usb/misc/iowarrior.c
@@ -757,7 +757,6 @@ static int iowarrior_probe(struct usb_interface *interface,
 	struct iowarrior *dev = NULL;
 	struct usb_host_interface *iface_desc;
 	struct usb_endpoint_descriptor *endpoint;
-	int i;
 	int retval = -ENOMEM;
 
 	/* allocate memory for our device state and initialize it */
@@ -781,29 +780,21 @@ static int iowarrior_probe(struct usb_interface *interface,
 	iface_desc = interface->cur_altsetting;
 	dev->product_id = le16_to_cpu(udev->descriptor.idProduct);
 
-	/* set up the endpoint information */
-	for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) {
-		endpoint = &iface_desc->endpoint[i].desc;
-
-		if (usb_endpoint_is_int_in(endpoint))
-			dev->int_in_endpoint = endpoint;
-		if (usb_endpoint_is_int_out(endpoint))
-			/* this one will match for the IOWarrior56 only */
-			dev->int_out_endpoint = endpoint;
-	}
-
-	if (!dev->int_in_endpoint) {
+	retval = usb_find_last_int_in_endpoint(iface_desc, &endpoint);
+	if (retval) {
 		dev_err(&interface->dev, "no interrupt-in endpoint found\n");
-		retval = -ENODEV;
 		goto error;
 	}
 
+	dev->int_in_endpoint = endpoint;
+
 	if (dev->product_id == USB_DEVICE_ID_CODEMERCS_IOW56) {
-		if (!dev->int_out_endpoint) {
+		retval = usb_find_last_int_out_endpoint(iface_desc, &endpoint);
+		if (retval) {
 			dev_err(&interface->dev, "no interrupt-out endpoint found\n");
-			retval = -ENODEV;
 			goto error;
 		}
+		dev->int_out_endpoint = endpoint;
 	}
 
 	/* we have to check the report_size often, so remember it in the endianness suitable for our machine */
@@ -813,6 +804,7 @@ static int iowarrior_probe(struct usb_interface *interface,
 		/* IOWarrior56 has wMaxPacketSize different from report size */
 		dev->report_size = 7;
 
+	retval = -ENOMEM;
 	/* create the urb and buffer for reading */
 	dev->int_in_urb = usb_alloc_urb(0, GFP_KERNEL);
 	if (!dev->int_in_urb)
-- 
2.12.0

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux