net: can: remove custom hex_to_bin()
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Sun, 17 Jul 2011 22:26:37 +0000 (22:26 +0000)
committerDavid S. Miller <davem@davemloft.net>
Mon, 18 Jul 2011 18:31:43 +0000 (11:31 -0700)
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Wolfgang Grandegger <wg@grandegger.com>
Acked-by: Oliver Hartkopp <socketcan@hartkopp.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/can/slcan.c

index aa8ad73477ba3fa229f475c45115ad9f62c7100d..65e54fd0a8d74f875a3ab7f7cb6d792f14709850 100644 (file)
@@ -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;