From: Andy Shevchenko Date: Fri, 30 Sep 2011 11:45:40 +0000 (+0300) Subject: tcm_fc: remove custom hex_to_bin in ft_parse_wwn X-Git-Tag: accepted/tizen/common/20141203.182822~5931^2~59 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=635a2b3f3e561278cb5b837ea305e50e3fa7f063;p=platform%2Fkernel%2Flinux-arm64.git 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 Cc: "Nicholas A. Bellinger" Signed-off-by: Nicholas Bellinger --- diff --git a/drivers/target/tcm_fc/tfc_conf.c b/drivers/target/tcm_fc/tfc_conf.c index b30eace..5f77041 100644 --- a/drivers/target/tcm_fc/tfc_conf.c +++ b/drivers/target/tcm_fc/tfc_conf.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -70,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++) { @@ -94,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: