backports: add bin2hex()
authorJohannes Berg <johannes.berg@intel.com>
Thu, 12 Oct 2017 20:53:09 +0000 (22:53 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Fri, 13 Oct 2017 08:57:59 +0000 (10:57 +0200)
This is needed in the key backports in the next patch.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
backport/backport-include/linux/kernel.h
backport/compat/backport-3.18.c

index 0e9a69f9bcd27af8b58f472726973268fbb5211c..3ddeb13c29a2fcfa3be8ecf508e1701a14c61122 100644 (file)
@@ -213,6 +213,11 @@ static inline u32 reciprocal_scale(u32 val, u32 ep_ro)
 }
 #endif /* LINUX_VERSION_IS_LESS(3,14,0) */
 
+#if LINUX_VERSION_IS_LESS(3,18,0)
+#define bin2hex LINUX_BACKPORT(bin2hex)
+extern char *bin2hex(char *dst, const void *src, size_t count);
+#endif
+
 #endif /* __BACKPORT_KERNEL_H */
 
 /*
index 73db233cb22b06fa8c98186f4159993f74140a1d..d2eceef7dc77732d74bdecd5c0106c411ab834eb 100644 (file)
@@ -320,3 +320,13 @@ void memzero_explicit(void *s, size_t count)
 }
 EXPORT_SYMBOL_GPL(memzero_explicit);
 #endif
+
+char *bin2hex(char *dst, const void *src, size_t count)
+{
+       const unsigned char *_src = src;
+
+       while (count--)
+               dst = hex_byte_pack(dst, *_src++);
+       return dst;
+}
+EXPORT_SYMBOL(bin2hex);