diff options
author | juhosg <juhosg@3c298f89-4303-0410-b956-a3cf2f4a3e73> | 2013-09-20 16:41:30 +0000 |
---|---|---|
committer | juhosg <juhosg@3c298f89-4303-0410-b956-a3cf2f4a3e73> | 2013-09-20 16:41:30 +0000 |
commit | 580941e14ab2fa137f0987a3aefd3bf719c42b3b (patch) | |
tree | 4d8ac69e17f49e6b7b0953d896d35b03cbabf384 | |
parent | e276236cb68c279e1a0a2a1834780dc7ce6dea1e (diff) |
ar71xx: rename ath79_parse_mac_addr to ath79_parse_ascii_mac
Rename the function and extend it in order to make it
usable from board setup code.
Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@38085 3c298f89-4303-0410-b956-a3cf2f4a3e73
-rw-r--r-- | target/linux/ar71xx/files/arch/mips/ath79/dev-eth.c | 29 | ||||
-rw-r--r-- | target/linux/ar71xx/files/arch/mips/ath79/dev-eth.h | 2 |
2 files changed, 19 insertions, 12 deletions
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/dev-eth.c b/target/linux/ar71xx/files/arch/mips/ath79/dev-eth.c index d7f3595b88..4a2b1db7fb 100644 --- a/target/linux/ar71xx/files/arch/mips/ath79/dev-eth.c +++ b/target/linux/ar71xx/files/arch/mips/ath79/dev-eth.c @@ -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); diff --git a/target/linux/ar71xx/files/arch/mips/ath79/dev-eth.h b/target/linux/ar71xx/files/arch/mips/ath79/dev-eth.h index 561bf3ff86..bc608dac07 100644 --- a/target/linux/ar71xx/files/arch/mips/ath79/dev-eth.h +++ b/target/linux/ar71xx/files/arch/mips/ath79/dev-eth.h @@ -17,7 +17,7 @@ struct platform_device; extern unsigned char ath79_mac_base[] __initdata; -void ath79_parse_mac_addr(char *mac_str); +void ath79_parse_ascii_mac(char *mac_str, u8 *mac); void ath79_init_mac(unsigned char *dst, const unsigned char *src, int offset); void ath79_init_local_mac(unsigned char *dst, const unsigned char *src); |