From: Johan Hovold <johan@kernel.org>
To: Andrew Lunn <andrew+netdev@lunn.ch>,
"David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: linux-usb@vger.kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, Johan Hovold <johan@kernel.org>
Subject: [PATCH 2/2] net: ipeth: refactor endpoint lookup
Date: Mon, 30 Mar 2026 12:26:11 +0200 [thread overview]
Message-ID: <20260330102611.1671546-3-johan@kernel.org> (raw)
In-Reply-To: <20260330102611.1671546-1-johan@kernel.org>
Use the common USB helper for looking up bulk and interrupt endpoints
instead of open coding.
Signed-off-by: Johan Hovold <johan@kernel.org>
---
drivers/net/usb/ipheth.c | 18 +++++++-----------
1 file changed, 7 insertions(+), 11 deletions(-)
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;
--
2.52.0
next prev parent reply other threads:[~2026-03-30 10:26 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-30 10:26 [PATCH 0/2] net: refactor USB endpoint lookups Johan Hovold
2026-03-30 10:26 ` [PATCH 1/2] net: hso: refactor endpoint lookup Johan Hovold
2026-03-30 10:26 ` Johan Hovold [this message]
2026-04-01 2:30 ` [PATCH 0/2] net: refactor USB endpoint lookups patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260330102611.1671546-3-johan@kernel.org \
--to=johan@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.