linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] arch: mips: use newly introduced hex_to_bin()
@ 2010-09-11 13:33 Andy Shevchenko
  2010-10-11 16:34 ` Andy Shevchenko
  0 siblings, 1 reply; 4+ messages in thread
From: Andy Shevchenko @ 2010-09-11 13:33 UTC (permalink / raw)
  To: linux-kernel; +Cc: Andy Shevchenko, Ralf Baechle, linux-mips

Remove custom implementation of hex_to_bin().

Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: linux-mips@linux-mips.org
---
 arch/mips/rb532/devices.c |   24 +++++++++---------------
 1 files changed, 9 insertions(+), 15 deletions(-)

diff --git a/arch/mips/rb532/devices.c b/arch/mips/rb532/devices.c
index 041fc1a..a969eb8 100644
--- a/arch/mips/rb532/devices.c
+++ b/arch/mips/rb532/devices.c
@@ -251,28 +251,22 @@ static struct platform_device *rb532_devs[] = {
 
 static void __init parse_mac_addr(char *macstr)
 {
-	int i, j;
-	unsigned char result, value;
+	int i, h, l;
 
 	for (i = 0; i < 6; i++) {
-		result = 0;
-
 		if (i != 5 && *(macstr + 2) != ':')
 			return;
 
-		for (j = 0; j < 2; j++) {
-			if (isxdigit(*macstr)
-			    && (value =
-				isdigit(*macstr) ? *macstr -
-				'0' : toupper(*macstr) - 'A' + 10) < 16) {
-				result = result * 16 + value;
-				macstr++;
-			} else
-				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] = result;
+		korina_dev0_data.mac[i] = (h << 4) + l;
 	}
 }
 
-- 
1.7.2.2


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

* Re: [PATCH] arch: mips: use newly introduced hex_to_bin()
  2010-09-11 13:33 [PATCH] arch: mips: use newly introduced hex_to_bin() Andy Shevchenko
@ 2010-10-11 16:34 ` Andy Shevchenko
  2010-11-08  7:26   ` Florian Fainelli
  0 siblings, 1 reply; 4+ messages in thread
From: Andy Shevchenko @ 2010-10-11 16:34 UTC (permalink / raw)
  To: linux-kernel; +Cc: Andy Shevchenko, Ralf Baechle, linux-mips

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=UTF-8, Size: 2275 bytes --]

Any comments here?

On Sat, Sep 11, 2010 at 4:33 PM, Andy Shevchenko
<andy.shevchenko@gmail.com> wrote:
> Remove custom implementation of hex_to_bin().
>
> Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
> Cc: Ralf Baechle <ralf@linux-mips.org>
> Cc: linux-mips@linux-mips.org
> ---
>  arch/mips/rb532/devices.c |   24 +++++++++---------------
>  1 files changed, 9 insertions(+), 15 deletions(-)
>
> diff --git a/arch/mips/rb532/devices.c b/arch/mips/rb532/devices.c
> index 041fc1a..a969eb8 100644
> --- a/arch/mips/rb532/devices.c
> +++ b/arch/mips/rb532/devices.c
> @@ -251,28 +251,22 @@ static struct platform_device *rb532_devs[] = {
>
>  static void __init parse_mac_addr(char *macstr)
>  {
> -       int i, j;
> -       unsigned char result, value;
> +       int i, h, l;
>
>        for (i = 0; i < 6; i++) {
> -               result = 0;
> -
>                if (i != 5 && *(macstr + 2) != ':')
>                        return;
>
> -               for (j = 0; j < 2; j++) {
> -                       if (isxdigit(*macstr)
> -                           && (value =
> -                               isdigit(*macstr) ? *macstr -
> -                               '0' : toupper(*macstr) - 'A' + 10) < 16) {
> -                               result = result * 16 + value;
> -                               macstr++;
> -                       } else
> -                               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] = result;
> +               korina_dev0_data.mac[i] = (h << 4) + l;
>        }
>  }
>
> --
> 1.7.2.2
>
>



-- 
With Best Regards,
Andy Shevchenko
ÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ\x17¥Šwÿº{.nÇ+‰·¥Š{±þG«éÿŠ{ayº\x1dʇڙë,j\a­¢f£¢·hšïêÿ‘êçz_è®\x03(­éšŽŠÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?™¨è­Ú&£ø§~á¶iO•æ¬z·švØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?–I¥

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

* Re: [PATCH] arch: mips: use newly introduced hex_to_bin()
  2010-10-11 16:34 ` Andy Shevchenko
@ 2010-11-08  7:26   ` Florian Fainelli
  2011-05-19 16:12     ` Ralf Baechle
  0 siblings, 1 reply; 4+ messages in thread
From: Florian Fainelli @ 2010-11-08  7:26 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: linux-kernel, Ralf Baechle, linux-mips

Le Monday 11 October 2010 18:34:16, Andy Shevchenko a écrit :
> Any comments here?

Acked-by: Florian Fainelli <florian@openwrt.org>

> 
> On Sat, Sep 11, 2010 at 4:33 PM, Andy Shevchenko
> 
> <andy.shevchenko@gmail.com> wrote:
> > Remove custom implementation of hex_to_bin().
> > 
> > Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
> > Cc: Ralf Baechle <ralf@linux-mips.org>
> > Cc: linux-mips@linux-mips.org
> > ---
> >  arch/mips/rb532/devices.c |   24 +++++++++---------------
> >  1 files changed, 9 insertions(+), 15 deletions(-)
> > 
> > diff --git a/arch/mips/rb532/devices.c b/arch/mips/rb532/devices.c
> > index 041fc1a..a969eb8 100644
> > --- a/arch/mips/rb532/devices.c
> > +++ b/arch/mips/rb532/devices.c
> > @@ -251,28 +251,22 @@ static struct platform_device *rb532_devs[] = {
> > 
> >  static void __init parse_mac_addr(char *macstr)
> >  {
> > -       int i, j;
> > -       unsigned char result, value;
> > +       int i, h, l;
> > 
> >        for (i = 0; i < 6; i++) {
> > -               result = 0;
> > -
> >                if (i != 5 && *(macstr + 2) != ':')
> >                        return;
> > 
> > -               for (j = 0; j < 2; j++) {
> > -                       if (isxdigit(*macstr)
> > -                           && (value =
> > -                               isdigit(*macstr) ? *macstr -
> > -                               '0' : toupper(*macstr) - 'A' + 10) < 16)
> > { -                               result = result * 16 + value;
> > -                               macstr++;
> > -                       } else
> > -                               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] = result;
> > +               korina_dev0_data.mac[i] = (h << 4) + l;
> >        }
> >  }
> > 
> > --
> > 1.7.2.2

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

* Re: [PATCH] arch: mips: use newly introduced hex_to_bin()
  2010-11-08  7:26   ` Florian Fainelli
@ 2011-05-19 16:12     ` Ralf Baechle
  0 siblings, 0 replies; 4+ messages in thread
From: Ralf Baechle @ 2011-05-19 16:12 UTC (permalink / raw)
  To: Florian Fainelli; +Cc: Andy Shevchenko, linux-kernel, linux-mips

Queued for 2.6.41.  Thanks,

  Ralf

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

end of thread, other threads:[~2011-05-19 16:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-11 13:33 [PATCH] arch: mips: use newly introduced hex_to_bin() Andy Shevchenko
2010-10-11 16:34 ` Andy Shevchenko
2010-11-08  7:26   ` Florian Fainelli
2011-05-19 16:12     ` Ralf Baechle

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).