]> Pileus Git - ~andy/linux/blobdiff - drivers/target/tcm_fc/tfc_conf.c
Merge branch 'for-usb-linus' of git.kernel.org/pub/scm/linux/kernel/git/sarah/xhci...
[~andy/linux] / drivers / target / tcm_fc / tfc_conf.c
index 8fa39b74f22c4a178ed714f123131521f0d78e84..5f770412ca403265ddfc19856ef4934470a25c63 100644 (file)
@@ -23,7 +23,6 @@
 
 #include <linux/module.h>
 #include <linux/moduleparam.h>
-#include <linux/version.h>
 #include <generated/utsrelease.h>
 #include <linux/utsname.h>
 #include <linux/init.h>
@@ -32,6 +31,7 @@
 #include <linux/types.h>
 #include <linux/string.h>
 #include <linux/configfs.h>
+#include <linux/kernel.h>
 #include <linux/ctype.h>
 #include <asm/unaligned.h>
 #include <scsi/scsi.h>
@@ -71,10 +71,10 @@ static ssize_t ft_parse_wwn(const char *name, u64 *wwn, int strict)
 {
        const char *cp;
        char c;
-       u32 nibble;
        u32 byte = 0;
        u32 pos = 0;
        u32 err;
+       int val;
 
        *wwn = 0;
        for (cp = name; cp < &name[FT_NAMELEN - 1]; cp++) {
@@ -95,13 +95,10 @@ static ssize_t ft_parse_wwn(const char *name, u64 *wwn, int strict)
                        return cp - name;
                }
                err = 3;
-               if (isdigit(c))
-                       nibble = c - '0';
-               else if (isxdigit(c) && (islower(c) || !strict))
-                       nibble = tolower(c) - 'a' + 10;
-               else
+               val = hex_to_bin(c);
+               if (val < 0 || (strict && isupper(c)))
                        goto fail;
-               *wwn = (*wwn << 4) | nibble;
+               *wwn = (*wwn << 4) | val;
        }
        err = 4;
 fail: