diff options
author | Hauke Mehrtens <hauke@hauke-m.de> | 2010-11-27 11:46:00 -0500 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2010-12-16 13:10:59 -0500 |
commit | 59833fcf48ee7b7c8a01e590aa7b7212305c3077 (patch) | |
tree | 47e21a465253b2c65073ff5136454e76a883ff2b /arch | |
parent | 2aa088d6fd8a6c6e6020ea46b70141f0b7ccf5d2 (diff) |
MIPS: BCM47xx: Use sscanf for parsing mac address
Instead of writing own function for parsing the mac address we now
use sscanf.
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
To: linux-mips@linux-mips.org
Cc: Hauke Mehrtens <hauke@hauke-m.de>
Patchwork: https://patchwork.linux-mips.org/patch/1847/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/mips/bcm47xx/setup.c | 23 | ||||
-rw-r--r-- | arch/mips/include/asm/mach-bcm47xx/nvram.h | 7 |
2 files changed, 10 insertions, 20 deletions
diff --git a/arch/mips/bcm47xx/setup.c b/arch/mips/bcm47xx/setup.c index 1f61dfd71ac7..87a305536604 100644 --- a/arch/mips/bcm47xx/setup.c +++ b/arch/mips/bcm47xx/setup.c | |||
@@ -56,23 +56,6 @@ static void bcm47xx_machine_halt(void) | |||
56 | cpu_relax(); | 56 | cpu_relax(); |
57 | } | 57 | } |
58 | 58 | ||
59 | static void str2eaddr(char *str, char *dest) | ||
60 | { | ||
61 | int i = 0; | ||
62 | |||
63 | if (str == NULL) { | ||
64 | memset(dest, 0, 6); | ||
65 | return; | ||
66 | } | ||
67 | |||
68 | for (;;) { | ||
69 | dest[i++] = (char) simple_strtoul(str, NULL, 16); | ||
70 | str += 2; | ||
71 | if (!*str++ || i == 6) | ||
72 | break; | ||
73 | } | ||
74 | } | ||
75 | |||
76 | #define READ_FROM_NVRAM(_outvar, name, buf) \ | 59 | #define READ_FROM_NVRAM(_outvar, name, buf) \ |
77 | if (nvram_getenv(name, buf, sizeof(buf)) >= 0)\ | 60 | if (nvram_getenv(name, buf, sizeof(buf)) >= 0)\ |
78 | sprom->_outvar = simple_strtoul(buf, NULL, 0); | 61 | sprom->_outvar = simple_strtoul(buf, NULL, 0); |
@@ -87,11 +70,11 @@ static void bcm47xx_fill_sprom(struct ssb_sprom *sprom) | |||
87 | sprom->revision = 1; /* Fallback: Old hardware does not define this. */ | 70 | sprom->revision = 1; /* Fallback: Old hardware does not define this. */ |
88 | READ_FROM_NVRAM(revision, "sromrev", buf); | 71 | READ_FROM_NVRAM(revision, "sromrev", buf); |
89 | if (nvram_getenv("il0macaddr", buf, sizeof(buf)) >= 0) | 72 | if (nvram_getenv("il0macaddr", buf, sizeof(buf)) >= 0) |
90 | str2eaddr(buf, sprom->il0mac); | 73 | nvram_parse_macaddr(buf, sprom->il0mac); |
91 | if (nvram_getenv("et0macaddr", buf, sizeof(buf)) >= 0) | 74 | if (nvram_getenv("et0macaddr", buf, sizeof(buf)) >= 0) |
92 | str2eaddr(buf, sprom->et0mac); | 75 | nvram_parse_macaddr(buf, sprom->et0mac); |
93 | if (nvram_getenv("et1macaddr", buf, sizeof(buf)) >= 0) | 76 | if (nvram_getenv("et1macaddr", buf, sizeof(buf)) >= 0) |
94 | str2eaddr(buf, sprom->et1mac); | 77 | nvram_parse_macaddr(buf, sprom->et1mac); |
95 | READ_FROM_NVRAM(et0phyaddr, "et0phyaddr", buf); | 78 | READ_FROM_NVRAM(et0phyaddr, "et0phyaddr", buf); |
96 | READ_FROM_NVRAM(et1phyaddr, "et1phyaddr", buf); | 79 | READ_FROM_NVRAM(et1phyaddr, "et1phyaddr", buf); |
97 | READ_FROM_NVRAM(et0mdcport, "et0mdcport", buf); | 80 | READ_FROM_NVRAM(et0mdcport, "et0mdcport", buf); |
diff --git a/arch/mips/include/asm/mach-bcm47xx/nvram.h b/arch/mips/include/asm/mach-bcm47xx/nvram.h index c58ebd8bc155..9759588ba3cf 100644 --- a/arch/mips/include/asm/mach-bcm47xx/nvram.h +++ b/arch/mips/include/asm/mach-bcm47xx/nvram.h | |||
@@ -12,6 +12,7 @@ | |||
12 | #define __NVRAM_H | 12 | #define __NVRAM_H |
13 | 13 | ||
14 | #include <linux/types.h> | 14 | #include <linux/types.h> |
15 | #include <linux/kernel.h> | ||
15 | 16 | ||
16 | struct nvram_header { | 17 | struct nvram_header { |
17 | u32 magic; | 18 | u32 magic; |
@@ -36,4 +37,10 @@ struct nvram_header { | |||
36 | 37 | ||
37 | extern int nvram_getenv(char *name, char *val, size_t val_len); | 38 | extern int nvram_getenv(char *name, char *val, size_t val_len); |
38 | 39 | ||
40 | static inline void nvram_parse_macaddr(char *buf, u8 *macaddr) | ||
41 | { | ||
42 | sscanf(buf, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", &macaddr[0], &macaddr[1], | ||
43 | &macaddr[2], &macaddr[3], &macaddr[4], &macaddr[5]); | ||
44 | } | ||
45 | |||
39 | #endif | 46 | #endif |