summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: b22456c)
raw | patch | inline | side by side (parent: b22456c)
author | Hauke Mehrtens <hauke@hauke-m.de> | |
Wed, 31 Aug 2011 22:20:12 +0000 (00:20 +0200) | ||
committer | Luis R. Rodriguez <mcgrof@qca.qualcomm.com> | |
Wed, 31 Aug 2011 22:22:55 +0000 (15:22 -0700) |
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
compat/compat-3.0.c | patch | blob | history | |
include/linux/compat-3.0.h | patch | blob | history |
diff --git a/compat/compat-3.0.c b/compat/compat-3.0.c
index 312eea004a5e73ac5e70661c26722bc1006897f2..f517e9fbeec5858aa941f7dc4d3ee7acf4ddba8c 100644 (file)
--- a/compat/compat-3.0.c
+++ b/compat/compat-3.0.c
return 1;
}
EXPORT_SYMBOL(mac_pton);
+
+#define kstrto_from_user(f, g, type) \
+int f(const char __user *s, size_t count, unsigned int base, type *res) \
+{ \
+ /* sign, base 2 representation, newline, terminator */ \
+ char buf[1 + sizeof(type) * 8 + 1 + 1]; \
+ \
+ count = min(count, sizeof(buf) - 1); \
+ if (copy_from_user(buf, s, count)) \
+ return -EFAULT; \
+ buf[count] = '\0'; \
+ return g(buf, base, res); \
+} \
+EXPORT_SYMBOL(f)
+
+kstrto_from_user(kstrtoull_from_user, kstrtoull, unsigned long long);
+kstrto_from_user(kstrtoll_from_user, kstrtoll, long long);
+kstrto_from_user(kstrtoul_from_user, kstrtoul, unsigned long);
+kstrto_from_user(kstrtol_from_user, kstrtol, long);
+kstrto_from_user(kstrtouint_from_user, kstrtouint, unsigned int);
+kstrto_from_user(kstrtoint_from_user, kstrtoint, int);
+kstrto_from_user(kstrtou16_from_user, kstrtou16, u16);
+kstrto_from_user(kstrtos16_from_user, kstrtos16, s16);
+kstrto_from_user(kstrtou8_from_user, kstrtou8, u8);
+kstrto_from_user(kstrtos8_from_user, kstrtos8, s8);
index 7954ddb12d9ed66e6a22cd409863f008813b2dce..8c8720e0a5fc99e6ff9e7b107953d8d9985a00b4 100644 (file)
int mac_pton(const char *s, u8 *mac);
+int __must_check kstrtoull_from_user(const char __user *s, size_t count, unsigned int base, unsigned long long *res);
+int __must_check kstrtoll_from_user(const char __user *s, size_t count, unsigned int base, long long *res);
+int __must_check kstrtoul_from_user(const char __user *s, size_t count, unsigned int base, unsigned long *res);
+int __must_check kstrtol_from_user(const char __user *s, size_t count, unsigned int base, long *res);
+int __must_check kstrtouint_from_user(const char __user *s, size_t count, unsigned int base, unsigned int *res);
+int __must_check kstrtoint_from_user(const char __user *s, size_t count, unsigned int base, int *res);
+int __must_check kstrtou16_from_user(const char __user *s, size_t count, unsigned int base, u16 *res);
+int __must_check kstrtos16_from_user(const char __user *s, size_t count, unsigned int base, s16 *res);
+int __must_check kstrtou8_from_user(const char __user *s, size_t count, unsigned int base, u8 *res);
+int __must_check kstrtos8_from_user(const char __user *s, size_t count, unsigned int base, s8 *res);
+
+static inline int __must_check kstrtou64_from_user(const char __user *s, size_t count, unsigned int base, u64 *res)
+{
+ return kstrtoull_from_user(s, count, base, res);
+}
+
+static inline int __must_check kstrtos64_from_user(const char __user *s, size_t count, unsigned int base, s64 *res)
+{
+ return kstrtoll_from_user(s, count, base, res);
+}
+
+static inline int __must_check kstrtou32_from_user(const char __user *s, size_t count, unsigned int base, u32 *res)
+{
+ return kstrtouint_from_user(s, count, base, res);
+}
+
+static inline int __must_check kstrtos32_from_user(const char __user *s, size_t count, unsigned int base, s32 *res)
+{
+ return kstrtoint_from_user(s, count, base, res);
+}
+
#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,0,0)) */
#endif /* LINUX_3_0_COMPAT_H */