[package] busybox: implement ms static routes option in udhcpc (#6435)
[openwrt.git] / target / linux / brcm47xx / patches-2.6.37 / 012-MIPS-BCM47xx-Use-sscanf-for-parsing-mac-address.patch
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
5
6 Instead of writing out own function for parsing the mac address we now
7 use sscanf.
8
9 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
10 ---
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(-)
14
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)
18 cpu_relax();
19 }
20
21 -static void str2eaddr(char *str, char *dest)
22 -{
23 - int i = 0;
24 -
25 - if (str == NULL) {
26 - memset(dest, 0, 6);
27 - return;
28 - }
29 -
30 - for (;;) {
31 - dest[i++] = (char) simple_strtoul(str, NULL, 16);
32 - str += 2;
33 - if (!*str++ || i == 6)
34 - break;
35 - }
36 -}
37 -
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
58 @@ -12,6 +12,7 @@
59 #define __NVRAM_H
60
61 #include <linux/types.h>
62 +#include <linux/kernel.h>
63
64 struct nvram_header {
65 u32 magic;
66 @@ -36,4 +37,10 @@ struct nvram_header {
67
68 extern int nvram_getenv(char *name, char *val, size_t val_len);
69
70 +static inline void nvram_parse_macaddr(char *buf, u8 *macaddr)
71 +{
72 + sscanf(buf, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", &macaddr[0], &macaddr[1],
73 + &macaddr[2], &macaddr[3], &macaddr[4], &macaddr[5]);
74 +}
75 +
76 #endif
This page took 0.053307 seconds and 5 git commands to generate.