linux-mips
[Top] [All Lists]

[PATCH v2 5/5] MIPS: BCM47xx: Fix mac address parsing.

To: ralf@linux-mips.org
Subject: [PATCH v2 5/5] MIPS: BCM47xx: Fix mac address parsing.
From: Hauke Mehrtens <hauke@hauke-m.de>
Date: Tue, 10 May 2011 23:31:34 +0200
Cc: linux-mips@linux-mips.org, Hauke Mehrtens <hauke@hauke-m.de>
In-reply-to: <1305063094-26656-1-git-send-email-hauke@hauke-m.de>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <1305063094-26656-1-git-send-email-hauke@hauke-m.de>
Sender: linux-mips-bounce@linux-mips.org
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: Hauke Mehrtens <hauke@hauke-m.de>
---
v2: * fix some checkpatch errors and warnings

 arch/mips/include/asm/mach-bcm47xx/nvram.h |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/arch/mips/include/asm/mach-bcm47xx/nvram.h 
b/arch/mips/include/asm/mach-bcm47xx/nvram.h
index 9759588..184d5ec 100644
--- a/arch/mips/include/asm/mach-bcm47xx/nvram.h
+++ b/arch/mips/include/asm/mach-bcm47xx/nvram.h
@@ -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
-- 
1.7.4.1


<Prev in Thread] Current Thread [Next in Thread>