[ar71xx] parse dot-separated MAC address (patch by Jonas <jmajau@ubnt.com>)
[openwrt/svn-archive/archive.git] / target / linux / ar71xx / files / arch / mips / ar71xx / platform.c
index ef70867a2b7cdbb8ca4e1acc045235051036466e..6a29fc46a00429ed776b5e90bc17ba01ac8d0122 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/init.h>
 #include <linux/delay.h>
 #include <linux/dma-mapping.h>
+#include <linux/etherdevice.h>
 #include <linux/platform_device.h>
 #include <linux/serial_8250.h>
 #include <linux/ath9k_platform.h>
@@ -456,8 +457,15 @@ void __init ar71xx_add_device_eth(unsigned int id)
                break;
        }
 
-       memcpy(pdata->mac_addr, ar71xx_mac_base, ETH_ALEN);
-       pdata->mac_addr[5] += ar71xx_eth_instance;
+       if (is_valid_ether_addr(ar71xx_mac_base)) {
+               memcpy(pdata->mac_addr, ar71xx_mac_base, ETH_ALEN);
+               pdata->mac_addr[5] += ar71xx_eth_instance;
+       } else {
+               random_ether_addr(pdata->mac_addr);
+               printk(KERN_DEBUG
+                       "ar71xx: using random MAC address for eth%d\n",
+                       ar71xx_eth_instance);
+       }
 
        platform_device_register(pdev);
        ar71xx_eth_instance++;
@@ -507,7 +515,7 @@ void __init ar71xx_add_device_leds_gpio(int id, unsigned num_leds,
 
        memset(&pdata, 0, sizeof(pdata));
        pdata.num_leds = num_leds;
-       pdata.leds = leds;
+       pdata.leds = p;
 
        err = platform_device_add_data(pdev, &pdata, sizeof(pdata));
        if (err)
@@ -587,6 +595,10 @@ void __init ar71xx_parse_mac_addr(char *mac_str)
        t = sscanf(mac_str, "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx",
                        &tmp[0], &tmp[1], &tmp[2], &tmp[3], &tmp[4], &tmp[5]);
 
+       if (t != ETH_ALEN)
+               t = sscanf(mac_str, "%02hhx.%02hhx.%02hhx.%02hhx.%02hhx.%02hhx",
+                       &tmp[0], &tmp[1], &tmp[2], &tmp[3], &tmp[4], &tmp[5]);
+
        if (t == ETH_ALEN)
                ar71xx_set_mac_base(tmp);
        else