diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2014-07-04 09:14:07 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2014-07-11 08:15:47 +0200 |
commit | 36d3cc49fb556cfbb15d7cf65569b14796f20246 (patch) | |
tree | 3e9ebe656269cc06d569b9232a15c7bd20741d52 /include/linux | |
parent | 241c6a017b65a88b1c23c701b32618e3ff5e8e07 (diff) | |
download | barebox-36d3cc49fb556cfbb15d7cf65569b14796f20246.tar.gz barebox-36d3cc49fb556cfbb15d7cf65569b14796f20246.tar.xz |
Add hex_byte_pack and hex_byte_pack_upper from kernel
Utility functions needed by the UUID/GUID printf support.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/kernel.h | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/include/linux/kernel.h b/include/linux/kernel.h index 4322f01580..c5ba99fe0a 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -117,5 +117,26 @@ } \ ) -#endif /* _LINUX_KERNEL_H */ +extern const char hex_asc[]; +#define hex_asc_lo(x) hex_asc[((x) & 0x0f)] +#define hex_asc_hi(x) hex_asc[((x) & 0xf0) >> 4] + +static inline char *hex_byte_pack(char *buf, u8 byte) +{ + *buf++ = hex_asc_hi(byte); + *buf++ = hex_asc_lo(byte); + return buf; +} + +extern const char hex_asc_upper[]; +#define hex_asc_upper_lo(x) hex_asc_upper[((x) & 0x0f)] +#define hex_asc_upper_hi(x) hex_asc_upper[((x) & 0xf0) >> 4] +static inline char *hex_byte_pack_upper(char *buf, u8 byte) +{ + *buf++ = hex_asc_upper_hi(byte); + *buf++ = hex_asc_upper_lo(byte); + return buf; +} + +#endif /* _LINUX_KERNEL_H */ |