From: Johan Hovold Date: Mon, 30 Mar 2026 10:26:11 +0000 (+0200) Subject: net: ipeth: refactor endpoint lookup X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=abfca6b13bcfe4f2b70a88190d61f162656ed44e;p=thirdparty%2Fkernel%2Flinux.git net: ipeth: refactor endpoint lookup Use the common USB helper for looking up bulk and interrupt endpoints instead of open coding. Signed-off-by: Johan Hovold Link: https://patch.msgid.link/20260330102611.1671546-3-johan@kernel.org Signed-off-by: Jakub Kicinski --- diff --git a/drivers/net/usb/ipheth.c b/drivers/net/usb/ipheth.c index a19789b57190..bb1364f85bd1 100644 --- a/drivers/net/usb/ipheth.c +++ b/drivers/net/usb/ipheth.c @@ -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;