Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F167662755
D56391.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D56391.diff
View Options
diff --git a/sys/compat/linuxkpi/common/include/linux/hex.h b/sys/compat/linuxkpi/common/include/linux/hex.h
new file mode 100644
--- /dev/null
+++ b/sys/compat/linuxkpi/common/include/linux/hex.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2022-2026 Bjoern A. Zeeb
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#ifndef _LINUXKPI_LINUX_HEX_H_
+#define _LINUXKPI_LINUX_HEX_H_
+
+#include <linux/types.h>
+#include <linux/errno.h>
+
+static inline int
+_h2b(const char c)
+{
+
+ if (c >= '0' && c <= '9')
+ return (c - '0');
+ if (c >= 'a' && c <= 'f')
+ return (10 + c - 'a');
+ if (c >= 'A' && c <= 'F')
+ return (10 + c - 'A');
+ return (-EINVAL);
+}
+
+static inline int
+hex2bin(uint8_t *bindst, const char *hexsrc, size_t binlen)
+{
+ int hi4, lo4;
+
+ while (binlen > 0) {
+ hi4 = _h2b(*hexsrc++);
+ lo4 = _h2b(*hexsrc++);
+ if (hi4 < 0 || lo4 < 0)
+ return (-EINVAL);
+
+ *bindst++ = (hi4 << 4) | lo4;
+ binlen--;
+ }
+
+ return (0);
+}
+
+#endif /* _LINUXKPI_LINUX_HEX_H_ */
diff --git a/sys/compat/linuxkpi/common/include/linux/kernel.h b/sys/compat/linuxkpi/common/include/linux/kernel.h
--- a/sys/compat/linuxkpi/common/include/linux/kernel.h
+++ b/sys/compat/linuxkpi/common/include/linux/kernel.h
@@ -56,6 +56,7 @@
#include <linux/log2.h>
#include <linux/kconfig.h>
#include <linux/instruction_pointer.h>
+#include <linux/hex.h>
#include <asm/byteorder.h>
#include <asm/cpufeature.h>
@@ -305,37 +306,6 @@
#define add_taint(x,y) do { \
} while (0)
-static inline int
-_h2b(const char c)
-{
-
- if (c >= '0' && c <= '9')
- return (c - '0');
- if (c >= 'a' && c <= 'f')
- return (10 + c - 'a');
- if (c >= 'A' && c <= 'F')
- return (10 + c - 'A');
- return (-EINVAL);
-}
-
-static inline int
-hex2bin(uint8_t *bindst, const char *hexsrc, size_t binlen)
-{
- int hi4, lo4;
-
- while (binlen > 0) {
- hi4 = _h2b(*hexsrc++);
- lo4 = _h2b(*hexsrc++);
- if (hi4 < 0 || lo4 < 0)
- return (-EINVAL);
-
- *bindst++ = (hi4 << 4) | lo4;
- binlen--;
- }
-
- return (0);
-}
-
static inline bool
mac_pton(const char *macin, uint8_t *macout)
{
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Aug 24, 3:30 PM (3 h, 22 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
37172405
Default Alt Text
D56391.diff (2 KB)
Attached To
Mode
D56391: LinuxKPI: move hex2bin() from kernel.h to new hex.h
Attached
Detach File
Event Timeline
Log In to Comment