From 99ce1bc1746266a20e91417b600533e82d57734d Mon Sep 17 00:00:00 2001 From: Jimmy Assarsson Date: Wed, 18 Jul 2018 23:29:23 +0200 Subject: [PATCH] can: kvaser_usb: Refactor kvaser_usb_get_endpoints() 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 Signed-off-by: Marc Kleine-Budde --- drivers/net/can/usb/kvaser_usb.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/drivers/net/can/usb/kvaser_usb.c b/drivers/net/can/usb/kvaser_usb.c index 9e0e2c852943..cb3a2d6d3ba4 100644 --- a/drivers/net/can/usb/kvaser_usb.c +++ b/drivers/net/can/usb/kvaser_usb.c @@ -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; } @@ -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;