lib: hex2bin converts ascii hexadecimal string to binary
[linux-2.6-block.git] / lib / hexdump.c
index 5d7a4802c5623c00056159735bf73d17165ba476..b66b2bd67952ea5ac3aaa2f3805a5a1b08f4c85e 100644 (file)
@@ -33,6 +33,22 @@ int hex_to_bin(char ch)
 }
 EXPORT_SYMBOL(hex_to_bin);
 
+/**
+ * hex2bin - convert an ascii hexadecimal string to its binary representation
+ * @dst: binary result
+ * @src: ascii hexadecimal string
+ * @count: result length
+ */
+void hex2bin(u8 *dst, const char *src, size_t count)
+{
+       while (count--) {
+               *dst = hex_to_bin(*src++) << 4;
+               *dst += hex_to_bin(*src++);
+               dst++;
+       }
+}
+EXPORT_SYMBOL(hex2bin);
+
 /**
  * hex_dump_to_buffer - convert a blob of data to "hex ASCII" in memory
  * @buf: data blob to dump