* [PATCH v1 1/1] kernel.h: Split the hexadecimal related helpers to hex.h
@ 2022-09-14 17:08 Andy Shevchenko
2022-09-14 19:52 ` Joe Perches
0 siblings, 1 reply; 3+ messages in thread
From: Andy Shevchenko @ 2022-09-14 17:08 UTC (permalink / raw)
To: Andy Shevchenko, linux-kernel; +Cc: Andrew Morton
For the sake of cleaning up the kernel.h split the hexadecimal
relted helpers to own header called 'hex.h'.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
include/linux/hex.h | 35 +++++++++++++++++++++++++++++++++++
include/linux/kernel.h | 29 +----------------------------
2 files changed, 36 insertions(+), 28 deletions(-)
create mode 100644 include/linux/hex.h
diff --git a/include/linux/hex.h b/include/linux/hex.h
new file mode 100644
index 000000000000..2618382e5b0c
--- /dev/null
+++ b/include/linux/hex.h
@@ -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
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index bc3e0364970a..7a495e94b087 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -20,6 +20,7 @@
#include <linux/compiler.h>
#include <linux/container_of.h>
#include <linux/bitops.h>
+#include <linux/hex.h>
#include <linux/kstrtox.h>
#include <linux/log2.h>
#include <linux/math.h>
@@ -259,34 +260,6 @@ extern enum system_states {
SYSTEM_SUSPEND,
} system_state;
-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);
-
/*
* General tracing related utility functions - trace_printk(),
* tracing_on/tracing_off and tracing_start()/tracing_stop
--
2.35.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v1 1/1] kernel.h: Split the hexadecimal related helpers to hex.h
2022-09-14 17:08 [PATCH v1 1/1] kernel.h: Split the hexadecimal related helpers to hex.h Andy Shevchenko
@ 2022-09-14 19:52 ` Joe Perches
0 siblings, 0 replies; 3+ messages in thread
From: Joe Perches @ 2022-09-14 19:52 UTC (permalink / raw)
To: Andy Shevchenko, linux-kernel; +Cc: Andrew Morton
On Wed, 2022-09-14 at 20:08 +0300, Andy Shevchenko wrote:
> For the sake of cleaning up the kernel.h split the hexadecimal
> relted helpers to own header called 'hex.h'.
related
> diff --git a/include/linux/hex.h b/include/linux/hex.h
[]
> +bool mac_pton(const char *s, u8 *mac);
This one should likely stay in kernel.h unless and until
a more suitable place is found for it.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v1 1/1] kernel.h: Split the hexadecimal related helpers to hex.h
@ 2023-03-23 15:50 Andy Shevchenko
0 siblings, 0 replies; 3+ messages in thread
From: Andy Shevchenko @ 2023-03-23 15:50 UTC (permalink / raw)
To: Andy Shevchenko, linux-kernel; +Cc: Rasmus Villemoes, Andrew Morton
For the sake of cleaning up the kernel.h split the hexadecimal
related helpers to own header called 'hex.h'.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
include/linux/hex.h | 35 +++++++++++++++++++++++++++++++++++
include/linux/kernel.h | 29 +----------------------------
2 files changed, 36 insertions(+), 28 deletions(-)
create mode 100644 include/linux/hex.h
diff --git a/include/linux/hex.h b/include/linux/hex.h
new file mode 100644
index 000000000000..2618382e5b0c
--- /dev/null
+++ b/include/linux/hex.h
@@ -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
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 40bce7495af8..0d91e0af0125 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -20,6 +20,7 @@
#include <linux/compiler.h>
#include <linux/container_of.h>
#include <linux/bitops.h>
+#include <linux/hex.h>
#include <linux/kstrtox.h>
#include <linux/log2.h>
#include <linux/math.h>
@@ -263,34 +264,6 @@ extern enum system_states {
SYSTEM_SUSPEND,
} system_state;
-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);
-
/*
* General tracing related utility functions - trace_printk(),
* tracing_on/tracing_off and tracing_start()/tracing_stop
--
2.40.0.1.gaa8946217a0b
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-03-23 15:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-14 17:08 [PATCH v1 1/1] kernel.h: Split the hexadecimal related helpers to hex.h Andy Shevchenko
2022-09-14 19:52 ` Joe Perches
-- strict thread matches above, loose matches on Subject: below --
2023-03-23 15:50 Andy Shevchenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox