From mboxrd@z Thu Jan 1 00:00:00 1970 From: Takashi Iwai Subject: Re: [PATCH] alsa: 6fire: don't use custom hex_to_bin() Date: Fri, 23 Sep 2011 15:22:51 +0200 Message-ID: References: Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id 0B957243FF for ; Fri, 23 Sep 2011 15:22:53 +0200 (CEST) In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: alsa-devel-bounces@alsa-project.org Errors-To: alsa-devel-bounces@alsa-project.org To: Andy Shevchenko Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org List-Id: alsa-devel@alsa-project.org At Fri, 23 Sep 2011 14:32:11 +0300, Andy Shevchenko wrote: > > Signed-off-by: Andy Shevchenko > Cc: Takashi Iwai > Cc: alsa-devel@alsa-project.org Applied now. Thanks. Takashi > --- > sound/usb/6fire/firmware.c | 25 ++++++++++++------------- > 1 files changed, 12 insertions(+), 13 deletions(-) > > diff --git a/sound/usb/6fire/firmware.c b/sound/usb/6fire/firmware.c > index 3ebbdec..3b5f517 100644 > --- a/sound/usb/6fire/firmware.c > +++ b/sound/usb/6fire/firmware.c > @@ -17,6 +17,7 @@ > #include > #include > #include > +#include > > #include "firmware.h" > #include "chip.h" > @@ -60,21 +61,19 @@ struct ihex_record { > unsigned int txt_offset; /* current position in txt_data */ > }; > > -static u8 usb6fire_fw_ihex_nibble(const u8 n) > -{ > - if (n >= '0' && n <= '9') > - return n - '0'; > - else if (n >= 'A' && n <= 'F') > - return n - ('A' - 10); > - else if (n >= 'a' && n <= 'f') > - return n - ('a' - 10); > - return 0; > -} > - > static u8 usb6fire_fw_ihex_hex(const u8 *data, u8 *crc) > { > - u8 val = (usb6fire_fw_ihex_nibble(data[0]) << 4) | > - usb6fire_fw_ihex_nibble(data[1]); > + u8 val = 0; > + int hval; > + > + hval = hex_to_bin(data[0]); > + if (hval >= 0) > + val |= (hval << 4); > + > + hval = hex_to_bin(data[1]); > + if (hval >= 0) > + val |= hval; > + > *crc += val; > return val; > } > -- > 1.7.6.3 > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753909Ab1IWNW4 (ORCPT ); Fri, 23 Sep 2011 09:22:56 -0400 Received: from cantor2.suse.de ([195.135.220.15]:47810 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753558Ab1IWNWy (ORCPT ); Fri, 23 Sep 2011 09:22:54 -0400 Date: Fri, 23 Sep 2011 15:22:51 +0200 Message-ID: From: Takashi Iwai To: Andy Shevchenko Cc: linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org Subject: Re: [PATCH] alsa: 6fire: don't use custom hex_to_bin() In-Reply-To: References: User-Agent: Wanderlust/2.15.6 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.7 Emacs/23.3 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org At Fri, 23 Sep 2011 14:32:11 +0300, Andy Shevchenko wrote: > > Signed-off-by: Andy Shevchenko > Cc: Takashi Iwai > Cc: alsa-devel@alsa-project.org Applied now. Thanks. Takashi > --- > sound/usb/6fire/firmware.c | 25 ++++++++++++------------- > 1 files changed, 12 insertions(+), 13 deletions(-) > > diff --git a/sound/usb/6fire/firmware.c b/sound/usb/6fire/firmware.c > index 3ebbdec..3b5f517 100644 > --- a/sound/usb/6fire/firmware.c > +++ b/sound/usb/6fire/firmware.c > @@ -17,6 +17,7 @@ > #include > #include > #include > +#include > > #include "firmware.h" > #include "chip.h" > @@ -60,21 +61,19 @@ struct ihex_record { > unsigned int txt_offset; /* current position in txt_data */ > }; > > -static u8 usb6fire_fw_ihex_nibble(const u8 n) > -{ > - if (n >= '0' && n <= '9') > - return n - '0'; > - else if (n >= 'A' && n <= 'F') > - return n - ('A' - 10); > - else if (n >= 'a' && n <= 'f') > - return n - ('a' - 10); > - return 0; > -} > - > static u8 usb6fire_fw_ihex_hex(const u8 *data, u8 *crc) > { > - u8 val = (usb6fire_fw_ihex_nibble(data[0]) << 4) | > - usb6fire_fw_ihex_nibble(data[1]); > + u8 val = 0; > + int hval; > + > + hval = hex_to_bin(data[0]); > + if (hval >= 0) > + val |= (hval << 4); > + > + hval = hex_to_bin(data[1]); > + if (hval >= 0) > + val |= hval; > + > *crc += val; > return val; > } > -- > 1.7.6.3 >