linux-mips
[Top] [All Lists]

[PATCH v2] arch/mips rb532: replace mac_addr parsing

To: Ralf Baechle <ralf@linux-mips.org>
Subject: [PATCH v2] arch/mips rb532: replace mac_addr parsing
From: Daniel Walter <dwalter@google.com>
Date: Tue, 24 Jun 2014 09:45:40 +0100
Cc: linux-mips@linux-mips.org, linux-kernel@vger.kernel.org
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=date:from:to:cc:subject:message-id:mime-version:content-type :content-disposition:user-agent; bh=JnyrGWaR4E0ZLB0Yb3VE3RtpF1m73XNfA/fj4N3+qio=; b=pXnUtD/wxTHw1rm8HFHoQt14CZbOuaszFTAslHhNKgBR6JObojwsej3nnIUTkKvF8v M7+ckVjoM5BEG7kC4A0GUikJNk3I3jem3/LoyMRpCsoRxxxtrWfUIWiNpeqcQZLLYNU9 yoFm0S/vJDHr6jY++NFH87ndOAQ3v7N2UnDvq9a3wrGSM5IFMPT3Qm72BTmfNVFudL6n 1tiFmWtxjgEUo6lH2R+j3ISdeQ6HaETQSn934vU4VGqirwMWFHmxRc0IOcJFq7h05lGj 4BK3NTTnbTlP4PSqMPeni/M1EJIGU0CSzvR+9a2aBOuQO5vG7YRSI7DFORqj/9jBG3li +QQw==
List-archive: <http://www.linux-mips.org/archives/linux-mips/>
List-help: <mailto:ecartis@linux-mips.org?Subject=help>
List-id: linux-mips <linux-mips.eddie.linux-mips.org>
List-owner: <mailto:ralf@linux-mips.org>
List-post: <mailto:linux-mips@linux-mips.org>
List-software: Ecartis version 1.0.0
List-subscribe: <mailto:ecartis@linux-mips.org?subject=subscribe%20linux-mips>
List-unsubscribe: <mailto:ecartis@linux-mips.org?subject=unsubscribe%20linux-mips>
Original-recipient: rfc822;linux-mips@linux-mips.org
Sender: linux-mips-bounce@linux-mips.org
User-agent: Mutt/1.5.21 (2010-09-15)
Replace parse_mac_addr with sscanf.


Signed-off-by: Daniel Walter <dwalter@google.com>
---
Changes since v1:
  sending in the working patch
Patch applies against current linux-tree
---
 arch/mips/rb532/devices.c | 30 +++++++-----------------------
 1 file changed, 7 insertions(+), 23 deletions(-)
---
diff --git a/arch/mips/rb532/devices.c b/arch/mips/rb532/devices.c
index 3af00b2..6e32819b 100644
--- a/arch/mips/rb532/devices.c
+++ b/arch/mips/rb532/devices.c
@@ -250,28 +250,6 @@ static struct platform_device *rb532_devs[] = {
        &rb532_wdt
 };
 
-static void __init parse_mac_addr(char *macstr)
-{
-       int i, h, l;
-
-       for (i = 0; i < 6; i++) {
-               if (i != 5 && *(macstr + 2) != ':')
-                       return;
-
-               h = hex_to_bin(*macstr++);
-               if (h == -1)
-                       return;
-
-               l = hex_to_bin(*macstr++);
-               if (l == -1)
-                       return;
-
-               macstr++;
-               korina_dev0_data.mac[i] = (h << 4) + l;
-       }
-}
-
-
 /* NAND definitions */
 #define NAND_CHIP_DELAY 25
 
@@ -333,7 +311,13 @@ static int __init plat_setup_devices(void)
 static int __init setup_kmac(char *s)
 {
        printk(KERN_INFO "korina mac = %s\n", s);
-       parse_mac_addr(s);
+       sscanf(s, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx",
+                       &korina_dev0_data.mac[0],
+                       &korina_dev0_data.mac[1],
+                       &korina_dev0_data.mac[2],
+                       &korina_dev0_data.mac[3],
+                       &korina_dev0_data.mac[4],
+                       &korina_dev0_data.mac[5]);
        return 0;
 }
 

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