aboutsummaryrefslogtreecommitdiff
path: root/sys/compat/linuxkpi/common/include/linux/kernel.h
diff options
context:
space:
mode:
authorEmmanuel Vadot <manu@FreeBSD.org>2020-05-27 11:42:09 +0000
committerEmmanuel Vadot <manu@FreeBSD.org>2020-05-27 11:42:09 +0000
commit8e52f22b25e205e3000c4f4aa673883851befeb7 (patch)
treef4c2f3bb24ea883a682796699bb055f3ff43c6b3 /sys/compat/linuxkpi/common/include/linux/kernel.h
parent9b703f30829b78eef43b51b217021357b51d390d (diff)
Notes
Diffstat (limited to 'sys/compat/linuxkpi/common/include/linux/kernel.h')
-rw-r--r--sys/compat/linuxkpi/common/include/linux/kernel.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/sys/compat/linuxkpi/common/include/linux/kernel.h b/sys/compat/linuxkpi/common/include/linux/kernel.h
index a7b2263cab7e..fcba880011ca 100644
--- a/sys/compat/linuxkpi/common/include/linux/kernel.h
+++ b/sys/compat/linuxkpi/common/include/linux/kernel.h
@@ -374,6 +374,24 @@ kstrtouint(const char *cp, unsigned int base, unsigned int *res)
}
static inline int
+kstrtou16(const char *cp, unsigned int base, u16 *res)
+{
+ char *end;
+ unsigned long temp;
+
+ *res = temp = strtoul(cp, &end, base);
+
+ /* skip newline character, if any */
+ if (*end == '\n')
+ end++;
+ if (*cp == 0 || *end != 0)
+ return (-EINVAL);
+ if (temp != (u16)temp)
+ return (-ERANGE);
+ return (0);
+}
+
+static inline int
kstrtou32(const char *cp, unsigned int base, u32 *res)
{
char *end;