提交 635a2b3f 编写于 作者: A Andy Shevchenko 提交者: Nicholas Bellinger

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: NAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: "Nicholas A. Bellinger" <nab@linux-iscsi.org>
Signed-off-by: NNicholas Bellinger <nab@linux-iscsi.org>
上级 f2b56afd
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include <linux/types.h> #include <linux/types.h>
#include <linux/string.h> #include <linux/string.h>
#include <linux/configfs.h> #include <linux/configfs.h>
#include <linux/kernel.h>
#include <linux/ctype.h> #include <linux/ctype.h>
#include <asm/unaligned.h> #include <asm/unaligned.h>
#include <scsi/scsi.h> #include <scsi/scsi.h>
...@@ -70,10 +71,10 @@ static ssize_t ft_parse_wwn(const char *name, u64 *wwn, int strict) ...@@ -70,10 +71,10 @@ static ssize_t ft_parse_wwn(const char *name, u64 *wwn, int strict)
{ {
const char *cp; const char *cp;
char c; char c;
u32 nibble;
u32 byte = 0; u32 byte = 0;
u32 pos = 0; u32 pos = 0;
u32 err; u32 err;
int val;
*wwn = 0; *wwn = 0;
for (cp = name; cp < &name[FT_NAMELEN - 1]; cp++) { 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,13 +95,10 @@ static ssize_t ft_parse_wwn(const char *name, u64 *wwn, int strict)
return cp - name; return cp - name;
} }
err = 3; err = 3;
if (isdigit(c)) val = hex_to_bin(c);
nibble = c - '0'; if (val < 0 || (strict && isupper(c)))
else if (isxdigit(c) && (islower(c) || !strict))
nibble = tolower(c) - 'a' + 10;
else
goto fail; goto fail;
*wwn = (*wwn << 4) | nibble; *wwn = (*wwn << 4) | val;
} }
err = 4; err = 4;
fail: fail:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册