mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andy Shevchenko <ext-andriy.shevchenko@nokia.com>
To: linux-kernel@vger.kernel.org
Cc: Andy Shevchenko <ext-andriy.shevchenko@nokia.com>,
	"Richard Russon (FlatCap)" <ldm@flatcap.org>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: [PATCH 08/10] fs: ldm: don't use own implementation of hex_to_bin()
Date: Fri, 30 Apr 2010 12:34:07 +0300	[thread overview]
Message-ID: <ce5ee38b2d01568cd56ffc9598d7ceaa24738e65.1272617852.git.ext-andriy.shevchenko@nokia.com> (raw)
In-Reply-To: <d6886a8b94bf8726d7bde807b3ca19f65739ce4d.1272617852.git.ext-andriy.shevchenko@nokia.com>
In-Reply-To: <cover.1272617852.git.ext-andriy.shevchenko@nokia.com>

Get rid of own implementation of hex_to_bin().

Signed-off-by: Andy Shevchenko <ext-andriy.shevchenko@nokia.com>
Cc: "Richard Russon (FlatCap)" <ldm@flatcap.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
---
 fs/partitions/ldm.c |   18 +++++++++---------
 1 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/fs/partitions/ldm.c b/fs/partitions/ldm.c
index 8652fb9..cb445fb 100644
--- a/fs/partitions/ldm.c
+++ b/fs/partitions/ldm.c
@@ -26,6 +26,7 @@
 #include <linux/slab.h>
 #include <linux/pagemap.h>
 #include <linux/stringify.h>
+#include <linux/kernel.h>
 #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;
 }
 
 /**
-- 
1.6.3.3


  reply	other threads:[~2010-04-30 18:49 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-30  9:33 [PATCH 00/10] Introduce common hex_to_bin() helper Andy Shevchenko
2010-04-30  9:34 ` [PATCH 01/10] lib: introduce common method to convert hex digits Andy Shevchenko
2010-04-30  9:34   ` [PATCH 02/10] drivers: isdn: use new hex_to_bin() method Andy Shevchenko
2010-04-30  9:34     ` [PATCH 03/10] usb: atm: speedtch: " Andy Shevchenko
2010-04-30  9:34       ` [PATCH 04/10] drivers: net: " Andy Shevchenko
2010-04-30  9:34         ` [PATCH 05/10] " Andy Shevchenko
2010-04-30  9:34           ` [PATCH 06/10] sysctl: don't use own implementation of hex_to_bin() Andy Shevchenko
2010-04-30  9:34             ` [PATCH 07/10] staging: rt2860: use new hex_to_bin() method Andy Shevchenko
2010-04-30  9:34               ` Andy Shevchenko [this message]
2010-04-30  9:34                 ` [PATCH 09/10] drivers: wireless: " Andy Shevchenko
2010-04-30  9:34                   ` [PATCH 10/10] drivers: acpi: don't use own implementation of hex_to_bin() Andy Shevchenko
2010-04-30 18:14                   ` [PATCH 09/10] drivers: wireless: use new hex_to_bin() method John W. Linville
2010-05-04  0:14           ` [PATCH 05/10] drivers: net: " Divy Le Ray
2010-04-30 19:07   ` [PATCH 01/10] lib: introduce common method to convert hex digits Andrew Morton
2010-05-01  2:55     ` Joe Perches
2010-05-02 18:12     ` Andy Shevchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ce5ee38b2d01568cd56ffc9598d7ceaa24738e65.1272617852.git.ext-andriy.shevchenko@nokia.com \
    --to=ext-andriy.shevchenko@nokia.com \
    --cc=akpm@linux-foundation.org \
    --cc=ldm@flatcap.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®