From: James Hogan <james.hogan@imgtec.com>
To: Daniel Walter <dwalter@google.com>, Ralf Baechle <ralf@linux-mips.org>
Cc: <linux-mips@linux-mips.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v3] arch/mips/rb532: replace mac_addr parsing
Date: Tue, 24 Jun 2014 13:55:59 +0100 [thread overview]
Message-ID: <53A9755F.9000403@imgtec.com> (raw)
In-Reply-To: <20140624111426.GA15160@google.com>
On 24/06/14 12:14, Daniel Walter wrote:
> Replace parse_mac_addr with mac_pton().
>
>
> Signed-off-by: Daniel Walter <dwalter@google.com>
Reviewed-by: James Hogan <james.hogan@imgtec.com>
Cheers
James
> ---
> Changes since v2
> Use mac_pton() instead of sscanf()
> added error handling in case could not be parsed
> ---
> Patch applies against current linux-git
> ---
> arch/mips/rb532/devices.c | 27 ++++-----------------------
> 1 file changed, 4 insertions(+), 23 deletions(-)
> ---
> diff --git a/arch/mips/rb532/devices.c b/arch/mips/rb532/devices.c
> index 3af00b2..03a4cdc 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,10 @@ 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);
> + if (!mac_pton(s, korina_dev0_data.mac)) {
> + printk(KERN_ERR "Invalid mac\n");
> + return -EINVAL;
> + }
> return 0;
> }
>
>
WARNING: multiple messages have this Message-ID (diff)
From: James Hogan <james.hogan@imgtec.com>
To: Daniel Walter <dwalter@google.com>, Ralf Baechle <ralf@linux-mips.org>
Cc: linux-mips@linux-mips.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] arch/mips/rb532: replace mac_addr parsing
Date: Tue, 24 Jun 2014 13:55:59 +0100 [thread overview]
Message-ID: <53A9755F.9000403@imgtec.com> (raw)
Message-ID: <20140624125559.I0pC84zHfmRW9ZvCVTwJBbJquFMAwav2l0hPNpy0SHE@z> (raw)
In-Reply-To: <20140624111426.GA15160@google.com>
On 24/06/14 12:14, Daniel Walter wrote:
> Replace parse_mac_addr with mac_pton().
>
>
> Signed-off-by: Daniel Walter <dwalter@google.com>
Reviewed-by: James Hogan <james.hogan@imgtec.com>
Cheers
James
> ---
> Changes since v2
> Use mac_pton() instead of sscanf()
> added error handling in case could not be parsed
> ---
> Patch applies against current linux-git
> ---
> arch/mips/rb532/devices.c | 27 ++++-----------------------
> 1 file changed, 4 insertions(+), 23 deletions(-)
> ---
> diff --git a/arch/mips/rb532/devices.c b/arch/mips/rb532/devices.c
> index 3af00b2..03a4cdc 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,10 @@ 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);
> + if (!mac_pton(s, korina_dev0_data.mac)) {
> + printk(KERN_ERR "Invalid mac\n");
> + return -EINVAL;
> + }
> return 0;
> }
>
>
next prev parent reply other threads:[~2014-06-24 14:31 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-24 11:14 [PATCH v3] arch/mips/rb532: replace mac_addr parsing Daniel Walter
2014-06-24 12:55 ` James Hogan [this message]
2014-06-24 12:55 ` James Hogan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=53A9755F.9000403@imgtec.com \
--to=james.hogan@imgtec.com \
--cc=dwalter@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@linux-mips.org \
--cc=ralf@linux-mips.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.