* [PATCH] drivers: scsi: remove private hex_to_bin() implementation
@ 2010-09-11 13:38 Andy Shevchenko
2010-09-11 13:56 ` James Bottomley
0 siblings, 1 reply; 3+ messages in thread
From: Andy Shevchenko @ 2010-09-11 13:38 UTC (permalink / raw)
To: linux-kernel; +Cc: Andy Shevchenko, James E.J. Bottomley, linux-scsi
Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: "James E.J. Bottomley" <James.Bottomley@suse.de>
Cc: linux-scsi@vger.kernel.org
---
drivers/scsi/libsas/sas_scsi_host.c | 10 +++-------
1 files changed, 3 insertions(+), 7 deletions(-)
diff --git a/drivers/scsi/libsas/sas_scsi_host.c b/drivers/scsi/libsas/sas_scsi_host.c
index f0cfba9..527dcf7 100644
--- a/drivers/scsi/libsas/sas_scsi_host.c
+++ b/drivers/scsi/libsas/sas_scsi_host.c
@@ -1078,14 +1078,10 @@ void sas_target_destroy(struct scsi_target *starget)
static void sas_parse_addr(u8 *sas_addr, const char *p)
{
int i;
- for (i = 0; i < SAS_ADDR_SIZE; i++) {
+ for (i = 0; i < SAS_ADDR_SIZE && *p; i++) {
u8 h, l;
- if (!*p)
- break;
- h = isdigit(*p) ? *p-'0' : toupper(*p)-'A'+10;
- p++;
- l = isdigit(*p) ? *p-'0' : toupper(*p)-'A'+10;
- p++;
+ h = hex_to_bin(*p++);
+ l = hex_to_bin(*p++);
sas_addr[i] = (h<<4) | l;
}
}
--
1.7.2.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] drivers: scsi: remove private hex_to_bin() implementation
2010-09-11 13:38 [PATCH] drivers: scsi: remove private hex_to_bin() implementation Andy Shevchenko
@ 2010-09-11 13:56 ` James Bottomley
2010-09-22 8:41 ` Andy Shevchenko
0 siblings, 1 reply; 3+ messages in thread
From: James Bottomley @ 2010-09-11 13:56 UTC (permalink / raw)
To: Andy Shevchenko; +Cc: linux-kernel, linux-scsi
On Sat, 2010-09-11 at 16:38 +0300, Andy Shevchenko wrote:
> Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
> Cc: "James E.J. Bottomley" <James.Bottomley@suse.de>
> Cc: linux-scsi@vger.kernel.org
> ---
> drivers/scsi/libsas/sas_scsi_host.c | 10 +++-------
> 1 files changed, 3 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/scsi/libsas/sas_scsi_host.c b/drivers/scsi/libsas/sas_scsi_host.c
> index f0cfba9..527dcf7 100644
> --- a/drivers/scsi/libsas/sas_scsi_host.c
> +++ b/drivers/scsi/libsas/sas_scsi_host.c
> @@ -1078,14 +1078,10 @@ void sas_target_destroy(struct scsi_target *starget)
> static void sas_parse_addr(u8 *sas_addr, const char *p)
> {
> int i;
> - for (i = 0; i < SAS_ADDR_SIZE; i++) {
> + for (i = 0; i < SAS_ADDR_SIZE && *p; i++) {
> u8 h, l;
> - if (!*p)
> - break;
> - h = isdigit(*p) ? *p-'0' : toupper(*p)-'A'+10;
> - p++;
> - l = isdigit(*p) ? *p-'0' : toupper(*p)-'A'+10;
> - p++;
> + h = hex_to_bin(*p++);
> + l = hex_to_bin(*p++);
the hex_to_bin() is really to prevent open coded mistakes. When the
open coding pre-dates the hex_to_bin macro, I'm inclined to leave it
alone unless it contains an actual bug.
James
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] drivers: scsi: remove private hex_to_bin() implementation
2010-09-11 13:56 ` James Bottomley
@ 2010-09-22 8:41 ` Andy Shevchenko
0 siblings, 0 replies; 3+ messages in thread
From: Andy Shevchenko @ 2010-09-22 8:41 UTC (permalink / raw)
To: James Bottomley; +Cc: linux-kernel, linux-scsi
On Sat, Sep 11, 2010 at 4:56 PM, James Bottomley
<James.Bottomley@suse.de> wrote:
> the hex_to_bin() is really to prevent open coded mistakes. When the
> open coding pre-dates the hex_to_bin macro, I'm inclined to leave it
> alone unless it contains an actual bug.
It's also a matter of speed/size optimization. Nevertheless SCSI
subsystem already has such clean up.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-09-22 8:41 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-11 13:38 [PATCH] drivers: scsi: remove private hex_to_bin() implementation Andy Shevchenko
2010-09-11 13:56 ` James Bottomley
2010-09-22 8:41 ` Andy Shevchenko
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).