From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Wolfgang Grandegger <wg@grandegger.com>
Subject: [PATCH] net: can: remove custom hex_to_bin()
Date: Mon, 18 Jul 2011 11:26:37 +0300 [thread overview]
Message-ID: <1310977597-9666-1-git-send-email-andriy.shevchenko@linux.intel.com> (raw)
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Wolfgang Grandegger <wg@grandegger.com>
---
drivers/net/can/slcan.c | 26 +++++---------------------
1 files changed, 5 insertions(+), 21 deletions(-)
diff --git a/drivers/net/can/slcan.c b/drivers/net/can/slcan.c
index aa8ad73..65e54fd 100644
--- a/drivers/net/can/slcan.c
+++ b/drivers/net/can/slcan.c
@@ -56,6 +56,7 @@
#include <linux/sched.h>
#include <linux/delay.h>
#include <linux/init.h>
+#include <linux/kernel.h>
#include <linux/can.h>
static __initdata const char banner[] =
@@ -142,21 +143,6 @@ static struct net_device **slcan_devs;
* STANDARD SLCAN DECAPSULATION *
************************************************************************/
-static int asc2nibble(char c)
-{
-
- if ((c >= '0') && (c <= '9'))
- return c - '0';
-
- if ((c >= 'A') && (c <= 'F'))
- return c - 'A' + 10;
-
- if ((c >= 'a') && (c <= 'f'))
- return c - 'a' + 10;
-
- return 16; /* error */
-}
-
/* Send one completely decapsulated can_frame to the network layer */
static void slc_bump(struct slcan *sl)
{
@@ -195,18 +181,16 @@ static void slc_bump(struct slcan *sl)
*(u64 *) (&cf.data) = 0; /* clear payload */
for (i = 0, dlc_pos++; i < cf.can_dlc; i++) {
-
- tmp = asc2nibble(sl->rbuff[dlc_pos++]);
- if (tmp > 0x0F)
+ tmp = hex_to_bin(sl->rbuff[dlc_pos++]);
+ if (tmp < 0)
return;
cf.data[i] = (tmp << 4);
- tmp = asc2nibble(sl->rbuff[dlc_pos++]);
- if (tmp > 0x0F)
+ tmp = hex_to_bin(sl->rbuff[dlc_pos++]);
+ if (tmp < 0)
return;
cf.data[i] |= tmp;
}
-
skb = dev_alloc_skb(sizeof(struct can_frame));
if (!skb)
return;
--
1.7.5.4
next reply other threads:[~2011-07-18 8:27 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-18 8:26 Andy Shevchenko [this message]
2011-07-18 11:41 ` [PATCH] net: can: remove custom hex_to_bin() Tetsuo Handa
2011-07-18 12:23 ` Andy Shevchenko
2011-07-18 12:48 ` [PATCH] Add error check to hex2bin() Tetsuo Handa
2011-07-18 18:03 ` Mimi Zohar
2011-07-18 18:57 ` Andy Shevchenko
2011-07-18 19:20 ` Mimi Zohar
2011-07-18 19:44 ` Andy Shevchenko
2011-07-18 19:44 ` Andy Shevchenko
2011-07-18 21:43 ` Mimi Zohar
2011-07-18 20:49 ` Geert Uytterhoeven
2011-07-18 20:49 ` Geert Uytterhoeven
2011-07-18 21:18 ` Andy Shevchenko
2011-07-18 21:59 ` Mimi Zohar
2011-07-19 1:00 ` Mimi Zohar
2011-07-19 10:52 ` Mimi Zohar
2011-07-18 14:02 ` [PATCH] net: can: remove custom hex_to_bin() Oliver Hartkopp
2011-07-18 18:33 ` David Miller
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=1310977597-9666-1-git-send-email-andriy.shevchenko@linux.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=wg@grandegger.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.