Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

MIPS: BCM47xx: Fix MAC address parsing.

Some devices like the Netgear WGT634u are using minuses between the blocks
of the MAC address and other devices are using colons to separate them.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/2366/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>

authored by

Hauke Mehrtens and committed by
Ralf Baechle
9cbda726 41790fd5

+10 -2
+10 -2
arch/mips/include/asm/mach-bcm47xx/nvram.h
··· 39 39 40 40 static inline void nvram_parse_macaddr(char *buf, u8 *macaddr) 41 41 { 42 - sscanf(buf, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", &macaddr[0], &macaddr[1], 43 - &macaddr[2], &macaddr[3], &macaddr[4], &macaddr[5]); 42 + if (strchr(buf, ':')) 43 + sscanf(buf, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", &macaddr[0], 44 + &macaddr[1], &macaddr[2], &macaddr[3], &macaddr[4], 45 + &macaddr[5]); 46 + else if (strchr(buf, '-')) 47 + sscanf(buf, "%hhx-%hhx-%hhx-%hhx-%hhx-%hhx", &macaddr[0], 48 + &macaddr[1], &macaddr[2], &macaddr[3], &macaddr[4], 49 + &macaddr[5]); 50 + else 51 + printk(KERN_WARNING "Can not parse mac address: %s\n", buf); 44 52 } 45 53 46 54 #endif