]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net: ipeth: refactor endpoint lookup
authorJohan Hovold <johan@kernel.org>
Mon, 30 Mar 2026 10:26:11 +0000 (12:26 +0200)
committerJakub Kicinski <kuba@kernel.org>
Wed, 1 Apr 2026 02:23:41 +0000 (19:23 -0700)
Use the common USB helper for looking up bulk and interrupt endpoints
instead of open coding.

Signed-off-by: Johan Hovold <johan@kernel.org>
Link: https://patch.msgid.link/20260330102611.1671546-3-johan@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/usb/ipheth.c

index a19789b571905a36a587528d6f6651c6b35af11d..bb1364f85bd1fcdf074e91c582eaa6b2a9451798 100644 (file)
@@ -573,11 +573,10 @@ static int ipheth_probe(struct usb_interface *intf,
                        const struct usb_device_id *id)
 {
        struct usb_device *udev = interface_to_usbdev(intf);
+       struct usb_endpoint_descriptor *ep_in, *ep_out;
        struct usb_host_interface *hintf;
-       struct usb_endpoint_descriptor *endp;
        struct ipheth_device *dev;
        struct net_device *netdev;
-       int i;
        int retval;
 
        netdev = alloc_etherdev(sizeof(struct ipheth_device));
@@ -603,19 +602,16 @@ static int ipheth_probe(struct usb_interface *intf,
                goto err_endpoints;
        }
 
-       for (i = 0; i < hintf->desc.bNumEndpoints; i++) {
-               endp = &hintf->endpoint[i].desc;
-               if (usb_endpoint_is_bulk_in(endp))
-                       dev->bulk_in = endp->bEndpointAddress;
-               else if (usb_endpoint_is_bulk_out(endp))
-                       dev->bulk_out = endp->bEndpointAddress;
-       }
-       if (!(dev->bulk_in && dev->bulk_out)) {
-               retval = -ENODEV;
+       retval = usb_find_common_endpoints_reverse(hintf, &ep_in, &ep_out,
+                                                  NULL, NULL);
+       if (retval) {
                dev_err(&intf->dev, "Unable to find endpoints\n");
                goto err_endpoints;
        }
 
+       dev->bulk_in = ep_in->bEndpointAddress;
+       dev->bulk_out = ep_out->bEndpointAddress;
+
        dev->ctrl_buf = kmalloc(IPHETH_CTRL_BUF_SIZE, GFP_KERNEL);
        if (dev->ctrl_buf == NULL) {
                retval = -ENOMEM;