USB: chaoskey: refactor endpoint retrieval
Use the new endpoint helpers to lookup the required bulk-in endpoint. Signed-off-by: Johan Hovold <johan@kernel.org> Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
c77b8855c6
commit
a8bbb0f8db
@ -117,28 +117,26 @@ static int chaoskey_probe(struct usb_interface *interface,
|
|||||||
{
|
{
|
||||||
struct usb_device *udev = interface_to_usbdev(interface);
|
struct usb_device *udev = interface_to_usbdev(interface);
|
||||||
struct usb_host_interface *altsetting = interface->cur_altsetting;
|
struct usb_host_interface *altsetting = interface->cur_altsetting;
|
||||||
int i;
|
struct usb_endpoint_descriptor *epd;
|
||||||
int in_ep = -1;
|
int in_ep;
|
||||||
struct chaoskey *dev;
|
struct chaoskey *dev;
|
||||||
int result = -ENOMEM;
|
int result = -ENOMEM;
|
||||||
int size;
|
int size;
|
||||||
|
int res;
|
||||||
|
|
||||||
usb_dbg(interface, "probe %s-%s", udev->product, udev->serial);
|
usb_dbg(interface, "probe %s-%s", udev->product, udev->serial);
|
||||||
|
|
||||||
/* Find the first bulk IN endpoint and its packet size */
|
/* Find the first bulk IN endpoint and its packet size */
|
||||||
for (i = 0; i < altsetting->desc.bNumEndpoints; i++) {
|
res = usb_find_bulk_in_endpoint(altsetting, &epd);
|
||||||
if (usb_endpoint_is_bulk_in(&altsetting->endpoint[i].desc)) {
|
if (res) {
|
||||||
in_ep = usb_endpoint_num(&altsetting->endpoint[i].desc);
|
usb_dbg(interface, "no IN endpoint found");
|
||||||
size = usb_endpoint_maxp(&altsetting->endpoint[i].desc);
|
return res;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
in_ep = usb_endpoint_num(epd);
|
||||||
|
size = usb_endpoint_maxp(epd);
|
||||||
|
|
||||||
/* Validate endpoint and size */
|
/* Validate endpoint and size */
|
||||||
if (in_ep == -1) {
|
|
||||||
usb_dbg(interface, "no IN endpoint found");
|
|
||||||
return -ENODEV;
|
|
||||||
}
|
|
||||||
if (size <= 0) {
|
if (size <= 0) {
|
||||||
usb_dbg(interface, "invalid size (%d)", size);
|
usb_dbg(interface, "invalid size (%d)", size);
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
Loading…
Reference in New Issue
Block a user