Commit 20f10aa0 authored by Wu Fengguang's avatar Wu Fengguang Committed by David S. Miller

dm9601: handle corrupt mac address

Some cheap devices ship with dangling EEPROM pins!
They always return invalid address ff:ff:ff:ff:ff:ff.

Inherit the auto-generated address in this case,
so that these products can work with zero configuration.
Signed-off-by: default avatarWu Fengguang <fengguang.wu@intel.com>
Signed-off-by: default avatarPeter Korsgaard <jacmet@sunsite.dk>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent e1c096e2
...@@ -414,6 +414,7 @@ static int dm9601_set_mac_address(struct net_device *net, void *p) ...@@ -414,6 +414,7 @@ static int dm9601_set_mac_address(struct net_device *net, void *p)
static int dm9601_bind(struct usbnet *dev, struct usb_interface *intf) static int dm9601_bind(struct usbnet *dev, struct usb_interface *intf)
{ {
int ret; int ret;
u8 mac[ETH_ALEN];
ret = usbnet_get_endpoints(dev, intf); ret = usbnet_get_endpoints(dev, intf);
if (ret) if (ret)
...@@ -438,12 +439,18 @@ static int dm9601_bind(struct usbnet *dev, struct usb_interface *intf) ...@@ -438,12 +439,18 @@ static int dm9601_bind(struct usbnet *dev, struct usb_interface *intf)
udelay(20); udelay(20);
/* read MAC */ /* read MAC */
if (dm_read(dev, DM_PHY_ADDR, ETH_ALEN, dev->net->dev_addr) < 0) { if (dm_read(dev, DM_PHY_ADDR, ETH_ALEN, mac) < 0) {
printk(KERN_ERR "Error reading MAC address\n"); printk(KERN_ERR "Error reading MAC address\n");
ret = -ENODEV; ret = -ENODEV;
goto out; goto out;
} }
/*
* Overwrite the auto-generated address only with good ones.
*/
if (is_valid_ether_addr(mac))
memcpy(dev->net->dev_addr, mac, ETH_ALEN);
/* power up phy */ /* power up phy */
dm_write_reg(dev, DM_GPR_CTRL, 1); dm_write_reg(dev, DM_GPR_CTRL, 1);
dm_write_reg(dev, DM_GPR_DATA, 0); dm_write_reg(dev, DM_GPR_DATA, 0);
......
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