Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

kernel.h: split the hexadecimal related helpers to hex.h

For the sake of cleaning up the kernel.h split the hexadecimal related
helpers to own header called 'hex.h'.

Link: https://lkml.kernel.org/r/20230323155029.40000-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Andy Shevchenko and committed by
Andrew Morton
890a3ee3 58c9b016

+36 -28
+35
include/linux/hex.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + #ifndef _LINUX_HEX_H 3 + #define _LINUX_HEX_H 4 + 5 + #include <linux/types.h> 6 + 7 + extern const char hex_asc[]; 8 + #define hex_asc_lo(x) hex_asc[((x) & 0x0f)] 9 + #define hex_asc_hi(x) hex_asc[((x) & 0xf0) >> 4] 10 + 11 + static inline char *hex_byte_pack(char *buf, u8 byte) 12 + { 13 + *buf++ = hex_asc_hi(byte); 14 + *buf++ = hex_asc_lo(byte); 15 + return buf; 16 + } 17 + 18 + extern const char hex_asc_upper[]; 19 + #define hex_asc_upper_lo(x) hex_asc_upper[((x) & 0x0f)] 20 + #define hex_asc_upper_hi(x) hex_asc_upper[((x) & 0xf0) >> 4] 21 + 22 + static inline char *hex_byte_pack_upper(char *buf, u8 byte) 23 + { 24 + *buf++ = hex_asc_upper_hi(byte); 25 + *buf++ = hex_asc_upper_lo(byte); 26 + return buf; 27 + } 28 + 29 + extern int hex_to_bin(unsigned char ch); 30 + extern int __must_check hex2bin(u8 *dst, const char *src, size_t count); 31 + extern char *bin2hex(char *dst, const void *src, size_t count); 32 + 33 + bool mac_pton(const char *s, u8 *mac); 34 + 35 + #endif
+1 -28
include/linux/kernel.h
··· 20 20 #include <linux/compiler.h> 21 21 #include <linux/container_of.h> 22 22 #include <linux/bitops.h> 23 + #include <linux/hex.h> 23 24 #include <linux/kstrtox.h> 24 25 #include <linux/log2.h> 25 26 #include <linux/math.h> ··· 263 262 SYSTEM_RESTART, 264 263 SYSTEM_SUSPEND, 265 264 } system_state; 266 - 267 - extern const char hex_asc[]; 268 - #define hex_asc_lo(x) hex_asc[((x) & 0x0f)] 269 - #define hex_asc_hi(x) hex_asc[((x) & 0xf0) >> 4] 270 - 271 - static inline char *hex_byte_pack(char *buf, u8 byte) 272 - { 273 - *buf++ = hex_asc_hi(byte); 274 - *buf++ = hex_asc_lo(byte); 275 - return buf; 276 - } 277 - 278 - extern const char hex_asc_upper[]; 279 - #define hex_asc_upper_lo(x) hex_asc_upper[((x) & 0x0f)] 280 - #define hex_asc_upper_hi(x) hex_asc_upper[((x) & 0xf0) >> 4] 281 - 282 - static inline char *hex_byte_pack_upper(char *buf, u8 byte) 283 - { 284 - *buf++ = hex_asc_upper_hi(byte); 285 - *buf++ = hex_asc_upper_lo(byte); 286 - return buf; 287 - } 288 - 289 - extern int hex_to_bin(unsigned char ch); 290 - extern int __must_check hex2bin(u8 *dst, const char *src, size_t count); 291 - extern char *bin2hex(char *dst, const void *src, size_t count); 292 - 293 - bool mac_pton(const char *s, u8 *mac); 294 265 295 266 /* 296 267 * General tracing related utility functions - trace_printk(),