linuxkpi: Add kstrtouint_from_user

Like kstrtoint_from_user but for uint.
Needed by drm v5.10

MFC after:	1 month
Reviewed by:	hselasky
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D34642
This commit is contained in:
Emmanuel Vadot 2022-03-22 10:22:42 +01:00
parent 9b8016548e
commit 8e587a5f13

View File

@ -524,6 +524,21 @@ kstrtoint_from_user(const char __user *s, size_t count, unsigned int base,
return (kstrtoint(buf, base, p));
}
static inline int
kstrtouint_from_user(const char __user *s, size_t count, unsigned int base,
int *p)
{
char buf[36] = {};
if (count > (sizeof(buf) - 1))
count = (sizeof(buf) - 1);
if (copy_from_user(buf, s, count))
return (-EFAULT);
return (kstrtouint(buf, base, p));
}
static inline int
kstrtou8_from_user(const char __user *s, size_t count, unsigned int base,
u8 *p)