drivers: scsi: remove private hex_to_bin() implementation
Subsystems (2)
PATCH 1/1 drivers: scsi: remove private hex_to_bin() implementation
Signed-off-by Andy Shevchenko <[email protected]>
Cc "James E.J. Bottomley" <[email protected]>
--- drivers/scsi/libsas/sas_scsi_host.c | 10 +++------- 1 files changed, 3 insertions(+), 7 deletions(-)
drivers/scsi/libsas/sas_scsi_host.c +3 -7
@@ -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; } }
Signature · 1 line
1.7.2.2
Quoted 16 lines · Andy Shevchenko
Signed-off-by Andy Shevchenko <[email protected]>Cc "James E.J. Bottomley" <[email protected]>--- drivers/scsi/libsas/sas_scsi_host.c | 10 +++------- 1 files changed, 3 insertions(+), 7 deletions(-)drivers/scsi/libsas/sas_scsi_host.c +0
-1@@ -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++) {
drivers/scsi/libsas/sas_scsi_host.c void sas_target_destroy(struct scsi_target *starget) · line 1084
Quoted 10 lines
drivers/scsi/libsas/sas_scsi_host.c +3
-6+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
Quoted 3 lines · James Bottomley
the
hex_to_bin()is really to prevent open coded mistakes. When the open coding pre-dates thehex_to_binmacro, 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.
Signature · 2 lines
With Best Regards, Andy Shevchenko