diff options
author | Johannes Berg <johannes.berg@intel.com> | 2013-04-12 11:58:10 +0200 |
---|---|---|
committer | Johannes Berg <johannes.berg@intel.com> | 2013-04-15 11:32:46 +0200 |
commit | 16b14026eda016fe0a6256d068705f6327a08a0d (patch) | |
tree | 020faee020a64d71986330e9bde1aa6610d64c84 /backport/backport-include/linux/kernel.h | |
parent | 1c4e559c0f7da7826f3b2bec50af8d089fdb42a3 (diff) |
backports: dissolve compat-2.6.39.h
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'backport/backport-include/linux/kernel.h')
-rw-r--r-- | backport/backport-include/linux/kernel.h | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/backport/backport-include/linux/kernel.h b/backport/backport-include/linux/kernel.h index 7d22b74f..c41ea1b3 100644 --- a/backport/backport-include/linux/kernel.h +++ b/backport/backport-include/linux/kernel.h @@ -92,4 +92,74 @@ static inline int __must_check kstrtos32_from_user(const char __user *s, size_t } #endif +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39) +/* + * kstrto* was included in kernel 2.6.38.4 and causes conflicts with the + * version included in compat-drivers. We use strict_strtol to check if + * kstrto* is already available. + */ +#ifndef strict_strtoull +/* Internal, do not use. */ +int __must_check _kstrtoul(const char *s, unsigned int base, unsigned long *res); +int __must_check _kstrtol(const char *s, unsigned int base, long *res); + +int __must_check kstrtoull(const char *s, unsigned int base, unsigned long long *res); +int __must_check kstrtoll(const char *s, unsigned int base, long long *res); +static inline int __must_check kstrtoul(const char *s, unsigned int base, unsigned long *res) +{ + /* + * We want to shortcut function call, but + * __builtin_types_compatible_p(unsigned long, unsigned long long) = 0. + */ + if (sizeof(unsigned long) == sizeof(unsigned long long) && + __alignof__(unsigned long) == __alignof__(unsigned long long)) + return kstrtoull(s, base, (unsigned long long *)res); + else + return _kstrtoul(s, base, res); +} + +static inline int __must_check kstrtol(const char *s, unsigned int base, long *res) +{ + /* + * We want to shortcut function call, but + * __builtin_types_compatible_p(long, long long) = 0. + */ + if (sizeof(long) == sizeof(long long) && + __alignof__(long) == __alignof__(long long)) + return kstrtoll(s, base, (long long *)res); + else + return _kstrtol(s, base, res); +} + +int __must_check kstrtouint(const char *s, unsigned int base, unsigned int *res); +int __must_check kstrtoint(const char *s, unsigned int base, int *res); + +static inline int __must_check kstrtou64(const char *s, unsigned int base, u64 *res) +{ + return kstrtoull(s, base, res); +} + +static inline int __must_check kstrtos64(const char *s, unsigned int base, s64 *res) +{ + return kstrtoll(s, base, res); +} + +static inline int __must_check kstrtou32(const char *s, unsigned int base, u32 *res) +{ + return kstrtouint(s, base, res); +} + +static inline int __must_check kstrtos32(const char *s, unsigned int base, s32 *res) +{ + return kstrtoint(s, base, res); +} + +int __must_check kstrtou16(const char *s, unsigned int base, u16 *res); +int __must_check kstrtos16(const char *s, unsigned int base, s16 *res); +int __must_check kstrtou8(const char *s, unsigned int base, u8 *res); +int __must_check kstrtos8(const char *s, unsigned int base, s8 *res); +#endif /* ifndef strict_strtol */ + +#endif /* < 2.6.39 */ + #endif /* __BACKPORT_KERNEL_H */ |