From: Johan Hovold <johan@kernel.org>
To: netdev@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, Johan Hovold <johan@kernel.org>
Subject: [PATCH 3/3] nfc: port100: refactor endpoint lookup
Date: Mon, 30 Mar 2026 12:36:55 +0200 [thread overview]
Message-ID: <20260330103655.1672331-4-johan@kernel.org> (raw)
In-Reply-To: <20260330103655.1672331-1-johan@kernel.org>
Use the common USB helpers for looking up bulk and interrupt endpoints
(and determining endpoint numbers) instead of open coding.
Signed-off-by: Johan Hovold <johan@kernel.org>
---
drivers/nfc/port100.c | 27 ++++++---------------------
1 file changed, 6 insertions(+), 21 deletions(-)
diff --git a/drivers/nfc/port100.c b/drivers/nfc/port100.c
index 09dcc6f4c4f3..5ae61d7ebcfe 100644
--- a/drivers/nfc/port100.c
+++ b/drivers/nfc/port100.c
@@ -1489,15 +1489,11 @@ MODULE_DEVICE_TABLE(usb, port100_table);
static int port100_probe(struct usb_interface *interface,
const struct usb_device_id *id)
{
+ struct usb_endpoint_descriptor *ep_in, *ep_out;
struct port100 *dev;
int rc;
- struct usb_host_interface *iface_desc;
- struct usb_endpoint_descriptor *endpoint;
- int in_endpoint;
- int out_endpoint;
u16 fw_version;
u64 cmd_type_mask;
- int i;
dev = devm_kzalloc(&interface->dev, sizeof(struct port100), GFP_KERNEL);
if (!dev)
@@ -1508,22 +1504,11 @@ static int port100_probe(struct usb_interface *interface,
dev->interface = interface;
usb_set_intfdata(interface, dev);
- in_endpoint = out_endpoint = 0;
- iface_desc = interface->cur_altsetting;
- for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) {
- endpoint = &iface_desc->endpoint[i].desc;
-
- if (!in_endpoint && usb_endpoint_is_bulk_in(endpoint))
- in_endpoint = endpoint->bEndpointAddress;
-
- if (!out_endpoint && usb_endpoint_is_bulk_out(endpoint))
- out_endpoint = endpoint->bEndpointAddress;
- }
-
- if (!in_endpoint || !out_endpoint) {
+ rc = usb_find_common_endpoints(interface->cur_altsetting, &ep_in,
+ &ep_out, NULL, NULL);
+ if (rc) {
nfc_err(&interface->dev,
"Could not find bulk-in or bulk-out endpoint\n");
- rc = -ENODEV;
goto error;
}
@@ -1537,10 +1522,10 @@ static int port100_probe(struct usb_interface *interface,
}
usb_fill_bulk_urb(dev->in_urb, dev->udev,
- usb_rcvbulkpipe(dev->udev, in_endpoint),
+ usb_rcvbulkpipe(dev->udev, usb_endpoint_num(ep_in)),
NULL, 0, NULL, dev);
usb_fill_bulk_urb(dev->out_urb, dev->udev,
- usb_sndbulkpipe(dev->udev, out_endpoint),
+ usb_sndbulkpipe(dev->udev, usb_endpoint_num(ep_out)),
NULL, 0, port100_send_complete, dev);
dev->out_urb->transfer_flags = URB_ZERO_PACKET;
--
2.52.0
prev parent reply other threads:[~2026-03-30 10:37 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-30 10:36 [PATCH 0/3] nfc: refactor USB endpoint lookups Johan Hovold
2026-03-30 10:36 ` [PATCH 1/3] nfc: nfcmrvl: refactor endpoint lookup Johan Hovold
2026-03-30 10:36 ` [PATCH 2/3] nfc: pn533: " Johan Hovold
2026-03-30 10:36 ` Johan Hovold [this message]
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=20260330103655.1672331-4-johan@kernel.org \
--to=johan@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox