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>
This commit is contained in:
parent
41790fd51f
commit
9cbda726bb
1 changed files with 10 additions and 2 deletions
|
@ -39,8 +39,16 @@ extern int nvram_getenv(char *name, char *val, size_t val_len);
|
|||
|
||||
static inline void nvram_parse_macaddr(char *buf, u8 *macaddr)
|
||||
{
|
||||
sscanf(buf, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", &macaddr[0], &macaddr[1],
|
||||
&macaddr[2], &macaddr[3], &macaddr[4], &macaddr[5]);
|
||||
if (strchr(buf, ':'))
|
||||
sscanf(buf, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", &macaddr[0],
|
||||
&macaddr[1], &macaddr[2], &macaddr[3], &macaddr[4],
|
||||
&macaddr[5]);
|
||||
else if (strchr(buf, '-'))
|
||||
sscanf(buf, "%hhx-%hhx-%hhx-%hhx-%hhx-%hhx", &macaddr[0],
|
||||
&macaddr[1], &macaddr[2], &macaddr[3], &macaddr[4],
|
||||
&macaddr[5]);
|
||||
else
|
||||
printk(KERN_WARNING "Can not parse mac address: %s\n", buf);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue