mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git/
synced 2026-04-17 22:23:45 -04:00
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>
This commit is contained in:
committed by
Andrew Morton
parent
58c9b016e1
commit
890a3ee3ce
35
include/linux/hex.h
Normal file
35
include/linux/hex.h
Normal file
@@ -0,0 +1,35 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
#ifndef _LINUX_HEX_H
|
||||
#define _LINUX_HEX_H
|
||||
|
||||
#include <linux/types.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;
|
||||
}
|
||||
|
||||
extern int hex_to_bin(unsigned char ch);
|
||||
extern int __must_check hex2bin(u8 *dst, const char *src, size_t count);
|
||||
extern char *bin2hex(char *dst, const void *src, size_t count);
|
||||
|
||||
bool mac_pton(const char *s, u8 *mac);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user