Use the new endpoint helpers to lookup the required bulk-in endpoint. Signed-off-by: Johan Hovold <johan@xxxxxxxxxx> --- drivers/usb/misc/chaoskey.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/drivers/usb/misc/chaoskey.c b/drivers/usb/misc/chaoskey.c index aa350dc9eb25..9adfbb351eb7 100644 --- a/drivers/usb/misc/chaoskey.c +++ b/drivers/usb/misc/chaoskey.c @@ -117,28 +117,25 @@ static int chaoskey_probe(struct usb_interface *interface, { struct usb_device *udev = interface_to_usbdev(interface); struct usb_host_interface *altsetting = interface->cur_altsetting; - int i; + struct usb_endpoint_descriptor *epd; int in_ep = -1; struct chaoskey *dev; - int result = -ENOMEM; + int result; int size; usb_dbg(interface, "probe %s-%s", udev->product, udev->serial); /* Find the first bulk IN endpoint and its packet size */ - for (i = 0; i < altsetting->desc.bNumEndpoints; i++) { - if (usb_endpoint_is_bulk_in(&altsetting->endpoint[i].desc)) { - in_ep = usb_endpoint_num(&altsetting->endpoint[i].desc); - size = usb_endpoint_maxp(&altsetting->endpoint[i].desc); - break; - } + result = usb_find_bulk_in_endpoint(altsetting, &epd); + if (result) { + usb_dbg(interface, "no IN endpoint found"); + return result; } + in_ep = usb_endpoint_num(epd); + size = usb_endpoint_maxp(epd); + /* Validate endpoint and size */ - if (in_ep == -1) { - usb_dbg(interface, "no IN endpoint found"); - return -ENODEV; - } if (size <= 0) { usb_dbg(interface, "invalid size (%d)", size); return -ENODEV; @@ -151,7 +148,7 @@ static int chaoskey_probe(struct usb_interface *interface, } /* Looks good, allocate and initialize */ - + result = -ENOMEM; dev = kzalloc(sizeof(struct chaoskey), GFP_KERNEL); if (dev == NULL) -- 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