diff options
author | Johan Hovold <johan@kernel.org> | 2017-03-17 06:35:38 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-03-23 08:53:52 -0400 |
commit | fa38442eaac1f5a3ba883c91bdc772e77d35bf27 (patch) | |
tree | 38d6c7d4eabf244f063e568ec6a8a6bdd5f45b79 /drivers/usb/misc/idmouse.c | |
parent | 50129f74548b5075187fa4908c2ba3a081ec1b67 (diff) |
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/idmouse.c')
-rw-r--r-- | drivers/usb/misc/idmouse.c | 28 |
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, | |||
357 | dev->interface = interface; | 357 | dev->interface = interface; |
358 | 358 | ||
359 | /* set up the endpoint information - use only the first bulk-in endpoint */ | 359 | /* set up the endpoint information - use only the first bulk-in endpoint */ |
360 | endpoint = &iface_desc->endpoint[0].desc; | 360 | result = usb_find_bulk_in_endpoint(iface_desc, &endpoint); |
361 | if (!dev->bulk_in_endpointAddr && usb_endpoint_is_bulk_in(endpoint)) { | 361 | if (result) { |
362 | /* we found a bulk in endpoint */ | 362 | dev_err(&interface->dev, "Unable to find bulk-in endpoint.\n"); |
363 | dev->orig_bi_size = usb_endpoint_maxp(endpoint); | 363 | idmouse_delete(dev); |
364 | dev->bulk_in_size = 0x200; /* works _much_ faster */ | 364 | return result; |
365 | dev->bulk_in_endpointAddr = endpoint->bEndpointAddress; | ||
366 | dev->bulk_in_buffer = | ||
367 | kmalloc(IMGSIZE + dev->bulk_in_size, GFP_KERNEL); | ||
368 | |||
369 | if (!dev->bulk_in_buffer) { | ||
370 | idmouse_delete(dev); | ||
371 | return -ENOMEM; | ||
372 | } | ||
373 | } | 365 | } |
374 | 366 | ||
375 | if (!(dev->bulk_in_endpointAddr)) { | 367 | dev->orig_bi_size = usb_endpoint_maxp(endpoint); |
376 | dev_err(&interface->dev, "Unable to find bulk-in endpoint.\n"); | 368 | dev->bulk_in_size = 0x200; /* works _much_ faster */ |
369 | dev->bulk_in_endpointAddr = endpoint->bEndpointAddress; | ||
370 | dev->bulk_in_buffer = kmalloc(IMGSIZE + dev->bulk_in_size, GFP_KERNEL); | ||
371 | if (!dev->bulk_in_buffer) { | ||
377 | idmouse_delete(dev); | 372 | idmouse_delete(dev); |
378 | return -ENODEV; | 373 | return -ENOMEM; |
379 | } | 374 | } |
375 | |||
380 | /* allow device read, write and ioctl */ | 376 | /* allow device read, write and ioctl */ |
381 | dev->present = 1; | 377 | dev->present = 1; |
382 | 378 | ||