Commit 81fc70d8 authored by Andy Shevchenko's avatar Andy Shevchenko Committed by David S. Miller

net: can: remove custom hex_to_bin()

Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Wolfgang Grandegger <wg@grandegger.com>
Acked-by: default avatarOliver Hartkopp <socketcan@hartkopp.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 61b8013a
...@@ -56,6 +56,7 @@ ...@@ -56,6 +56,7 @@
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/kernel.h>
#include <linux/can.h> #include <linux/can.h>
static __initdata const char banner[] = static __initdata const char banner[] =
...@@ -142,21 +143,6 @@ static struct net_device **slcan_devs; ...@@ -142,21 +143,6 @@ static struct net_device **slcan_devs;
* STANDARD SLCAN DECAPSULATION * * 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 */ /* Send one completely decapsulated can_frame to the network layer */
static void slc_bump(struct slcan *sl) static void slc_bump(struct slcan *sl)
{ {
...@@ -195,18 +181,16 @@ static void slc_bump(struct slcan *sl) ...@@ -195,18 +181,16 @@ static void slc_bump(struct slcan *sl)
*(u64 *) (&cf.data) = 0; /* clear payload */ *(u64 *) (&cf.data) = 0; /* clear payload */
for (i = 0, dlc_pos++; i < cf.can_dlc; i++) { for (i = 0, dlc_pos++; i < cf.can_dlc; i++) {
tmp = hex_to_bin(sl->rbuff[dlc_pos++]);
tmp = asc2nibble(sl->rbuff[dlc_pos++]); if (tmp < 0)
if (tmp > 0x0F)
return; return;
cf.data[i] = (tmp << 4); cf.data[i] = (tmp << 4);
tmp = asc2nibble(sl->rbuff[dlc_pos++]); tmp = hex_to_bin(sl->rbuff[dlc_pos++]);
if (tmp > 0x0F) if (tmp < 0)
return; return;
cf.data[i] |= tmp; cf.data[i] |= tmp;
} }
skb = dev_alloc_skb(sizeof(struct can_frame)); skb = dev_alloc_skb(sizeof(struct can_frame));
if (!skb) if (!skb)
return; return;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment