ar71xx: rename ath79_parse_mac_addr to ath79_parse_ascii_mac
[openwrt/svn-archive/archive.git] / target / linux / ar71xx / files / arch / mips / ath79 / dev-eth.c
index 249323246c4e4d9e10c881d8578c9c77b47d48a0..4a2b1db7fb13ba2145eaf1bad8b9771466f3e7da 100644 (file)
@@ -439,8 +439,8 @@ static struct resource ath79_eth0_resources[] = {
        }, {
                .name   = "mac_irq",
                .flags  = IORESOURCE_IRQ,
-               .start  = ATH79_CPU_IRQ_GE0,
-               .end    = ATH79_CPU_IRQ_GE0,
+               .start  = ATH79_CPU_IRQ(4),
+               .end    = ATH79_CPU_IRQ(4),
        },
 };
 
@@ -467,8 +467,8 @@ static struct resource ath79_eth1_resources[] = {
        }, {
                .name   = "mac_irq",
                .flags  = IORESOURCE_IRQ,
-               .start  = ATH79_CPU_IRQ_GE1,
-               .end    = ATH79_CPU_IRQ_GE1,
+               .start  = ATH79_CPU_IRQ(5),
+               .end    = ATH79_CPU_IRQ(5),
        },
 };
 
@@ -1056,35 +1056,42 @@ void __init ath79_set_mac_base(unsigned char *mac)
        memcpy(ath79_mac_base, mac, ETH_ALEN);
 }
 
-void __init ath79_parse_mac_addr(char *mac_str)
+void __init ath79_parse_ascii_mac(char *mac_str, u8 *mac)
 {
-       u8 tmp[ETH_ALEN];
        int t;
 
        t = sscanf(mac_str, "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx",
-                       &tmp[0], &tmp[1], &tmp[2], &tmp[3], &tmp[4], &tmp[5]);
+                  &mac[0], &mac[1], &mac[2], &mac[3], &mac[4], &mac[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]);
+                       &mac[0], &mac[1], &mac[2], &mac[3], &mac[4], &mac[5]);
 
-       if (t == ETH_ALEN)
-               ath79_set_mac_base(tmp);
-       else
-               printk(KERN_DEBUG "ar71xx: failed to parse mac address "
-                               "\"%s\"\n", mac_str);
+       if (t != ETH_ALEN || !is_valid_ether_addr(mac)) {
+               memset(mac, 0, ETH_ALEN);
+               printk(KERN_DEBUG "ar71xx: invalid mac address \"%s\"\n",
+                      mac_str);
+       }
+}
+
+static void __init ath79_set_mac_base_ascii(char *str)
+{
+       u8 mac[ETH_ALEN];
+
+       ath79_parse_ascii_mac(str, mac);
+       ath79_set_mac_base(mac);
 }
 
 static int __init ath79_ethaddr_setup(char *str)
 {
-       ath79_parse_mac_addr(str);
+       ath79_set_mac_base_ascii(str);
        return 1;
 }
 __setup("ethaddr=", ath79_ethaddr_setup);
 
 static int __init ath79_kmac_setup(char *str)
 {
-       ath79_parse_mac_addr(str);
+       ath79_set_mac_base_ascii(str);
        return 1;
 }
 __setup("kmac=", ath79_kmac_setup);