Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

wifi: libertas: refactor endpoint lookup

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>
Link: https://patch.msgid.link/20260407151111.3187826-3-johan@kernel.org
Signed-off-by: Johannes Berg <johannes.berg@intel.com>

authored by

Johan Hovold and committed by
Johannes Berg
c885e392 607363a1

+19 -20
+19 -20
drivers/net/wireless/marvell/libertas/if_usb.c
··· 193 193 static int if_usb_probe(struct usb_interface *intf, 194 194 const struct usb_device_id *id) 195 195 { 196 + struct usb_endpoint_descriptor *ep_in, *ep_out; 196 197 struct usb_device *udev; 197 198 struct usb_host_interface *iface_desc; 198 - struct usb_endpoint_descriptor *endpoint; 199 199 struct lbs_private *priv; 200 200 struct if_usb_card *cardp; 201 201 int r = -ENOMEM; 202 - int i; 203 202 204 203 udev = interface_to_usbdev(intf); 205 204 ··· 223 224 init_usb_anchor(&cardp->rx_submitted); 224 225 init_usb_anchor(&cardp->tx_submitted); 225 226 226 - for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) { 227 - endpoint = &iface_desc->endpoint[i].desc; 228 - if (usb_endpoint_is_bulk_in(endpoint)) { 229 - cardp->ep_in_size = le16_to_cpu(endpoint->wMaxPacketSize); 230 - cardp->ep_in = usb_endpoint_num(endpoint); 231 - 232 - lbs_deb_usbd(&udev->dev, "in_endpoint = %d\n", cardp->ep_in); 233 - lbs_deb_usbd(&udev->dev, "Bulk in size is %d\n", cardp->ep_in_size); 234 - 235 - } else if (usb_endpoint_is_bulk_out(endpoint)) { 236 - cardp->ep_out_size = le16_to_cpu(endpoint->wMaxPacketSize); 237 - cardp->ep_out = usb_endpoint_num(endpoint); 238 - 239 - lbs_deb_usbd(&udev->dev, "out_endpoint = %d\n", cardp->ep_out); 240 - lbs_deb_usbd(&udev->dev, "Bulk out size is %d\n", cardp->ep_out_size); 241 - } 242 - } 243 - if (!cardp->ep_out_size || !cardp->ep_in_size) { 227 + if (usb_find_common_endpoints_reverse(iface_desc, &ep_in, &ep_out, NULL, NULL)) { 244 228 lbs_deb_usbd(&udev->dev, "Endpoints not found\n"); 229 + goto dealloc; 230 + } 231 + 232 + cardp->ep_in_size = usb_endpoint_maxp(ep_in); 233 + cardp->ep_in = usb_endpoint_num(ep_in); 234 + 235 + lbs_deb_usbd(&udev->dev, "in_endpoint = %d\n", cardp->ep_in); 236 + lbs_deb_usbd(&udev->dev, "Bulk in size is %d\n", cardp->ep_in_size); 237 + 238 + cardp->ep_out_size = usb_endpoint_maxp(ep_out); 239 + cardp->ep_out = usb_endpoint_num(ep_out); 240 + 241 + lbs_deb_usbd(&udev->dev, "out_endpoint = %d\n", cardp->ep_out); 242 + lbs_deb_usbd(&udev->dev, "Bulk out size is %d\n", cardp->ep_out_size); 243 + 244 + if (!cardp->ep_out_size || !cardp->ep_in_size) { 245 + lbs_deb_usbd(&udev->dev, "Endpoints not valid\n"); 245 246 goto dealloc; 246 247 } 247 248 if (!(cardp->rx_urb = usb_alloc_urb(0, GFP_KERNEL))) {