Commit 7c478014 authored by Jimmy Assarsson's avatar Jimmy Assarsson Committed by Marc Kleine-Budde

can: kvaser_usb: Refactor kvaser_usb_init_one()

Replace first parameter in kvaser_usb_init_one() with a pointer to
struct kvaser_usb.
Signed-off-by: default avatarJimmy Assarsson <extja@kvaser.com>
Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
parent 99ce1bc1
...@@ -1848,10 +1848,9 @@ static void kvaser_usb_remove_interfaces(struct kvaser_usb *dev) ...@@ -1848,10 +1848,9 @@ static void kvaser_usb_remove_interfaces(struct kvaser_usb *dev)
} }
} }
static int kvaser_usb_init_one(struct usb_interface *intf, static int kvaser_usb_init_one(struct kvaser_usb *dev,
const struct usb_device_id *id, int channel) const struct usb_device_id *id, int channel)
{ {
struct kvaser_usb *dev = usb_get_intfdata(intf);
struct net_device *netdev; struct net_device *netdev;
struct kvaser_usb_net_priv *priv; struct kvaser_usb_net_priv *priv;
int err; int err;
...@@ -1864,7 +1863,7 @@ static int kvaser_usb_init_one(struct usb_interface *intf, ...@@ -1864,7 +1863,7 @@ static int kvaser_usb_init_one(struct usb_interface *intf,
dev->max_tx_urbs * sizeof(*priv->tx_contexts), dev->max_tx_urbs * sizeof(*priv->tx_contexts),
dev->max_tx_urbs); dev->max_tx_urbs);
if (!netdev) { if (!netdev) {
dev_err(&intf->dev, "Cannot alloc candev\n"); dev_err(&dev->intf->dev, "Cannot alloc candev\n");
return -ENOMEM; return -ENOMEM;
} }
...@@ -1896,14 +1895,14 @@ static int kvaser_usb_init_one(struct usb_interface *intf, ...@@ -1896,14 +1895,14 @@ static int kvaser_usb_init_one(struct usb_interface *intf,
netdev->netdev_ops = &kvaser_usb_netdev_ops; netdev->netdev_ops = &kvaser_usb_netdev_ops;
SET_NETDEV_DEV(netdev, &intf->dev); SET_NETDEV_DEV(netdev, &dev->intf->dev);
netdev->dev_id = channel; netdev->dev_id = channel;
dev->nets[channel] = priv; dev->nets[channel] = priv;
err = register_candev(netdev); err = register_candev(netdev);
if (err) { if (err) {
dev_err(&intf->dev, "Failed to register can device\n"); dev_err(&dev->intf->dev, "Failed to register can device\n");
free_candev(netdev); free_candev(netdev);
dev->nets[channel] = NULL; dev->nets[channel] = NULL;
return err; return err;
...@@ -2005,7 +2004,7 @@ static int kvaser_usb_probe(struct usb_interface *intf, ...@@ -2005,7 +2004,7 @@ static int kvaser_usb_probe(struct usb_interface *intf,
} }
for (i = 0; i < dev->nchannels; i++) { for (i = 0; i < dev->nchannels; i++) {
err = kvaser_usb_init_one(intf, id, i); err = kvaser_usb_init_one(dev, id, i);
if (err) { if (err) {
kvaser_usb_remove_interfaces(dev); kvaser_usb_remove_interfaces(dev);
return err; return err;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment