From: Andy Shevchenko Date: Mon, 24 May 2010 21:33:27 +0000 (-0700) Subject: fs: ldm: don't use own implementation of hex_to_bin() X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=91f06e66805dd94825885b3ec392c693fe9ef4d9;p=openwrt%2Fstaging%2Fblogic.git fs: ldm: don't use own implementation of hex_to_bin() Remove own implementation of hex_to_bin(). Signed-off-by: Andy Shevchenko Cc: "Richard Russon (FlatCap)" Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/fs/partitions/ldm.c b/fs/partitions/ldm.c index 3ceca05b668c..648c9d8f3357 100644 --- a/fs/partitions/ldm.c +++ b/fs/partitions/ldm.c @@ -26,6 +26,7 @@ #include #include #include +#include #include "ldm.h" #include "check.h" #include "msdos.h" @@ -77,17 +78,16 @@ static int ldm_parse_hexbyte (const u8 *src) int h; /* high part */ - if ((x = src[0] - '0') <= '9'-'0') h = x; - else if ((x = src[0] - 'a') <= 'f'-'a') h = x+10; - else if ((x = src[0] - 'A') <= 'F'-'A') h = x+10; - else return -1; - h <<= 4; + x = h = hex_to_bin(src[0]); + if (h < 0) + return -1; /* low part */ - if ((x = src[1] - '0') <= '9'-'0') return h | x; - if ((x = src[1] - 'a') <= 'f'-'a') return h | (x+10); - if ((x = src[1] - 'A') <= 'F'-'A') return h | (x+10); - return -1; + h = hex_to_bin(src[1]); + if (h < 0) + return -1; + + return (x << 4) + h; } /**