summaryrefslogtreecommitdiffstats
path: root/drivers/usb/misc
diff options
context:
space:
mode:
authorJohan Hovold <johan@kernel.org>2017-03-17 11:35:38 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-03-23 13:53:52 +0100
commitfa38442eaac1f5a3ba883c91bdc772e77d35bf27 (patch)
tree38d6c7d4eabf244f063e568ec6a8a6bdd5f45b79 /drivers/usb/misc
parent50129f74548b5075187fa4908c2ba3a081ec1b67 (diff)
downloadlinux-fa38442eaac1f5a3ba883c91bdc772e77d35bf27.tar.bz2
USB: idmouse: refactor endpoint retrieval
Use the new endpoint helpers to lookup the required bulk-in endpoint. Note that we now pick the first bulk-in endpoint regardless of whether it happens to be the first descriptor. Signed-off-by: Johan Hovold <johan@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/misc')
-rw-r--r--drivers/usb/misc/idmouse.c28
1 files changed, 12 insertions, 16 deletions
diff --git a/drivers/usb/misc/idmouse.c b/drivers/usb/misc/idmouse.c
index 8b9fd7534f69..d185f49c353e 100644
--- a/drivers/usb/misc/idmouse.c
+++ b/drivers/usb/misc/idmouse.c
@@ -357,26 +357,22 @@ static int idmouse_probe(struct usb_interface *interface,
dev->interface = interface;
/* set up the endpoint information - use only the first bulk-in endpoint */
- endpoint = &iface_desc->endpoint[0].desc;
- if (!dev->bulk_in_endpointAddr && usb_endpoint_is_bulk_in(endpoint)) {
- /* we found a bulk in endpoint */
- dev->orig_bi_size = usb_endpoint_maxp(endpoint);
- dev->bulk_in_size = 0x200; /* works _much_ faster */
- dev->bulk_in_endpointAddr = endpoint->bEndpointAddress;
- dev->bulk_in_buffer =
- kmalloc(IMGSIZE + dev->bulk_in_size, GFP_KERNEL);
-
- if (!dev->bulk_in_buffer) {
- idmouse_delete(dev);
- return -ENOMEM;
- }
+ result = usb_find_bulk_in_endpoint(iface_desc, &endpoint);
+ if (result) {
+ dev_err(&interface->dev, "Unable to find bulk-in endpoint.\n");
+ idmouse_delete(dev);
+ return result;
}
- if (!(dev->bulk_in_endpointAddr)) {
- dev_err(&interface->dev, "Unable to find bulk-in endpoint.\n");
+ dev->orig_bi_size = usb_endpoint_maxp(endpoint);
+ dev->bulk_in_size = 0x200; /* works _much_ faster */
+ dev->bulk_in_endpointAddr = endpoint->bEndpointAddress;
+ dev->bulk_in_buffer = kmalloc(IMGSIZE + dev->bulk_in_size, GFP_KERNEL);
+ if (!dev->bulk_in_buffer) {
idmouse_delete(dev);
- return -ENODEV;
+ return -ENOMEM;
}
+
/* allow device read, write and ioctl */
dev->present = 1;