]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
comedi: ni_usb6501: refactor endpoint lookup
authorJohan Hovold <johan@kernel.org>
Mon, 30 Mar 2026 09:46:46 +0000 (11:46 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 2 Apr 2026 13:55:01 +0000 (15:55 +0200)
Use the common USB helper for looking up bulk and interrupt endpoints
instead of open coding.

Signed-off-by: Johan Hovold <johan@kernel.org>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Link: https://patch.msgid.link/20260330094646.1623523-1-johan@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/comedi/drivers/ni_usb6501.c

index 0dd9edf7bced3e8ff40212c05183fa48be1c1182..7afc5661a5ecc90e1e5ecf3a4700cfd6f1ff4509 100644 (file)
@@ -477,31 +477,16 @@ static int ni6501_find_endpoints(struct comedi_device *dev)
        struct usb_interface *intf = comedi_to_usb_interface(dev);
        struct ni6501_private *devpriv = dev->private;
        struct usb_host_interface *iface_desc = intf->cur_altsetting;
-       struct usb_endpoint_descriptor *ep_desc;
-       int i;
+       int ret;
 
        if (iface_desc->desc.bNumEndpoints != 2) {
                dev_err(dev->class_dev, "Wrong number of endpoints\n");
                return -ENODEV;
        }
 
-       for (i = 0; i < iface_desc->desc.bNumEndpoints; i++) {
-               ep_desc = &iface_desc->endpoint[i].desc;
-
-               if (usb_endpoint_is_bulk_in(ep_desc)) {
-                       if (!devpriv->ep_rx)
-                               devpriv->ep_rx = ep_desc;
-                       continue;
-               }
-
-               if (usb_endpoint_is_bulk_out(ep_desc)) {
-                       if (!devpriv->ep_tx)
-                               devpriv->ep_tx = ep_desc;
-                       continue;
-               }
-       }
-
-       if (!devpriv->ep_rx || !devpriv->ep_tx)
+       ret = usb_find_common_endpoints(iface_desc, &devpriv->ep_rx,
+                                       &devpriv->ep_tx, NULL, NULL);
+       if (ret)
                return -ENODEV;
 
        if (usb_endpoint_maxp(devpriv->ep_rx) < RX_MAX_SIZE)