mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] platform: x86: throw away custom methods
@ 2010-09-11 13:31 Andy Shevchenko
  2010-09-11 14:03 ` Carlos Corbacho
  0 siblings, 1 reply; 2+ messages in thread
From: Andy Shevchenko @ 2010-09-11 13:31 UTC (permalink / raw)
  To: linux-kernel
  Cc: Andy Shevchenko, Carlos Corbacho, Matthew Garrett, platform-driver-x86

In 2.6.35 the hex_to_bin() was introduced.

Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Carlos Corbacho <carlos@strangeworlds.co.uk>
Cc: Matthew Garrett <mjg@redhat.com>
Cc: platform-driver-x86@vger.kernel.org
---
 drivers/platform/x86/wmi.c |   24 ++++++------------------
 1 files changed, 6 insertions(+), 18 deletions(-)

diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c
index b2978a0..4980682 100644
--- a/drivers/platform/x86/wmi.c
+++ b/drivers/platform/x86/wmi.c
@@ -128,30 +128,18 @@ static struct acpi_driver acpi_wmi_driver = {
  */
 static int wmi_parse_hexbyte(const u8 *src)
 {
-	unsigned int x; /* For correct wrapping */
 	int h;
+	int value;
 
 	/* high part */
-	x = src[0];
-	if (x - '0' <= '9' - '0') {
-		h = x - '0';
-	} else if (x - 'a' <= 'f' - 'a') {
-		h = x - 'a' + 10;
-	} else if (x - 'A' <= 'F' - 'A') {
-		h = x - 'A' + 10;
-	} else {
+	h = value = hex_to_bin(src[0]);
+	if (value < 0)
 		return -1;
-	}
-	h <<= 4;
 
 	/* low part */
-	x = src[1];
-	if (x - '0' <= '9' - '0')
-		return h | (x - '0');
-	if (x - 'a' <= 'f' - 'a')
-		return h | (x - 'a' + 10);
-	if (x - 'A' <= 'F' - 'A')
-		return h | (x - 'A' + 10);
+	value = hex_to_bin(src[1]);
+	if (value >= 0)
+		return (h << 4) | value;
 	return -1;
 }
 
-- 
1.7.2.2


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] platform: x86: throw away custom methods
  2010-09-11 13:31 [PATCH] platform: x86: throw away custom methods Andy Shevchenko
@ 2010-09-11 14:03 ` Carlos Corbacho
  0 siblings, 0 replies; 2+ messages in thread
From: Carlos Corbacho @ 2010-09-11 14:03 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: linux-kernel, Matthew Garrett, platform-driver-x86

On Saturday 11 September 2010 14:31:02 Andy Shevchenko wrote:
> In 2.6.35 the hex_to_bin() was introduced.
> 
> Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>

Acked-by: Carlos Corbacho <carlos@strangeworlds.co.uk>

> Cc: Matthew Garrett <mjg@redhat.com>
> Cc: platform-driver-x86@vger.kernel.org

-- 
E-Mail: carlos@strangeworlds.co.uk
Web: strangeworlds.co.uk
GPG Key ID: 0x23EE722D

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-09-11 14:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-11 13:31 [PATCH] platform: x86: throw away custom methods Andy Shevchenko
2010-09-11 14:03 ` Carlos Corbacho

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®