public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] arch/mips rb532: replace mac_addr parsing
@ 2014-06-24  8:45 Daniel Walter
  2014-06-24 10:13 ` James Hogan
  0 siblings, 1 reply; 2+ messages in thread
From: Daniel Walter @ 2014-06-24  8:45 UTC (permalink / raw)
  To: Ralf Baechle; +Cc: linux-mips, linux-kernel

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;
 }
 

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] arch/mips rb532: replace mac_addr parsing
  2014-06-24  8:45 [PATCH v2] arch/mips rb532: replace mac_addr parsing Daniel Walter
@ 2014-06-24 10:13 ` James Hogan
  0 siblings, 0 replies; 2+ messages in thread
From: James Hogan @ 2014-06-24 10:13 UTC (permalink / raw)
  To: Daniel Walter, Ralf Baechle; +Cc: linux-mips, linux-kernel

Hi Daniel,

On 24/06/14 09:45, Daniel Walter wrote:
> @@ -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]);

Does it make sense to go one better and use mac_pton() for this?

Cheers
James

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-06-24 10:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-24  8:45 [PATCH v2] arch/mips rb532: replace mac_addr parsing Daniel Walter
2014-06-24 10:13 ` James Hogan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox