Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drivers: scsi: use newly introduced hex_to_bin() method

Signed-off-by: Andy Shevchenko <ext-andriy.shevchenko@nokia.com>
Cc: Adaptec OEM Raid Solutions <aacraid@adaptec.com>
Cc: "James E.J. Bottomley" <James.Bottomley@suse.de>
Cc: James Smart <james.smart@emulex.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Andy Shevchenko and committed by
Linus Torvalds
ecc30990 3094141c

+19 -21
+2 -3
drivers/scsi/aacraid/rx.c
··· 352 352 pci_free_consistent(dev->pdev, sizeof(struct POSTSTATUS), 353 353 post, paddr); 354 354 if (likely((buffer[0] == '0') && ((buffer[1] == 'x') || (buffer[1] == 'X')))) { 355 - ret = (buffer[2] <= '9') ? (buffer[2] - '0') : (buffer[2] - 'A' + 10); 356 - ret <<= 4; 357 - ret += (buffer[3] <= '9') ? (buffer[3] - '0') : (buffer[3] - 'A' + 10); 355 + ret = (hex_to_bin(buffer[2]) << 4) + 356 + hex_to_bin(buffer[3]); 358 357 } 359 358 pci_free_consistent(dev->pdev, 512, buffer, baddr); 360 359 return ret;
+11 -12
drivers/scsi/lpfc/lpfc_attr.c
··· 25 25 #include <linux/interrupt.h> 26 26 #include <linux/aer.h> 27 27 #include <linux/gfp.h> 28 + #include <linux/kernel.h> 28 29 29 30 #include <scsi/scsi.h> 30 31 #include <scsi/scsi_device.h> ··· 1796 1795 1797 1796 /* Validate and store the new name */ 1798 1797 for (i=0, j=0; i < 16; i++) { 1799 - if ((*buf >= 'a') && (*buf <= 'f')) 1800 - j = ((j << 4) | ((*buf++ -'a') + 10)); 1801 - else if ((*buf >= 'A') && (*buf <= 'F')) 1802 - j = ((j << 4) | ((*buf++ -'A') + 10)); 1803 - else if ((*buf >= '0') && (*buf <= '9')) 1804 - j = ((j << 4) | (*buf++ -'0')); 1798 + int value; 1799 + 1800 + value = hex_to_bin(*buf++); 1801 + if (value >= 0) 1802 + j = (j << 4) | value; 1805 1803 else 1806 1804 return -EINVAL; 1807 1805 if (i % 2) { ··· 1888 1888 1889 1889 /* Validate and store the new name */ 1890 1890 for (i=0, j=0; i < 16; i++) { 1891 - if ((*buf >= 'a') && (*buf <= 'f')) 1892 - j = ((j << 4) | ((*buf++ -'a') + 10)); 1893 - else if ((*buf >= 'A') && (*buf <= 'F')) 1894 - j = ((j << 4) | ((*buf++ -'A') + 10)); 1895 - else if ((*buf >= '0') && (*buf <= '9')) 1896 - j = ((j << 4) | (*buf++ -'0')); 1891 + int value; 1892 + 1893 + value = hex_to_bin(*buf++); 1894 + if (value >= 0) 1895 + j = (j << 4) | value; 1897 1896 else 1898 1897 return -EINVAL; 1899 1898 if (i % 2) {
+6 -6
drivers/scsi/scsi_transport_fc.c
··· 29 29 #include <linux/init.h> 30 30 #include <linux/slab.h> 31 31 #include <linux/delay.h> 32 + #include <linux/kernel.h> 32 33 #include <scsi/scsi_device.h> 33 34 #include <scsi/scsi_host.h> 34 35 #include <scsi/scsi_transport.h> ··· 1731 1730 1732 1731 /* Validate and store the new name */ 1733 1732 for (i=0, j=0; i < 16; i++) { 1734 - if ((*ns >= 'a') && (*ns <= 'f')) 1735 - j = ((j << 4) | ((*ns++ -'a') + 10)); 1736 - else if ((*ns >= 'A') && (*ns <= 'F')) 1737 - j = ((j << 4) | ((*ns++ -'A') + 10)); 1738 - else if ((*ns >= '0') && (*ns <= '9')) 1739 - j = ((j << 4) | (*ns++ -'0')); 1733 + int value; 1734 + 1735 + value = hex_to_bin(*ns++); 1736 + if (value >= 0) 1737 + j = (j << 4) | value; 1740 1738 else 1741 1739 return -EINVAL; 1742 1740 if (i % 2) {