public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Johan Hovold <johan@kernel.org>
To: netdev@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, Johan Hovold <johan@kernel.org>
Subject: [PATCH 1/3] nfc: nfcmrvl: refactor endpoint lookup
Date: Mon, 30 Mar 2026 12:36:53 +0200	[thread overview]
Message-ID: <20260330103655.1672331-2-johan@kernel.org> (raw)
In-Reply-To: <20260330103655.1672331-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/nfc/nfcmrvl/usb.c | 20 ++++----------------
 1 file changed, 4 insertions(+), 16 deletions(-)

diff --git a/drivers/nfc/nfcmrvl/usb.c b/drivers/nfc/nfcmrvl/usb.c
index ea7309453096..6c4711c869f0 100644
--- a/drivers/nfc/nfcmrvl/usb.c
+++ b/drivers/nfc/nfcmrvl/usb.c
@@ -288,9 +288,9 @@ static int nfcmrvl_probe(struct usb_interface *intf,
 {
 	struct nfcmrvl_usb_drv_data *drv_data;
 	struct nfcmrvl_private *priv;
-	int i;
 	struct usb_device *udev = interface_to_usbdev(intf);
 	struct nfcmrvl_platform_data config;
+	int ret;
 
 	/* No configuration for USB */
 	memset(&config, 0, sizeof(config));
@@ -302,21 +302,9 @@ static int nfcmrvl_probe(struct usb_interface *intf,
 	if (!drv_data)
 		return -ENOMEM;
 
-	for (i = 0; i < intf->cur_altsetting->desc.bNumEndpoints; i++) {
-		struct usb_endpoint_descriptor *ep_desc;
-
-		ep_desc = &intf->cur_altsetting->endpoint[i].desc;
-
-		if (!drv_data->bulk_tx_ep &&
-		    usb_endpoint_is_bulk_out(ep_desc)) {
-			drv_data->bulk_tx_ep = ep_desc;
-		} else if (!drv_data->bulk_rx_ep &&
-			   usb_endpoint_is_bulk_in(ep_desc)) {
-			drv_data->bulk_rx_ep = ep_desc;
-		}
-	}
-
-	if (!drv_data->bulk_tx_ep || !drv_data->bulk_rx_ep)
+	ret = usb_find_common_endpoints(intf->cur_altsetting, &drv_data->bulk_rx_ep,
+					&drv_data->bulk_tx_ep, NULL, NULL);
+	if (ret)
 		return -ENODEV;
 
 	drv_data->udev = udev;
-- 
2.52.0


  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 ` Johan Hovold [this message]
2026-03-30 10:36 ` [PATCH 2/3] nfc: pn533: refactor endpoint lookup Johan Hovold
2026-03-30 10:36 ` [PATCH 3/3] nfc: port100: " Johan Hovold

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-2-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