Skip to content

Commit

Permalink
can: kvaser_usb: Refactor kvaser_usb_get_endpoints()
Browse files Browse the repository at this point in the history
Replace parameters with struct kvaser_usb pointer. Rename the function
from kvaser_usb_get_endpoints() to kvaser_usb_setup_endpoints().

Signed-off-by: Jimmy Assarsson <extja@kvaser.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
  • Loading branch information
Jimmy Assarsson authored and Marc Kleine-Budde committed Jul 27, 2018
1 parent 0e30619 commit 99ce1bc
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions drivers/net/can/usb/kvaser_usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1914,27 +1914,25 @@ static int kvaser_usb_init_one(struct usb_interface *intf,
return 0;
}

static int kvaser_usb_get_endpoints(const struct usb_interface *intf,
struct usb_endpoint_descriptor **in,
struct usb_endpoint_descriptor **out)
static int kvaser_usb_setup_endpoints(struct kvaser_usb *dev)
{
const struct usb_host_interface *iface_desc;
struct usb_endpoint_descriptor *endpoint;
int i;

iface_desc = &intf->altsetting[0];
iface_desc = &dev->intf->altsetting[0];

for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) {
endpoint = &iface_desc->endpoint[i].desc;

if (!*in && usb_endpoint_is_bulk_in(endpoint))
*in = endpoint;
if (!dev->bulk_in && usb_endpoint_is_bulk_in(endpoint))
dev->bulk_in = endpoint;

if (!*out && usb_endpoint_is_bulk_out(endpoint))
*out = endpoint;
if (!dev->bulk_out && usb_endpoint_is_bulk_out(endpoint))
dev->bulk_out = endpoint;

/* use first bulk endpoint for in and out */
if (*in && *out)
if (dev->bulk_in && dev->bulk_out)
return 0;
}

Expand Down Expand Up @@ -1965,7 +1963,7 @@ static int kvaser_usb_probe(struct usb_interface *intf,

dev->intf = intf;

err = kvaser_usb_get_endpoints(intf, &dev->bulk_in, &dev->bulk_out);
err = kvaser_usb_setup_endpoints(dev);
if (err) {
dev_err(&intf->dev, "Cannot get usb endpoint(s)");
return err;
Expand Down

0 comments on commit 99ce1bc

Please sign in to comment.