Skip to content

Commit

Permalink
MIPS: BCM47xx: Fix MAC address parsing.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Hauke Mehrtens authored and Ralf Baechle committed May 19, 2011
1 parent 41790fd commit 9cbda72
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions arch/mips/include/asm/mach-bcm47xx/nvram.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 9cbda72

Please sign in to comment.