ar71xx: mach-rbspi: simplify reset button registration
[oweals/openwrt.git] / target / linux / ar71xx / files / arch / mips / ath79 / nvram.c
index 43911b8ac1e3610c3a89382acc9155dd947c4985..a1de55fb19937c9cb67c40731e456b88d9f18337 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/errno.h>
 #include <linux/init.h>
 #include <linux/string.h>
+#include <linux/etherdevice.h>
 
 #include "nvram.h"
 
@@ -59,10 +60,19 @@ int ath79_nvram_parse_mac_addr(const char *nvram, unsigned nvram_len,
                goto free;
        }
 
+       if (strlen(mac_str) == 19 && mac_str[0] == '"' && mac_str[18] == '"') {
+               mac_str[18] = 0;
+               mac_str++;
+       }
+
        t = sscanf(mac_str, "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx",
                   &mac[0], &mac[1], &mac[2], &mac[3], &mac[4], &mac[5]);
 
-       if (t != 6) {
+       if (t != ETH_ALEN)
+               t = sscanf(mac_str, "%02hhx-%02hhx-%02hhx-%02hhx-%02hhx-%02hhx",
+                       &mac[0], &mac[1], &mac[2], &mac[3], &mac[4], &mac[5]);
+
+       if (t != ETH_ALEN) {
                ret = -EINVAL;
                goto free;
        }