aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/usb
diff options
context:
space:
mode:
authorWu Fengguang <fengguang.wu@intel.com>2009-01-06 13:55:10 -0500
committerDavid S. Miller <davem@davemloft.net>2009-01-06 13:55:32 -0500
commit20f10aa07d8d4d43ae8e129c39a84e1670b0d5ab (patch)
treedb283b501631fbf6d21b402c580d7dc86809a4a4 /drivers/net/usb
parente1c096e251e52773afeffbbcb74d0a072be47ea3 (diff)
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: Wu Fengguang <fengguang.wu@intel.com> Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/usb')
-rw-r--r--drivers/net/usb/dm9601.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/drivers/net/usb/dm9601.c b/drivers/net/usb/dm9601.c
index edd244f3acb5..69a0436d3940 100644
--- a/drivers/net/usb/dm9601.c
+++ b/drivers/net/usb/dm9601.c
@@ -414,6 +414,7 @@ static int dm9601_set_mac_address(struct net_device *net, void *p)
414static int dm9601_bind(struct usbnet *dev, struct usb_interface *intf) 414static int dm9601_bind(struct usbnet *dev, struct usb_interface *intf)
415{ 415{
416 int ret; 416 int ret;
417 u8 mac[ETH_ALEN];
417 418
418 ret = usbnet_get_endpoints(dev, intf); 419 ret = usbnet_get_endpoints(dev, intf);
419 if (ret) 420 if (ret)
@@ -438,12 +439,18 @@ static int dm9601_bind(struct usbnet *dev, struct usb_interface *intf)
438 udelay(20); 439 udelay(20);
439 440
440 /* read MAC */ 441 /* read MAC */
441 if (dm_read(dev, DM_PHY_ADDR, ETH_ALEN, dev->net->dev_addr) < 0) { 442 if (dm_read(dev, DM_PHY_ADDR, ETH_ALEN, mac) < 0) {
442 printk(KERN_ERR "Error reading MAC address\n"); 443 printk(KERN_ERR "Error reading MAC address\n");
443 ret = -ENODEV; 444 ret = -ENODEV;
444 goto out; 445 goto out;
445 } 446 }
446 447
448 /*
449 * Overwrite the auto-generated address only with good ones.
450 */
451 if (is_valid_ether_addr(mac))
452 memcpy(dev->net->dev_addr, mac, ETH_ALEN);
453
447 /* power up phy */ 454 /* power up phy */
448 dm_write_reg(dev, DM_GPR_CTRL, 1); 455 dm_write_reg(dev, DM_GPR_CTRL, 1);
449 dm_write_reg(dev, DM_GPR_DATA, 0); 456 dm_write_reg(dev, DM_GPR_DATA, 0);