diff options
author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2011-07-17 18:26:37 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-07-18 14:31:43 -0400 |
commit | 81fc70d86527a1450560709500ca5f52e661da1f (patch) | |
tree | 81533323709564030b859af95191a2c64bfac4f8 /drivers/net/can/slcan.c | |
parent | 61b8013a114cb041db2c56f747953cac69637f26 (diff) |
net: can: remove custom hex_to_bin()
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>
Diffstat (limited to 'drivers/net/can/slcan.c')
-rw-r--r-- | 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 aa8ad73477ba..65e54fd0a8d7 100644 --- a/drivers/net/can/slcan.c +++ b/drivers/net/can/slcan.c | |||
@@ -56,6 +56,7 @@ | |||
56 | #include <linux/sched.h> | 56 | #include <linux/sched.h> |
57 | #include <linux/delay.h> | 57 | #include <linux/delay.h> |
58 | #include <linux/init.h> | 58 | #include <linux/init.h> |
59 | #include <linux/kernel.h> | ||
59 | #include <linux/can.h> | 60 | #include <linux/can.h> |
60 | 61 | ||
61 | static __initdata const char banner[] = | 62 | static __initdata const char banner[] = |
@@ -142,21 +143,6 @@ static struct net_device **slcan_devs; | |||
142 | * STANDARD SLCAN DECAPSULATION * | 143 | * STANDARD SLCAN DECAPSULATION * |
143 | ************************************************************************/ | 144 | ************************************************************************/ |
144 | 145 | ||
145 | static int asc2nibble(char c) | ||
146 | { | ||
147 | |||
148 | if ((c >= '0') && (c <= '9')) | ||
149 | return c - '0'; | ||
150 | |||
151 | if ((c >= 'A') && (c <= 'F')) | ||
152 | return c - 'A' + 10; | ||
153 | |||
154 | if ((c >= 'a') && (c <= 'f')) | ||
155 | return c - 'a' + 10; | ||
156 | |||
157 | return 16; /* error */ | ||
158 | } | ||
159 | |||
160 | /* Send one completely decapsulated can_frame to the network layer */ | 146 | /* Send one completely decapsulated can_frame to the network layer */ |
161 | static void slc_bump(struct slcan *sl) | 147 | static void slc_bump(struct slcan *sl) |
162 | { | 148 | { |
@@ -195,18 +181,16 @@ static void slc_bump(struct slcan *sl) | |||
195 | *(u64 *) (&cf.data) = 0; /* clear payload */ | 181 | *(u64 *) (&cf.data) = 0; /* clear payload */ |
196 | 182 | ||
197 | for (i = 0, dlc_pos++; i < cf.can_dlc; i++) { | 183 | for (i = 0, dlc_pos++; i < cf.can_dlc; i++) { |
198 | 184 | tmp = hex_to_bin(sl->rbuff[dlc_pos++]); | |
199 | tmp = asc2nibble(sl->rbuff[dlc_pos++]); | 185 | if (tmp < 0) |
200 | if (tmp > 0x0F) | ||
201 | return; | 186 | return; |
202 | cf.data[i] = (tmp << 4); | 187 | cf.data[i] = (tmp << 4); |
203 | tmp = asc2nibble(sl->rbuff[dlc_pos++]); | 188 | tmp = hex_to_bin(sl->rbuff[dlc_pos++]); |
204 | if (tmp > 0x0F) | 189 | if (tmp < 0) |
205 | return; | 190 | return; |
206 | cf.data[i] |= tmp; | 191 | cf.data[i] |= tmp; |
207 | } | 192 | } |
208 | 193 | ||
209 | |||
210 | skb = dev_alloc_skb(sizeof(struct can_frame)); | 194 | skb = dev_alloc_skb(sizeof(struct can_frame)); |
211 | if (!skb) | 195 | if (!skb) |
212 | return; | 196 | return; |