From: Johan Hovold <johan@kernel.org>
To: linux-wireless@vger.kernel.org
Cc: Johannes Berg <johannes@sipsolutions.net>,
libertas-dev@lists.infradead.org, linux-kernel@vger.kernel.org,
Johan Hovold <johan@kernel.org>
Subject: [PATCH 3/3] wifi: libertas_tf: refactor endpoint lookup
Date: Mon, 30 Mar 2026 12:32:07 +0200 [thread overview]
Message-ID: <20260330103207.1671926-4-johan@kernel.org> (raw)
In-Reply-To: <20260330103207.1671926-1-johan@kernel.org>
Use the common USB helpers for looking up bulk and interrupt endpoints
(and determining max packet size) instead of open coding.
Note that the driver has an implicit max packet size check which is
kept.
Signed-off-by: Johan Hovold <johan@kernel.org>
---
.../net/wireless/marvell/libertas_tf/if_usb.c | 46 +++++++++----------
1 file changed, 21 insertions(+), 25 deletions(-)
diff --git a/drivers/net/wireless/marvell/libertas_tf/if_usb.c b/drivers/net/wireless/marvell/libertas_tf/if_usb.c
index 07b38f2b8f58..b85c6d783bf7 100644
--- a/drivers/net/wireless/marvell/libertas_tf/if_usb.c
+++ b/drivers/net/wireless/marvell/libertas_tf/if_usb.c
@@ -144,12 +144,12 @@ static const struct lbtf_ops if_usb_ops = {
static int if_usb_probe(struct usb_interface *intf,
const struct usb_device_id *id)
{
+ struct usb_endpoint_descriptor *ep_in, *ep_out;
struct usb_device *udev;
struct usb_host_interface *iface_desc;
- struct usb_endpoint_descriptor *endpoint;
struct lbtf_private *priv;
struct if_usb_card *cardp;
- int i;
+ int ret;
lbtf_deb_enter(LBTF_DEB_USB);
udev = interface_to_usbdev(intf);
@@ -171,31 +171,27 @@ static int if_usb_probe(struct usb_interface *intf,
udev->descriptor.bDeviceSubClass,
udev->descriptor.bDeviceProtocol);
- for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) {
- endpoint = &iface_desc->endpoint[i].desc;
- if (usb_endpoint_is_bulk_in(endpoint)) {
- cardp->ep_in_size =
- le16_to_cpu(endpoint->wMaxPacketSize);
- cardp->ep_in = usb_endpoint_num(endpoint);
-
- lbtf_deb_usbd(&udev->dev, "in_endpoint = %d\n",
- cardp->ep_in);
- lbtf_deb_usbd(&udev->dev, "Bulk in size is %d\n",
- cardp->ep_in_size);
- } else if (usb_endpoint_is_bulk_out(endpoint)) {
- cardp->ep_out_size =
- le16_to_cpu(endpoint->wMaxPacketSize);
- cardp->ep_out = usb_endpoint_num(endpoint);
-
- lbtf_deb_usbd(&udev->dev, "out_endpoint = %d\n",
- cardp->ep_out);
- lbtf_deb_usbd(&udev->dev, "Bulk out size is %d\n",
- cardp->ep_out_size);
- }
+ ret = usb_find_common_endpoints_reverse(iface_desc, &ep_in, &ep_out,
+ NULL, NULL);
+ if (ret) {
+ lbtf_deb_usbd(&udev->dev, "Endpoints not found\n");
+ goto dealloc;
}
+
+ cardp->ep_in_size = usb_endpoint_maxp(ep_in);
+ cardp->ep_in = usb_endpoint_num(ep_in);
+
+ lbtf_deb_usbd(&udev->dev, "in_endpoint = %d\n", cardp->ep_in);
+ lbtf_deb_usbd(&udev->dev, "Bulk in size is %d\n", cardp->ep_in_size);
+
+ cardp->ep_out_size = usb_endpoint_maxp(ep_out);
+ cardp->ep_out = usb_endpoint_num(ep_out);
+
+ lbtf_deb_usbd(&udev->dev, "out_endpoint = %d\n", cardp->ep_out);
+ lbtf_deb_usbd(&udev->dev, "Bulk out size is %d\n", cardp->ep_out_size);
+
if (!cardp->ep_out_size || !cardp->ep_in_size) {
- lbtf_deb_usbd(&udev->dev, "Endpoints not found\n");
- /* Endpoints not found */
+ lbtf_deb_usbd(&udev->dev, "Endpoints not valid\n");
goto dealloc;
}
--
2.52.0
prev parent reply other threads:[~2026-03-30 10:32 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-30 10:32 [PATCH 0/3] wifi: refactor USB endpoint lookups Johan Hovold
2026-03-30 10:32 ` [PATCH 1/3] wifi: at76c50x: refactor endpoint lookup Johan Hovold
2026-03-30 10:32 ` [PATCH 2/3] wifi: libertas: " Johan Hovold
2026-03-30 10:32 ` 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=20260330103207.1671926-4-johan@kernel.org \
--to=johan@kernel.org \
--cc=johannes@sipsolutions.net \
--cc=libertas-dev@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@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