Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9cbda726 authored by Hauke Mehrtens's avatar Hauke Mehrtens Committed by Ralf Baechle
Browse files

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: default avatarHauke Mehrtens <hauke@hauke-m.de>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/2366/


Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
parent 41790fd5
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -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