net: core: don't use own hex_to_bin() method
authorAndy Shevchenko <andy.shevchenko@gmail.com>
Fri, 23 Jul 2010 03:18:10 +0000 (03:18 +0000)
committerDavid S. Miller <davem@davemloft.net>
Fri, 23 Jul 2010 19:50:51 +0000 (12:50 -0700)
Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/pktgen.c

index 24a19de..10a1ea7 100644 (file)
@@ -1434,18 +1434,12 @@ static ssize_t pktgen_if_write(struct file *file,
                i += len;
 
                for (*m = 0; *v && m < pkt_dev->dst_mac + 6; v++) {
-                       if (*v >= '0' && *v <= '9') {
-                               *m *= 16;
-                               *m += *v - '0';
-                       }
-                       if (*v >= 'A' && *v <= 'F') {
-                               *m *= 16;
-                               *m += *v - 'A' + 10;
-                       }
-                       if (*v >= 'a' && *v <= 'f') {
-                               *m *= 16;
-                               *m += *v - 'a' + 10;
-                       }
+                       int value;
+
+                       value = hex_to_bin(*v);
+                       if (value >= 0)
+                               *m = *m * 16 + value;
+
                        if (*v == ':') {
                                m++;
                                *m = 0;
@@ -1476,18 +1470,12 @@ static ssize_t pktgen_if_write(struct file *file,
                i += len;
 
                for (*m = 0; *v && m < pkt_dev->src_mac + 6; v++) {
-                       if (*v >= '0' && *v <= '9') {
-                               *m *= 16;
-                               *m += *v - '0';
-                       }
-                       if (*v >= 'A' && *v <= 'F') {
-                               *m *= 16;
-                               *m += *v - 'A' + 10;
-                       }
-                       if (*v >= 'a' && *v <= 'f') {
-                               *m *= 16;
-                               *m += *v - 'a' + 10;
-                       }
+                       int value;
+
+                       value = hex_to_bin(*v);
+                       if (value >= 0)
+                               *m = *m * 16 + value;
+
                        if (*v == ':') {
                                m++;
                                *m = 0;