summaryrefslogtreecommitdiff
path: root/target/linux/brcm47xx/patches-2.6.37/012-MIPS-BCM47xx-Use-sscanf-for-parsing-mac-address.patch
diff options
context:
space:
mode:
authorHauke Mehrtens <hauke@hauke-m.de>2010-11-27 22:47:11 +0000
committerHauke Mehrtens <hauke@hauke-m.de>2010-11-27 22:47:11 +0000
commitfb27da9487421f7e008c6ddb59fb23122dcc51c5 (patch)
tree9a288522a688a655ab4963eb9c1d27b68994d10c /target/linux/brcm47xx/patches-2.6.37/012-MIPS-BCM47xx-Use-sscanf-for-parsing-mac-address.patch
parentb54002aa8ec6b3c4cc980179d0cf8b0e828d4efa (diff)
downloadmtk-20170518-fb27da9487421f7e008c6ddb59fb23122dcc51c5.zip
mtk-20170518-fb27da9487421f7e008c6ddb59fb23122dcc51c5.tar.gz
mtk-20170518-fb27da9487421f7e008c6ddb59fb23122dcc51c5.tar.bz2
brcm47xx: reorder patches like they were commitet upstream
SVN-Revision: 24162
Diffstat (limited to 'target/linux/brcm47xx/patches-2.6.37/012-MIPS-BCM47xx-Use-sscanf-for-parsing-mac-address.patch')
-rw-r--r--target/linux/brcm47xx/patches-2.6.37/012-MIPS-BCM47xx-Use-sscanf-for-parsing-mac-address.patch76
1 files changed, 76 insertions, 0 deletions
diff --git a/target/linux/brcm47xx/patches-2.6.37/012-MIPS-BCM47xx-Use-sscanf-for-parsing-mac-address.patch b/target/linux/brcm47xx/patches-2.6.37/012-MIPS-BCM47xx-Use-sscanf-for-parsing-mac-address.patch
new file mode 100644
index 0000000..d4321c3
--- /dev/null
+++ b/target/linux/brcm47xx/patches-2.6.37/012-MIPS-BCM47xx-Use-sscanf-for-parsing-mac-address.patch
@@ -0,0 +1,76 @@
+From f52926174040418e26112cd0ba36afd8bb066928 Mon Sep 17 00:00:00 2001
+From: Hauke Mehrtens <hauke@hauke-m.de>
+Date: Sat, 27 Nov 2010 14:02:49 +0100
+Subject: [PATCH 3/6] MIPS: BCM47xx: Use sscanf for parsing mac address
+
+Instead of writing out own function for parsing the mac address we now
+use sscanf.
+
+Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
+---
+ arch/mips/bcm47xx/setup.c | 23 +++--------------------
+ arch/mips/include/asm/mach-bcm47xx/nvram.h | 7 +++++++
+ 2 files changed, 10 insertions(+), 20 deletions(-)
+
+--- a/arch/mips/bcm47xx/setup.c
++++ b/arch/mips/bcm47xx/setup.c
+@@ -56,23 +56,6 @@ static void bcm47xx_machine_halt(void)
+ cpu_relax();
+ }
+
+-static void str2eaddr(char *str, char *dest)
+-{
+- int i = 0;
+-
+- if (str == NULL) {
+- memset(dest, 0, 6);
+- return;
+- }
+-
+- for (;;) {
+- dest[i++] = (char) simple_strtoul(str, NULL, 16);
+- str += 2;
+- if (!*str++ || i == 6)
+- break;
+- }
+-}
+-
+ #define READ_FROM_NVRAM(_outvar, name, buf) \
+ if (nvram_getenv(name, buf, sizeof(buf)) >= 0)\
+ sprom->_outvar = simple_strtoul(buf, NULL, 0);
+@@ -87,11 +70,11 @@ static void bcm47xx_fill_sprom(struct ss
+ sprom->revision = 1; /* Fallback: Old hardware does not define this. */
+ READ_FROM_NVRAM(revision, "sromrev", buf);
+ if (nvram_getenv("il0macaddr", buf, sizeof(buf)) >= 0)
+- str2eaddr(buf, sprom->il0mac);
++ nvram_parse_macaddr(buf, sprom->il0mac);
+ if (nvram_getenv("et0macaddr", buf, sizeof(buf)) >= 0)
+- str2eaddr(buf, sprom->et0mac);
++ nvram_parse_macaddr(buf, sprom->et0mac);
+ if (nvram_getenv("et1macaddr", buf, sizeof(buf)) >= 0)
+- str2eaddr(buf, sprom->et1mac);
++ nvram_parse_macaddr(buf, sprom->et1mac);
+ READ_FROM_NVRAM(et0phyaddr, "et0phyaddr", buf);
+ READ_FROM_NVRAM(et1phyaddr, "et1phyaddr", buf);
+ READ_FROM_NVRAM(et0mdcport, "et0mdcport", buf);
+--- a/arch/mips/include/asm/mach-bcm47xx/nvram.h
++++ b/arch/mips/include/asm/mach-bcm47xx/nvram.h
+@@ -12,6 +12,7 @@
+ #define __NVRAM_H
+
+ #include <linux/types.h>
++#include <linux/kernel.h>
+
+ struct nvram_header {
+ u32 magic;
+@@ -36,4 +37,10 @@ struct nvram_header {
+
+ 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]);
++}
++
+ #endif