diff options
author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2011-09-30 07:45:40 -0400 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2011-10-23 23:20:49 -0400 |
commit | 635a2b3f3e561278cb5b837ea305e50e3fa7f063 (patch) | |
tree | 5247707ab19c1f766b9fadb12adf06587fbcd8aa /drivers/target/tcm_fc | |
parent | f2b56afd406b455fba339a35f43bfc4ada198073 (diff) |
tcm_fc: remove custom hex_to_bin in ft_parse_wwn
This patch converts ft_parse_wwn() to use hex_to_bin() instead of custom
conversion code.
(Andy: Re-add missing strict && isupper(c) check)
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: "Nicholas A. Bellinger" <nab@linux-iscsi.org>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers/target/tcm_fc')
-rw-r--r-- | drivers/target/tcm_fc/tfc_conf.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/drivers/target/tcm_fc/tfc_conf.c b/drivers/target/tcm_fc/tfc_conf.c index b30eace70d35..5f770412ca40 100644 --- a/drivers/target/tcm_fc/tfc_conf.c +++ b/drivers/target/tcm_fc/tfc_conf.c | |||
@@ -31,6 +31,7 @@ | |||
31 | #include <linux/types.h> | 31 | #include <linux/types.h> |
32 | #include <linux/string.h> | 32 | #include <linux/string.h> |
33 | #include <linux/configfs.h> | 33 | #include <linux/configfs.h> |
34 | #include <linux/kernel.h> | ||
34 | #include <linux/ctype.h> | 35 | #include <linux/ctype.h> |
35 | #include <asm/unaligned.h> | 36 | #include <asm/unaligned.h> |
36 | #include <scsi/scsi.h> | 37 | #include <scsi/scsi.h> |
@@ -70,10 +71,10 @@ static ssize_t ft_parse_wwn(const char *name, u64 *wwn, int strict) | |||
70 | { | 71 | { |
71 | const char *cp; | 72 | const char *cp; |
72 | char c; | 73 | char c; |
73 | u32 nibble; | ||
74 | u32 byte = 0; | 74 | u32 byte = 0; |
75 | u32 pos = 0; | 75 | u32 pos = 0; |
76 | u32 err; | 76 | u32 err; |
77 | int val; | ||
77 | 78 | ||
78 | *wwn = 0; | 79 | *wwn = 0; |
79 | for (cp = name; cp < &name[FT_NAMELEN - 1]; cp++) { | 80 | for (cp = name; cp < &name[FT_NAMELEN - 1]; cp++) { |
@@ -94,13 +95,10 @@ static ssize_t ft_parse_wwn(const char *name, u64 *wwn, int strict) | |||
94 | return cp - name; | 95 | return cp - name; |
95 | } | 96 | } |
96 | err = 3; | 97 | err = 3; |
97 | if (isdigit(c)) | 98 | val = hex_to_bin(c); |
98 | nibble = c - '0'; | 99 | if (val < 0 || (strict && isupper(c))) |
99 | else if (isxdigit(c) && (islower(c) || !strict)) | ||
100 | nibble = tolower(c) - 'a' + 10; | ||
101 | else | ||
102 | goto fail; | 100 | goto fail; |
103 | *wwn = (*wwn << 4) | nibble; | 101 | *wwn = (*wwn << 4) | val; |
104 | } | 102 | } |
105 | err = 4; | 103 | err = 4; |
106 | fail: | 104 | fail: |