can: kvaser_usb: leaf: refactor endpoint lookup

Use the common USB helper for looking up bulk and interrupt endpoints
instead of open coding.

Signed-off-by: Johan Hovold <johan@kernel.org>
Link: https://patch.msgid.link/20260330101817.1664787-2-johan@kernel.org
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
This commit is contained in:
Johan Hovold
2026-03-30 12:18:16 +02:00
committed by Marc Kleine-Budde
parent 572a36d279
commit 495fac90b8

View File

@@ -1957,27 +1957,18 @@ static int kvaser_usb_leaf_get_berr_counter(const struct net_device *netdev,
static int kvaser_usb_leaf_setup_endpoints(struct kvaser_usb *dev)
{
const struct usb_host_interface *iface_desc;
struct usb_endpoint_descriptor *endpoint;
int i;
struct usb_host_interface *iface_desc;
int ret;
iface_desc = dev->intf->cur_altsetting;
for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) {
endpoint = &iface_desc->endpoint[i].desc;
/* use first bulk endpoint for in and out */
ret = usb_find_common_endpoints(iface_desc, &dev->bulk_in, &dev->bulk_out,
NULL, NULL);
if (ret)
return -ENODEV;
if (!dev->bulk_in && usb_endpoint_is_bulk_in(endpoint))
dev->bulk_in = endpoint;
if (!dev->bulk_out && usb_endpoint_is_bulk_out(endpoint))
dev->bulk_out = endpoint;
/* use first bulk endpoint for in and out */
if (dev->bulk_in && dev->bulk_out)
return 0;
}
return -ENODEV;
return 0;
}
const struct kvaser_usb_dev_ops kvaser_usb_leaf_dev_ops = {