]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
dm9601: handle corrupt mac address
authorWu Fengguang <fengguang.wu@intel.com>
Tue, 6 Jan 2009 18:55:10 +0000 (10:55 -0800)
committerDavid S. Miller <davem@davemloft.net>
Tue, 6 Jan 2009 18:55:32 +0000 (10:55 -0800)
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>
drivers/net/usb/dm9601.c

index edd244f3acb50488c031863997101ff41469c797..69a0436d39403974b30f13f7c50965a35382a614 100644 (file)
@@ -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)
 {
        int ret;
+       u8 mac[ETH_ALEN];
 
        ret = usbnet_get_endpoints(dev, intf);
        if (ret)
@@ -438,12 +439,18 @@ static int dm9601_bind(struct usbnet *dev, struct usb_interface *intf)
        udelay(20);
 
        /* 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");
                ret = -ENODEV;
                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 */
        dm_write_reg(dev, DM_GPR_CTRL, 1);
        dm_write_reg(dev, DM_GPR_DATA, 0);