diff options
| author | Jiri Kosina <jkosina@suse.cz> | 2011-06-10 14:46:48 +0200 | 
|---|---|---|
| committer | Jiri Kosina <jkosina@suse.cz> | 2011-06-10 14:46:57 +0200 | 
| commit | 5be5758c114b18260c6fd4c8373bf89e39b0fe82 (patch) | |
| tree | 54390f904df6ff11e570f764c444356cf2709fda /lib/kstrtox.c | |
| parent | 71f66a6580c4e42df377bebbcca5c72661a40700 (diff) | |
| parent | 7f45e5cd1718ed769295033ca214032848a0097d (diff) | |
| download | olio-linux-3.10-5be5758c114b18260c6fd4c8373bf89e39b0fe82.tar.xz olio-linux-3.10-5be5758c114b18260c6fd4c8373bf89e39b0fe82.zip  | |
Merge branch 'master' into for-next
Sync with Linus' tree to be able to apply patches against new
code I have in queue.
Diffstat (limited to 'lib/kstrtox.c')
| -rw-r--r-- | lib/kstrtox.c | 26 | 
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/kstrtox.c b/lib/kstrtox.c index a235f3cc471..2dbae88090a 100644 --- a/lib/kstrtox.c +++ b/lib/kstrtox.c @@ -17,6 +17,7 @@  #include <linux/math64.h>  #include <linux/module.h>  #include <linux/types.h> +#include <asm/uaccess.h>  static inline char _tolower(const char c)  { @@ -222,3 +223,28 @@ int kstrtos8(const char *s, unsigned int base, s8 *res)  	return 0;  }  EXPORT_SYMBOL(kstrtos8); + +#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);  |