Commit 7ce9a701 authored by Oliver Neukum's avatar Oliver Neukum Committed by David S. Miller

usbb: catc: use correct API for MAC addresses

Commit 406f42fa ("net-next: When a bond have a massive amount
of VLANs...") introduced a rbtree for faster Ethernet address look
up. To maintain netdev->dev_addr in this tree we need to make all
the writes to it got through appropriate helpers.

In the case of catc we need a new temporary buffer to conform
to the rules for DMA coherency. That in turn necessitates
a reworking of error handling in probe().
Signed-off-by: default avatarOliver Neukum <oneukum@suse.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 2b30da45
...@@ -770,17 +770,23 @@ static int catc_probe(struct usb_interface *intf, const struct usb_device_id *id ...@@ -770,17 +770,23 @@ static int catc_probe(struct usb_interface *intf, const struct usb_device_id *id
struct net_device *netdev; struct net_device *netdev;
struct catc *catc; struct catc *catc;
u8 broadcast[ETH_ALEN]; u8 broadcast[ETH_ALEN];
int pktsz, ret; u8 *macbuf;
int pktsz, ret = -ENOMEM;
macbuf = kmalloc(ETH_ALEN, GFP_KERNEL);
if (!macbuf)
goto error;
if (usb_set_interface(usbdev, if (usb_set_interface(usbdev,
intf->altsetting->desc.bInterfaceNumber, 1)) { intf->altsetting->desc.bInterfaceNumber, 1)) {
dev_err(dev, "Can't set altsetting 1.\n"); dev_err(dev, "Can't set altsetting 1.\n");
return -EIO; ret = -EIO;
goto fail_mem;;
} }
netdev = alloc_etherdev(sizeof(struct catc)); netdev = alloc_etherdev(sizeof(struct catc));
if (!netdev) if (!netdev)
return -ENOMEM; goto fail_mem;
catc = netdev_priv(netdev); catc = netdev_priv(netdev);
...@@ -870,7 +876,8 @@ static int catc_probe(struct usb_interface *intf, const struct usb_device_id *id ...@@ -870,7 +876,8 @@ static int catc_probe(struct usb_interface *intf, const struct usb_device_id *id
dev_dbg(dev, "Getting MAC from SEEROM.\n"); dev_dbg(dev, "Getting MAC from SEEROM.\n");
catc_get_mac(catc, netdev->dev_addr); catc_get_mac(catc, macbuf);
eth_hw_addr_set(netdev, macbuf);
dev_dbg(dev, "Setting MAC into registers.\n"); dev_dbg(dev, "Setting MAC into registers.\n");
...@@ -899,7 +906,8 @@ static int catc_probe(struct usb_interface *intf, const struct usb_device_id *id ...@@ -899,7 +906,8 @@ static int catc_probe(struct usb_interface *intf, const struct usb_device_id *id
} else { } else {
dev_dbg(dev, "Performing reset\n"); dev_dbg(dev, "Performing reset\n");
catc_reset(catc); catc_reset(catc);
catc_get_mac(catc, netdev->dev_addr); catc_get_mac(catc, macbuf);
eth_hw_addr_set(netdev, macbuf);
dev_dbg(dev, "Setting RX Mode\n"); dev_dbg(dev, "Setting RX Mode\n");
catc->rxmode[0] = RxEnable | RxPolarity | RxMultiCast; catc->rxmode[0] = RxEnable | RxPolarity | RxMultiCast;
...@@ -917,6 +925,7 @@ static int catc_probe(struct usb_interface *intf, const struct usb_device_id *id ...@@ -917,6 +925,7 @@ static int catc_probe(struct usb_interface *intf, const struct usb_device_id *id
if (ret) if (ret)
goto fail_clear_intfdata; goto fail_clear_intfdata;
kfree(macbuf);
return 0; return 0;
fail_clear_intfdata: fail_clear_intfdata:
...@@ -927,6 +936,9 @@ static int catc_probe(struct usb_interface *intf, const struct usb_device_id *id ...@@ -927,6 +936,9 @@ static int catc_probe(struct usb_interface *intf, const struct usb_device_id *id
usb_free_urb(catc->rx_urb); usb_free_urb(catc->rx_urb);
usb_free_urb(catc->irq_urb); usb_free_urb(catc->irq_urb);
free_netdev(netdev); free_netdev(netdev);
fail_mem:
kfree(macbuf);
error:
return ret; return ret;
} }
......
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