Commit ecc30990 authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Linus Torvalds

drivers: scsi: use newly introduced hex_to_bin() method

Signed-off-by: default avatarAndy 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: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 3094141c
...@@ -352,9 +352,8 @@ static int aac_rx_check_health(struct aac_dev *dev) ...@@ -352,9 +352,8 @@ static int aac_rx_check_health(struct aac_dev *dev)
pci_free_consistent(dev->pdev, sizeof(struct POSTSTATUS), pci_free_consistent(dev->pdev, sizeof(struct POSTSTATUS),
post, paddr); post, paddr);
if (likely((buffer[0] == '0') && ((buffer[1] == 'x') || (buffer[1] == 'X')))) { if (likely((buffer[0] == '0') && ((buffer[1] == 'x') || (buffer[1] == 'X')))) {
ret = (buffer[2] <= '9') ? (buffer[2] - '0') : (buffer[2] - 'A' + 10); ret = (hex_to_bin(buffer[2]) << 4) +
ret <<= 4; hex_to_bin(buffer[3]);
ret += (buffer[3] <= '9') ? (buffer[3] - '0') : (buffer[3] - 'A' + 10);
} }
pci_free_consistent(dev->pdev, 512, buffer, baddr); pci_free_consistent(dev->pdev, 512, buffer, baddr);
return ret; return ret;
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/aer.h> #include <linux/aer.h>
#include <linux/gfp.h> #include <linux/gfp.h>
#include <linux/kernel.h>
#include <scsi/scsi.h> #include <scsi/scsi.h>
#include <scsi/scsi_device.h> #include <scsi/scsi_device.h>
...@@ -1795,12 +1796,11 @@ lpfc_soft_wwpn_store(struct device *dev, struct device_attribute *attr, ...@@ -1795,12 +1796,11 @@ lpfc_soft_wwpn_store(struct device *dev, struct device_attribute *attr,
/* Validate and store the new name */ /* Validate and store the new name */
for (i=0, j=0; i < 16; i++) { for (i=0, j=0; i < 16; i++) {
if ((*buf >= 'a') && (*buf <= 'f')) int value;
j = ((j << 4) | ((*buf++ -'a') + 10));
else if ((*buf >= 'A') && (*buf <= 'F')) value = hex_to_bin(*buf++);
j = ((j << 4) | ((*buf++ -'A') + 10)); if (value >= 0)
else if ((*buf >= '0') && (*buf <= '9')) j = (j << 4) | value;
j = ((j << 4) | (*buf++ -'0'));
else else
return -EINVAL; return -EINVAL;
if (i % 2) { if (i % 2) {
...@@ -1888,12 +1888,11 @@ lpfc_soft_wwnn_store(struct device *dev, struct device_attribute *attr, ...@@ -1888,12 +1888,11 @@ lpfc_soft_wwnn_store(struct device *dev, struct device_attribute *attr,
/* Validate and store the new name */ /* Validate and store the new name */
for (i=0, j=0; i < 16; i++) { for (i=0, j=0; i < 16; i++) {
if ((*buf >= 'a') && (*buf <= 'f')) int value;
j = ((j << 4) | ((*buf++ -'a') + 10));
else if ((*buf >= 'A') && (*buf <= 'F')) value = hex_to_bin(*buf++);
j = ((j << 4) | ((*buf++ -'A') + 10)); if (value >= 0)
else if ((*buf >= '0') && (*buf <= '9')) j = (j << 4) | value;
j = ((j << 4) | (*buf++ -'0'));
else else
return -EINVAL; return -EINVAL;
if (i % 2) { if (i % 2) {
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include <linux/init.h> #include <linux/init.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/kernel.h>
#include <scsi/scsi_device.h> #include <scsi/scsi_device.h>
#include <scsi/scsi_host.h> #include <scsi/scsi_host.h>
#include <scsi/scsi_transport.h> #include <scsi/scsi_transport.h>
...@@ -1730,12 +1731,11 @@ fc_parse_wwn(const char *ns, u64 *nm) ...@@ -1730,12 +1731,11 @@ fc_parse_wwn(const char *ns, u64 *nm)
/* Validate and store the new name */ /* Validate and store the new name */
for (i=0, j=0; i < 16; i++) { for (i=0, j=0; i < 16; i++) {
if ((*ns >= 'a') && (*ns <= 'f')) int value;
j = ((j << 4) | ((*ns++ -'a') + 10));
else if ((*ns >= 'A') && (*ns <= 'F')) value = hex_to_bin(*ns++);
j = ((j << 4) | ((*ns++ -'A') + 10)); if (value >= 0)
else if ((*ns >= '0') && (*ns <= '9')) j = (j << 4) | value;
j = ((j << 4) | (*ns++ -'0'));
else else
return -EINVAL; return -EINVAL;
if (i % 2) { if (i % 2) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment