Re: [PATCH] arch: mips: use newly introduced hex_to_bin()

From: Andy Shevchenko
Date: Mon Oct 11 2010 - 12:34:21 EST


Any comments here?

On Sat, Sep 11, 2010 at 4:33 PM, Andy Shevchenko
<andy.shevchenko@xxxxxxxxx> wrote:
> Remove custom implementation of hex_to_bin().
>
> Signed-off-by: Andy Shevchenko <andy.shevchenko@xxxxxxxxx>
> Cc: Ralf Baechle <ralf@xxxxxxxxxxxxxx>
> Cc: linux-mips@xxxxxxxxxxxxxx
> ---
> Â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‹§²æìr¸›yúèšØb²X¬¶ÇvØ^–)Þ{.nÇ+‰·¥Š{±‘êçzX§¶›¡Ü}©ž²ÆzÚ&j:+v‰¨¾«‘êçzZ+€Ê+zf£¢·hšˆ§~†­†Ûiÿûàz¹®w¥¢¸?™¨è­Ú&¢)ßf”ù^jÇy§m…á@A«a¶Úÿ 0¶ìh®å’i