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_tf: 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-4-johan@kernel.org
Signed-off-by: Johannes Berg <johannes.berg@intel.com>

authored by

Johan Hovold and committed by
Johannes Berg
e801194b c885e392

+22 -26
+22 -26
drivers/net/wireless/marvell/libertas_tf/if_usb.c
··· 144 144 static int if_usb_probe(struct usb_interface *intf, 145 145 const struct usb_device_id *id) 146 146 { 147 + struct usb_endpoint_descriptor *ep_in, *ep_out; 147 148 struct usb_device *udev; 148 149 struct usb_host_interface *iface_desc; 149 - struct usb_endpoint_descriptor *endpoint; 150 150 struct lbtf_private *priv; 151 151 struct if_usb_card *cardp; 152 - int i; 152 + int ret; 153 153 154 154 lbtf_deb_enter(LBTF_DEB_USB); 155 155 udev = interface_to_usbdev(intf); ··· 171 171 udev->descriptor.bDeviceSubClass, 172 172 udev->descriptor.bDeviceProtocol); 173 173 174 - for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) { 175 - endpoint = &iface_desc->endpoint[i].desc; 176 - if (usb_endpoint_is_bulk_in(endpoint)) { 177 - cardp->ep_in_size = 178 - le16_to_cpu(endpoint->wMaxPacketSize); 179 - cardp->ep_in = usb_endpoint_num(endpoint); 180 - 181 - lbtf_deb_usbd(&udev->dev, "in_endpoint = %d\n", 182 - cardp->ep_in); 183 - lbtf_deb_usbd(&udev->dev, "Bulk in size is %d\n", 184 - cardp->ep_in_size); 185 - } else if (usb_endpoint_is_bulk_out(endpoint)) { 186 - cardp->ep_out_size = 187 - le16_to_cpu(endpoint->wMaxPacketSize); 188 - cardp->ep_out = usb_endpoint_num(endpoint); 189 - 190 - lbtf_deb_usbd(&udev->dev, "out_endpoint = %d\n", 191 - cardp->ep_out); 192 - lbtf_deb_usbd(&udev->dev, "Bulk out size is %d\n", 193 - cardp->ep_out_size); 194 - } 195 - } 196 - if (!cardp->ep_out_size || !cardp->ep_in_size) { 174 + ret = usb_find_common_endpoints_reverse(iface_desc, &ep_in, &ep_out, 175 + NULL, NULL); 176 + if (ret) { 197 177 lbtf_deb_usbd(&udev->dev, "Endpoints not found\n"); 198 - /* Endpoints not found */ 178 + goto dealloc; 179 + } 180 + 181 + cardp->ep_in_size = usb_endpoint_maxp(ep_in); 182 + cardp->ep_in = usb_endpoint_num(ep_in); 183 + 184 + lbtf_deb_usbd(&udev->dev, "in_endpoint = %d\n", cardp->ep_in); 185 + lbtf_deb_usbd(&udev->dev, "Bulk in size is %d\n", cardp->ep_in_size); 186 + 187 + cardp->ep_out_size = usb_endpoint_maxp(ep_out); 188 + cardp->ep_out = usb_endpoint_num(ep_out); 189 + 190 + lbtf_deb_usbd(&udev->dev, "out_endpoint = %d\n", cardp->ep_out); 191 + lbtf_deb_usbd(&udev->dev, "Bulk out size is %d\n", cardp->ep_out_size); 192 + 193 + if (!cardp->ep_out_size || !cardp->ep_in_size) { 194 + lbtf_deb_usbd(&udev->dev, "Endpoints not valid\n"); 199 195 goto dealloc; 200 196 } 201 197