1 From f52926174040418e26112cd0ba36afd8bb066928 Mon Sep 17 00:00:00 2001
2 From: Hauke Mehrtens <hauke@hauke-m.de>
3 Date: Sat, 27 Nov 2010 14:02:49 +0100
4 Subject: [PATCH 3/6] MIPS: BCM47xx: Use sscanf for parsing mac address
6 Instead of writing out own function for parsing the mac address we now
9 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
11 arch/mips/bcm47xx/setup.c | 23 +++--------------------
12 arch/mips/include/asm/mach-bcm47xx/nvram.h | 7 +++++++
13 2 files changed, 10 insertions(+), 20 deletions(-)
15 --- a/arch/mips/bcm47xx/setup.c
16 +++ b/arch/mips/bcm47xx/setup.c
17 @@ -56,23 +56,6 @@ static void bcm47xx_machine_halt(void)
21 -static void str2eaddr(char *str, char *dest)
31 - dest[i++] = (char) simple_strtoul(str, NULL, 16);
33 - if (!*str++ || i == 6)
38 #define READ_FROM_NVRAM(_outvar, name, buf) \
39 if (nvram_getenv(name, buf, sizeof(buf)) >= 0)\
40 sprom->_outvar = simple_strtoul(buf, NULL, 0);
41 @@ -87,11 +70,11 @@ static void bcm47xx_fill_sprom(struct ss
42 sprom->revision = 1; /* Fallback: Old hardware does not define this. */
43 READ_FROM_NVRAM(revision, "sromrev", buf);
44 if (nvram_getenv("il0macaddr", buf, sizeof(buf)) >= 0)
45 - str2eaddr(buf, sprom->il0mac);
46 + nvram_parse_macaddr(buf, sprom->il0mac);
47 if (nvram_getenv("et0macaddr", buf, sizeof(buf)) >= 0)
48 - str2eaddr(buf, sprom->et0mac);
49 + nvram_parse_macaddr(buf, sprom->et0mac);
50 if (nvram_getenv("et1macaddr", buf, sizeof(buf)) >= 0)
51 - str2eaddr(buf, sprom->et1mac);
52 + nvram_parse_macaddr(buf, sprom->et1mac);
53 READ_FROM_NVRAM(et0phyaddr, "et0phyaddr", buf);
54 READ_FROM_NVRAM(et1phyaddr, "et1phyaddr", buf);
55 READ_FROM_NVRAM(et0mdcport, "et0mdcport", buf);
56 --- a/arch/mips/include/asm/mach-bcm47xx/nvram.h
57 +++ b/arch/mips/include/asm/mach-bcm47xx/nvram.h
61 #include <linux/types.h>
62 +#include <linux/kernel.h>
66 @@ -36,4 +37,10 @@ struct nvram_header {
68 extern int nvram_getenv(char *name, char *val, size_t val_len);
70 +static inline void nvram_parse_macaddr(char *buf, u8 *macaddr)
72 + sscanf(buf, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", &macaddr[0], &macaddr[1],
73 + &macaddr[2], &macaddr[3], &macaddr[4], &macaddr[5]);