diff options
author | Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> | 2012-11-22 01:35:17 +0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-11-23 23:29:51 +0400 |
commit | 452b5ecda0f99a15d6900dd9f845b8a0c09b5aca (patch) | |
tree | 4a43025c9b4b87892f6268a982ae53d899f49aca /drivers/net/usb/asix_devices.c | |
parent | 93272e07d8539cddce9a2a17b7b0de1326957599 (diff) | |
download | linux-452b5ecda0f99a15d6900dd9f845b8a0c09b5aca.tar.xz |
asix: use ramdom hw addr if the one read is not valid
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Cc: linux-usb@vger.kernel.org
Cc: netdev@vger.kernel.org
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/usb/asix_devices.c')
-rw-r--r-- | drivers/net/usb/asix_devices.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/drivers/net/usb/asix_devices.c b/drivers/net/usb/asix_devices.c index 33ab824773c5..7a6e758f48e7 100644 --- a/drivers/net/usb/asix_devices.c +++ b/drivers/net/usb/asix_devices.c @@ -64,6 +64,16 @@ static void asix_status(struct usbnet *dev, struct urb *urb) } } +static void asix_set_netdev_dev_addr(struct usbnet *dev, u8 *addr) +{ + if (is_valid_ether_addr(addr)) { + memcpy(dev->net->dev_addr, addr, ETH_ALEN); + } else { + netdev_info(dev->net, "invalid hw address, using random\n"); + eth_hw_addr_random(dev->net); + } +} + /* Get the PHY Identifier from the PHYSID1 & PHYSID2 MII registers */ static u32 asix_get_phyid(struct usbnet *dev) { @@ -225,7 +235,8 @@ static int ax88172_bind(struct usbnet *dev, struct usb_interface *intf) ret); goto out; } - memcpy(dev->net->dev_addr, buf, ETH_ALEN); + + asix_set_netdev_dev_addr(dev, buf); /* Initialize MII structure */ dev->mii.dev = dev->net; @@ -423,7 +434,8 @@ static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf) netdev_dbg(dev->net, "Failed to read MAC address: %d\n", ret); return ret; } - memcpy(dev->net->dev_addr, buf, ETH_ALEN); + + asix_set_netdev_dev_addr(dev, buf); /* Initialize MII structure */ dev->mii.dev = dev->net; @@ -777,7 +789,8 @@ static int ax88178_bind(struct usbnet *dev, struct usb_interface *intf) netdev_dbg(dev->net, "Failed to read MAC address: %d\n", ret); return ret; } - memcpy(dev->net->dev_addr, buf, ETH_ALEN); + + asix_set_netdev_dev_addr(dev, buf); /* Initialize MII structure */ dev->mii.dev = dev->net; |