linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 01/52] kstrtox: converting strings to integers done (hopefully) right
@ 2011-02-05 14:20 Alexey Dobriyan
  2011-02-05 14:20 ` [PATCH 02/52] kstrtox: convert kernel/ Alexey Dobriyan
                   ` (50 more replies)
  0 siblings, 51 replies; 58+ messages in thread
From: Alexey Dobriyan @ 2011-02-05 14:20 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, adobriyan

1. simple_strto*() do not contain overflow checks and crufty,
   libc way to indicate failure.
2. strict_strto*() also do not have overflow checks but the name and
   comments pretend they do.
3. Both families have only "long long" and "long" variants,
   but users want strtou8()
4. Both "simple" and "strict" prefixes are wrong:
   Simple doesn't exactly say what's so simple, strict should not exist
   because conversion should be strict by default.

The solution is to use "k" prefix and add convertors for more types.
Enter
	kstrtoull()
	kstrtoll()
	kstrtoul()
	kstrtol()
	kstrtouint()
	kstrtoint()
	kstrtou64()
	kstrtos64()
	kstrtou32()
	kstrtos32()
	kstrtou16()
	kstrtos16()
	kstrtou8()
	kstrtos8()

Include runtime testsuite (somewhat incomplete) as well.

strict_strto*() become deprecated, stubbed to kstrto*() and
eventually will be removed altogether.

Use kstrto*() in code today!

Note: sizeof and __alignof__ trick is done to save function call
      where types aren't distinguishable.

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
 drivers/video/via/viafbdev.h |    3 -
 include/linux/kernel.h       |   62 ++++-
 lib/Kconfig.debug            |    3 +
 lib/Makefile                 |    2 +
 lib/kstrtox.c                |  227 +++++++++++++
 lib/test-kstrtox.c           |  739 ++++++++++++++++++++++++++++++++++++++++++
 lib/vsprintf.c               |  141 --------
 scripts/checkpatch.pl        |    4 +-
 8 files changed, 1031 insertions(+), 150 deletions(-)
 create mode 100644 lib/kstrtox.c
 create mode 100644 lib/test-kstrtox.c

diff --git a/drivers/video/via/viafbdev.h b/drivers/video/via/viafbdev.h
index d66f963..137996d 100644
--- a/drivers/video/via/viafbdev.h
+++ b/drivers/video/via/viafbdev.h
@@ -94,9 +94,6 @@ extern int viafb_LCD_ON;
 extern int viafb_DVI_ON;
 extern int viafb_hotplug;
 
-extern int strict_strtoul(const char *cp, unsigned int base,
-	unsigned long *res);
-
 u8 viafb_gpio_i2c_read_lvds(struct lvds_setting_information
 	*plvds_setting_info, struct lvds_chip_information
 	*plvds_chip_info, u8 index);
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 2fe6e84..f689494 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -187,14 +187,68 @@ NORET_TYPE void do_exit(long error_code)
 	ATTRIB_NORET;
 NORET_TYPE void complete_and_exit(struct completion *, long)
 	ATTRIB_NORET;
+
+/* 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)
+{
+	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)
+{
+	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);
+
 extern unsigned long simple_strtoul(const char *,char **,unsigned int);
 extern long simple_strtol(const char *,char **,unsigned int);
 extern unsigned long long simple_strtoull(const char *,char **,unsigned int);
 extern long long simple_strtoll(const char *,char **,unsigned int);
-extern int __must_check strict_strtoul(const char *, unsigned int, unsigned long *);
-extern int __must_check strict_strtol(const char *, unsigned int, long *);
-extern int __must_check strict_strtoull(const char *, unsigned int, unsigned long long *);
-extern int __must_check strict_strtoll(const char *, unsigned int, long long *);
+#define strict_strtoul	kstrtoul
+#define strict_strtol	kstrtol
+#define strict_strtoull	kstrtoull
+#define strict_strtoll	kstrtoll
+
 extern int sprintf(char * buf, const char * fmt, ...)
 	__attribute__ ((format (printf, 2, 3)));
 extern int vsprintf(char *buf, const char *, va_list)
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 3967c23..6e35aeb 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -1236,3 +1236,6 @@ source "samples/Kconfig"
 source "lib/Kconfig.kgdb"
 
 source "lib/Kconfig.kmemcheck"
+
+config TEST_KSTRTOX
+	tristate "Test kstrto*() family of functions at runtime"
diff --git a/lib/Makefile b/lib/Makefile
index cbb774f..dfbf7d8 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -22,6 +22,8 @@ lib-y	+= kobject.o kref.o klist.o
 obj-y += bcd.o div64.o sort.o parser.o halfmd4.o debug_locks.o random32.o \
 	 bust_spinlocks.o hexdump.o kasprintf.o bitmap.o scatterlist.o \
 	 string_helpers.o gcd.o lcm.o list_sort.o uuid.o flex_array.o
+obj-y += kstrtox.o
+obj-$(CONFIG_TEST_KSTRTOX) += test-kstrtox.o
 
 ifeq ($(CONFIG_DEBUG_KOBJECT),y)
 CFLAGS_kobject.o += -DDEBUG
diff --git a/lib/kstrtox.c b/lib/kstrtox.c
new file mode 100644
index 0000000..d8af7f6
--- /dev/null
+++ b/lib/kstrtox.c
@@ -0,0 +1,227 @@
+/*
+ * Convert integer string representation to an integer.
+ * If an integer doesn't fit into specified type, -E is returned.
+ *
+ * Integer starts with optional sign.
+ * kstrtou*() functions do not accept sign "-".
+ *
+ * Radix 0 means autodetection: leading "0x" implies radix 16,
+ * leading "0" implies radix 8, otherwise radix is 10.
+ * Autodetection hints work after optional sign, but not before.
+ *
+ * If -E is returned, result is not touched.
+ */
+#include <linux/ctype.h>
+#include <linux/errno.h>
+#include <linux/kernel.h>
+#include <linux/math64.h>
+#include <linux/module.h>
+#include <linux/types.h>
+
+static inline char _tolower(const char c)
+{
+	return c | 0x20;
+}
+
+static int _kstrtoull(const char *s, unsigned int base, unsigned long long *res)
+{
+	unsigned long long acc;
+	int ok;
+
+	if (base == 0) {
+		if (s[0] == '0') {
+			if (_tolower(s[1]) == 'x' && isxdigit(s[2]))
+				base = 16;
+			else
+				base = 8;
+		} else
+			base = 10;
+	}
+	if (base == 16 && s[0] == '0' && _tolower(s[1]) == 'x')
+		s += 2;
+
+	acc = 0;
+	ok = 0;
+	while (*s) {
+		unsigned int val;
+
+		if ('0' <= *s && *s <= '9')
+			val = *s - '0';
+		else if ('a' <= _tolower(*s) && _tolower(*s) <= 'f')
+			val = _tolower(*s) - 'a' + 10;
+		else if (*s == '\n') {
+			if (*(s + 1) == '\0')
+				break;
+			else
+				return -EINVAL;
+		} else
+			return -EINVAL;
+
+		if (val >= base)
+			return -EINVAL;
+		if (acc > div_u64(ULLONG_MAX - val, base))
+			return -EINVAL;
+		acc = acc * base + val;
+		ok = 1;
+
+		s++;
+	}
+	if (!ok)
+		return -EINVAL;
+	*res = acc;
+	return 0;
+}
+
+int kstrtoull(const char *s, unsigned int base, unsigned long long *res)
+{
+	if (s[0] == '+')
+		s++;
+	return _kstrtoull(s, base, res);
+}
+EXPORT_SYMBOL(kstrtoull);
+
+int kstrtoll(const char *s, unsigned int base, long long *res)
+{
+	unsigned long long tmp;
+	int rv;
+
+	if (s[0] == '-') {
+		rv = _kstrtoull(s + 1, base, &tmp);
+		if (rv < 0)
+			return rv;
+		if ((long long)(-tmp) >= 0)
+			return -EINVAL;
+		*res = -tmp;
+	} else {
+		rv = kstrtoull(s, base, &tmp);
+		if (rv < 0)
+			return rv;
+		if ((long long)tmp < 0)
+			return -EINVAL;
+		*res = tmp;
+	}
+	return 0;
+}
+EXPORT_SYMBOL(kstrtoll);
+
+/* Internal, do not use. */
+int _kstrtoul(const char *s, unsigned int base, unsigned long *res)
+{
+	unsigned long long tmp;
+	int rv;
+
+	rv = kstrtoull(s, base, &tmp);
+	if (rv < 0)
+		return rv;
+	if (tmp != (unsigned long long)(unsigned long)tmp)
+		return -EINVAL;
+	*res = tmp;
+	return 0;
+}
+EXPORT_SYMBOL(_kstrtoul);
+
+/* Internal, do not use. */
+int _kstrtol(const char *s, unsigned int base, long *res)
+{
+	long long tmp;
+	int rv;
+
+	rv = kstrtoll(s, base, &tmp);
+	if (rv < 0)
+		return rv;
+	if (tmp != (long long)(long)tmp)
+		return -EINVAL;
+	*res = tmp;
+	return 0;
+}
+EXPORT_SYMBOL(_kstrtol);
+
+int kstrtouint(const char *s, unsigned int base, unsigned int *res)
+{
+	unsigned long long tmp;
+	int rv;
+
+	rv = kstrtoull(s, base, &tmp);
+	if (rv < 0)
+		return rv;
+	if (tmp != (unsigned long long)(unsigned int)tmp)
+		return -EINVAL;
+	*res = tmp;
+	return 0;
+}
+EXPORT_SYMBOL(kstrtouint);
+
+int kstrtoint(const char *s, unsigned int base, int *res)
+{
+	long long tmp;
+	int rv;
+
+	rv = kstrtoll(s, base, &tmp);
+	if (rv < 0)
+		return rv;
+	if (tmp != (long long)(int)tmp)
+		return -EINVAL;
+	*res = tmp;
+	return 0;
+}
+EXPORT_SYMBOL(kstrtoint);
+
+int kstrtou16(const char *s, unsigned int base, u16 *res)
+{
+	unsigned long long tmp;
+	int rv;
+
+	rv = kstrtoull(s, base, &tmp);
+	if (rv < 0)
+		return rv;
+	if (tmp != (unsigned long long)(u16)tmp)
+		return -EINVAL;
+	*res = tmp;
+	return 0;
+}
+EXPORT_SYMBOL(kstrtou16);
+
+int kstrtos16(const char *s, unsigned int base, s16 *res)
+{
+	long long tmp;
+	int rv;
+
+	rv = kstrtoll(s, base, &tmp);
+	if (rv < 0)
+		return rv;
+	if (tmp != (long long)(s16)tmp)
+		return -EINVAL;
+	*res = tmp;
+	return 0;
+}
+EXPORT_SYMBOL(kstrtos16);
+
+int kstrtou8(const char *s, unsigned int base, u8 *res)
+{
+	unsigned long long tmp;
+	int rv;
+
+	rv = kstrtoull(s, base, &tmp);
+	if (rv < 0)
+		return rv;
+	if (tmp != (unsigned long long)(u8)tmp)
+		return -EINVAL;
+	*res = tmp;
+	return 0;
+}
+EXPORT_SYMBOL(kstrtou8);
+
+int kstrtos8(const char *s, unsigned int base, s8 *res)
+{
+	long long tmp;
+	int rv;
+
+	rv = kstrtoll(s, base, &tmp);
+	if (rv < 0)
+		return rv;
+	if (tmp != (long long)(s8)tmp)
+		return -EINVAL;
+	*res = tmp;
+	return 0;
+}
+EXPORT_SYMBOL(kstrtos8);
diff --git a/lib/test-kstrtox.c b/lib/test-kstrtox.c
new file mode 100644
index 0000000..325c2f9
--- /dev/null
+++ b/lib/test-kstrtox.c
@@ -0,0 +1,739 @@
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+
+#define for_each_test(i, test)	\
+	for (i = 0; i < sizeof(test) / sizeof(test[0]); i++)
+
+struct test_fail {
+	const char *str;
+	unsigned int base;
+};
+
+#define DEFINE_TEST_FAIL(test)	\
+	const struct test_fail test[] __initdata
+
+#define DECLARE_TEST_OK(type, test_type)	\
+	test_type {				\
+		const char *str;		\
+		unsigned int base;		\
+		type expected_res;		\
+	}
+
+#define DEFINE_TEST_OK(type, test)	\
+	const type test[] __initdata
+
+#define TEST_FAIL(fn, type, fmt, test)					\
+{									\
+	unsigned int i;							\
+									\
+	for_each_test(i, test) {					\
+		const struct test_fail *t = &test[i];			\
+		type tmp;						\
+		int rv;							\
+									\
+		tmp = 0;						\
+		rv = fn(t->str, t->base, &tmp);				\
+		if (rv >= 0) {						\
+			WARN(1, "str '%s', base %u, expected -E, got %d/" fmt "\n",	\
+				t->str, t->base, rv, tmp);		\
+			continue;					\
+		}							\
+	}								\
+}
+
+#define TEST_OK(fn, type, fmt, test)					\
+{									\
+	unsigned int i;							\
+									\
+	for_each_test(i, test) {					\
+		const typeof(test[0]) *t = &test[i];			\
+		type res;						\
+		int rv;							\
+									\
+		rv = fn(t->str, t->base, &res);				\
+		if (rv != 0) {						\
+			WARN(1, "str '%s', base %u, expected 0/" fmt ", got %d\n",	\
+				t->str, t->base, t->expected_res, rv);	\
+			continue;					\
+		}							\
+		if (res != t->expected_res) {				\
+			WARN(1, "str '%s', base %u, expected " fmt ", got " fmt "\n",	\
+				t->str, t->base, t->expected_res, res);	\
+			continue;					\
+		}							\
+	}								\
+}
+
+static void __init test_kstrtoull_ok(void)
+{
+	DECLARE_TEST_OK(unsigned long long, struct test_ull);
+	static DEFINE_TEST_OK(struct test_ull, test_ull_ok) = {
+		{"0",	10,	0ULL},
+		{"1",	10,	1ULL},
+		{"127",	10,	127ULL},
+		{"128",	10,	128ULL},
+		{"129",	10,	129ULL},
+		{"255",	10,	255ULL},
+		{"256",	10,	256ULL},
+		{"257",	10,	257ULL},
+		{"32767",	10,	32767ULL},
+		{"32768",	10,	32768ULL},
+		{"32769",	10,	32769ULL},
+		{"65535",	10,	65535ULL},
+		{"65536",	10,	65536ULL},
+		{"65537",	10,	65537ULL},
+		{"2147483647",	10,	2147483647ULL},
+		{"2147483648",	10,	2147483648ULL},
+		{"2147483649",	10,	2147483649ULL},
+		{"4294967295",	10,	4294967295ULL},
+		{"4294967296",	10,	4294967296ULL},
+		{"4294967297",	10,	4294967297ULL},
+		{"9223372036854775807",	10,	9223372036854775807ULL},
+		{"9223372036854775808",	10,	9223372036854775808ULL},
+		{"9223372036854775809",	10,	9223372036854775809ULL},
+		{"18446744073709551614",	10,	18446744073709551614ULL},
+		{"18446744073709551615",	10,	18446744073709551615ULL},
+
+		{"00",		8,	00ULL},
+		{"01",		8,	01ULL},
+		{"0177",	8,	0177ULL},
+		{"0200",	8,	0200ULL},
+		{"0201",	8,	0201ULL},
+		{"0377",	8,	0377ULL},
+		{"0400",	8,	0400ULL},
+		{"0401",	8,	0401ULL},
+		{"077777",	8,	077777ULL},
+		{"0100000",	8,	0100000ULL},
+		{"0100001",	8,	0100001ULL},
+		{"0177777",	8,	0177777ULL},
+		{"0200000",	8,	0200000ULL},
+		{"0200001",	8,	0200001ULL},
+		{"017777777777",	8,	017777777777ULL},
+		{"020000000000",	8,	020000000000ULL},
+		{"020000000001",	8,	020000000001ULL},
+		{"037777777777",	8,	037777777777ULL},
+		{"040000000000",	8,	040000000000ULL},
+		{"040000000001",	8,	040000000001ULL},
+		{"0777777777777777777777",	8,	0777777777777777777777ULL},
+		{"01000000000000000000000",	8,	01000000000000000000000ULL},
+		{"01000000000000000000001",	8,	01000000000000000000001ULL},
+		{"01777777777777777777776",	8,	01777777777777777777776ULL},
+		{"01777777777777777777777",	8,	01777777777777777777777ULL},
+
+		{"0x0",		16,	0x0ULL},
+		{"0x1",		16,	0x1ULL},
+		{"0x7f",	16,	0x7fULL},
+		{"0x80",	16,	0x80ULL},
+		{"0x81",	16,	0x81ULL},
+		{"0xff",	16,	0xffULL},
+		{"0x100",	16,	0x100ULL},
+		{"0x101",	16,	0x101ULL},
+		{"0x7fff",	16,	0x7fffULL},
+		{"0x8000",	16,	0x8000ULL},
+		{"0x8001",	16,	0x8001ULL},
+		{"0xffff",	16,	0xffffULL},
+		{"0x10000",	16,	0x10000ULL},
+		{"0x10001",	16,	0x10001ULL},
+		{"0x7fffffff",	16,	0x7fffffffULL},
+		{"0x80000000",	16,	0x80000000ULL},
+		{"0x80000001",	16,	0x80000001ULL},
+		{"0xffffffff",	16,	0xffffffffULL},
+		{"0x100000000",	16,	0x100000000ULL},
+		{"0x100000001",	16,	0x100000001ULL},
+		{"0x7fffffffffffffff",	16,	0x7fffffffffffffffULL},
+		{"0x8000000000000000",	16,	0x8000000000000000ULL},
+		{"0x8000000000000001",	16,	0x8000000000000001ULL},
+		{"0xfffffffffffffffe",	16,	0xfffffffffffffffeULL},
+		{"0xffffffffffffffff",	16,	0xffffffffffffffffULL},
+
+		{"0\n",	0,	0ULL},
+	};
+	TEST_OK(kstrtoull, unsigned long long, "%llu", test_ull_ok);
+}
+
+static void __init test_kstrtoull_fail(void)
+{
+	static DEFINE_TEST_FAIL(test_ull_fail) = {
+		{"",	0},
+		{"",	8},
+		{"",	10},
+		{"",	16},
+		{"\n",	0},
+		{"\n",	8},
+		{"\n",	10},
+		{"\n",	16},
+		{"\n0",	0},
+		{"\n0",	8},
+		{"\n0",	10},
+		{"\n0",	16},
+		{"+",	0},
+		{"+",	8},
+		{"+",	10},
+		{"+",	16},
+		{"-",	0},
+		{"-",	8},
+		{"-",	10},
+		{"-",	16},
+		{"0x",	0},
+		{"0x",	16},
+		{"0X",	0},
+		{"0X",	16},
+		{"0 ",	0},
+		{"1+",	0},
+		{"1-",	0},
+		{" 2",	0},
+		/* base autodetection */
+		{"0x0z",	0},
+		{"0z",		0},
+		{"a",		0},
+		/* digit >= base */
+		{"2",	2},
+		{"8",	8},
+		{"a",	10},
+		{"A",	10},
+		{"g",	16},
+		{"G",	16},
+		/* overflow */
+		{"10000000000000000000000000000000000000000000000000000000000000000",	2},
+		{"2000000000000000000000",	8},
+		{"18446744073709551616",	10},
+		{"10000000000000000",	16},
+		/* negative */
+		{"-0", 0},
+		{"-0", 8},
+		{"-0", 10},
+		{"-0", 16},
+		{"-1", 0},
+		{"-1", 8},
+		{"-1", 10},
+		{"-1", 16},
+		/* sign is first character if any */
+		{"-+1", 0},
+		{"-+1", 8},
+		{"-+1", 10},
+		{"-+1", 16},
+		/* nothing after \n */
+		{"0\n0", 0},
+		{"0\n0", 8},
+		{"0\n0", 10},
+		{"0\n0", 16},
+		{"0\n+", 0},
+		{"0\n+", 8},
+		{"0\n+", 10},
+		{"0\n+", 16},
+		{"0\n-", 0},
+		{"0\n-", 8},
+		{"0\n-", 10},
+		{"0\n-", 16},
+		{"0\n ", 0},
+		{"0\n ", 8},
+		{"0\n ", 10},
+		{"0\n ", 16},
+	};
+	TEST_FAIL(kstrtoull, unsigned long long, "%llu", test_ull_fail);
+}
+
+static void __init test_kstrtoll_ok(void)
+{
+	DECLARE_TEST_OK(long long, struct test_ll);
+	static DEFINE_TEST_OK(struct test_ll, test_ll_ok) = {
+		{"0",	10,	0LL},
+		{"1",	10,	1LL},
+		{"127",	10,	127LL},
+		{"128",	10,	128LL},
+		{"129",	10,	129LL},
+		{"255",	10,	255LL},
+		{"256",	10,	256LL},
+		{"257",	10,	257LL},
+		{"32767",	10,	32767LL},
+		{"32768",	10,	32768LL},
+		{"32769",	10,	32769LL},
+		{"65535",	10,	65535LL},
+		{"65536",	10,	65536LL},
+		{"65537",	10,	65537LL},
+		{"2147483647",	10,	2147483647LL},
+		{"2147483648",	10,	2147483648LL},
+		{"2147483649",	10,	2147483649LL},
+		{"4294967295",	10,	4294967295LL},
+		{"4294967296",	10,	4294967296LL},
+		{"4294967297",	10,	4294967297LL},
+		{"9223372036854775807",	10,	9223372036854775807LL},
+
+		{"-1",	10,	-1LL},
+		{"-2",	10,	-2LL},
+		{"-9223372036854775808",	10,	LLONG_MIN},
+	};
+	TEST_OK(kstrtoll, long long, "%lld", test_ll_ok);
+}
+
+static void __init test_kstrtoll_fail(void)
+{
+	static DEFINE_TEST_FAIL(test_ll_fail) = {
+		{"9223372036854775808",	10},
+		{"9223372036854775809",	10},
+		{"18446744073709551614",	10},
+		{"18446744073709551615",	10},
+		{"-9223372036854775809",	10},
+		{"-18446744073709551614",	10},
+		{"-18446744073709551615",	10},
+		/* negative zero isn't an integer in Linux */
+		{"-0",	0},
+		{"-0",	8},
+		{"-0",	10},
+		{"-0",	16},
+		/* sign is first character if any */
+		{"-+1", 0},
+		{"-+1", 8},
+		{"-+1", 10},
+		{"-+1", 16},
+	};
+	TEST_FAIL(kstrtoll, long long, "%lld", test_ll_fail);
+}
+
+static void __init test_kstrtou64_ok(void)
+{
+	DECLARE_TEST_OK(u64, struct test_u64);
+	static DEFINE_TEST_OK(struct test_u64, test_u64_ok) = {
+		{"0",	10,	0},
+		{"1",	10,	1},
+		{"126",	10,	126},
+		{"127",	10,	127},
+		{"128",	10,	128},
+		{"129",	10,	129},
+		{"254",	10,	254},
+		{"255",	10,	255},
+		{"256",	10,	256},
+		{"257",	10,	257},
+		{"32766",	10,	32766},
+		{"32767",	10,	32767},
+		{"32768",	10,	32768},
+		{"32769",	10,	32769},
+		{"65534",	10,	65534},
+		{"65535",	10,	65535},
+		{"65536",	10,	65536},
+		{"65537",	10,	65537},
+		{"2147483646",	10,	2147483646},
+		{"2147483647",	10,	2147483647},
+		{"2147483648",	10,	2147483648},
+		{"2147483649",	10,	2147483649},
+		{"4294967294",	10,	4294967294},
+		{"4294967295",	10,	4294967295},
+		{"4294967296",	10,	4294967296},
+		{"4294967297",	10,	4294967297},
+		{"9223372036854775806",	10,	9223372036854775806ULL},
+		{"9223372036854775807",	10,	9223372036854775807ULL},
+		{"9223372036854775808",	10,	9223372036854775808ULL},
+		{"9223372036854775809",	10,	9223372036854775809ULL},
+		{"18446744073709551614",	10,	18446744073709551614ULL},
+		{"18446744073709551615",	10,	18446744073709551615ULL},
+	};
+	TEST_OK(kstrtou64, u64, "%llu", test_u64_ok);
+}
+
+static void __init test_kstrtou64_fail(void)
+{
+	static DEFINE_TEST_FAIL(test_u64_fail) = {
+		{"-2",	10},
+		{"-1",	10},
+		{"18446744073709551616",	10},
+		{"18446744073709551617",	10},
+	};
+	TEST_FAIL(kstrtou64, u64, "%llu", test_u64_fail);
+}
+
+static void __init test_kstrtos64_ok(void)
+{
+	DECLARE_TEST_OK(s64, struct test_s64);
+	static DEFINE_TEST_OK(struct test_s64, test_s64_ok) = {
+		{"-128",	10,	-128},
+		{"-127",	10,	-127},
+		{"-1",	10,	-1},
+		{"0",	10,	0},
+		{"1",	10,	1},
+		{"126",	10,	126},
+		{"127",	10,	127},
+		{"128",	10,	128},
+		{"129",	10,	129},
+		{"254",	10,	254},
+		{"255",	10,	255},
+		{"256",	10,	256},
+		{"257",	10,	257},
+		{"32766",	10,	32766},
+		{"32767",	10,	32767},
+		{"32768",	10,	32768},
+		{"32769",	10,	32769},
+		{"65534",	10,	65534},
+		{"65535",	10,	65535},
+		{"65536",	10,	65536},
+		{"65537",	10,	65537},
+		{"2147483646",	10,	2147483646},
+		{"2147483647",	10,	2147483647},
+		{"2147483648",	10,	2147483648},
+		{"2147483649",	10,	2147483649},
+		{"4294967294",	10,	4294967294},
+		{"4294967295",	10,	4294967295},
+		{"4294967296",	10,	4294967296},
+		{"4294967297",	10,	4294967297},
+		{"9223372036854775806",	10,	9223372036854775806LL},
+		{"9223372036854775807",	10,	9223372036854775807LL},
+	};
+	TEST_OK(kstrtos64, s64, "%lld", test_s64_ok);
+}
+
+static void __init test_kstrtos64_fail(void)
+{
+	static DEFINE_TEST_FAIL(test_s64_fail) = {
+		{"9223372036854775808",	10},
+		{"9223372036854775809",	10},
+		{"18446744073709551614",	10},
+		{"18446744073709551615",	10},
+		{"18446744073709551616",	10},
+		{"18446744073709551617",	10},
+	};
+	TEST_FAIL(kstrtos64, s64, "%lld", test_s64_fail);
+}
+
+static void __init test_kstrtou32_ok(void)
+{
+	DECLARE_TEST_OK(u32, struct test_u32);
+	static DEFINE_TEST_OK(struct test_u32, test_u32_ok) = {
+		{"0",	10,	0},
+		{"1",	10,	1},
+		{"126",	10,	126},
+		{"127",	10,	127},
+		{"128",	10,	128},
+		{"129",	10,	129},
+		{"254",	10,	254},
+		{"255",	10,	255},
+		{"256",	10,	256},
+		{"257",	10,	257},
+		{"32766",	10,	32766},
+		{"32767",	10,	32767},
+		{"32768",	10,	32768},
+		{"32769",	10,	32769},
+		{"65534",	10,	65534},
+		{"65535",	10,	65535},
+		{"65536",	10,	65536},
+		{"65537",	10,	65537},
+		{"2147483646",	10,	2147483646},
+		{"2147483647",	10,	2147483647},
+		{"2147483648",	10,	2147483648},
+		{"2147483649",	10,	2147483649},
+		{"4294967294",	10,	4294967294},
+		{"4294967295",	10,	4294967295},
+	};
+	TEST_OK(kstrtou32, u32, "%u", test_u32_ok);
+}
+
+static void __init test_kstrtou32_fail(void)
+{
+	static DEFINE_TEST_FAIL(test_u32_fail) = {
+		{"-2",	10},
+		{"-1",	10},
+		{"4294967296",	10},
+		{"4294967297",	10},
+		{"9223372036854775806",	10},
+		{"9223372036854775807",	10},
+		{"9223372036854775808",	10},
+		{"9223372036854775809",	10},
+		{"18446744073709551614",	10},
+		{"18446744073709551615",	10},
+		{"18446744073709551616",	10},
+		{"18446744073709551617",	10},
+	};
+	TEST_FAIL(kstrtou32, u32, "%u", test_u32_fail);
+}
+
+static void __init test_kstrtos32_ok(void)
+{
+	DECLARE_TEST_OK(s32, struct test_s32);
+	static DEFINE_TEST_OK(struct test_s32, test_s32_ok) = {
+		{"-128",	10,	-128},
+		{"-127",	10,	-127},
+		{"-1",	10,	-1},
+		{"0",	10,	0},
+		{"1",	10,	1},
+		{"126",	10,	126},
+		{"127",	10,	127},
+		{"128",	10,	128},
+		{"129",	10,	129},
+		{"254",	10,	254},
+		{"255",	10,	255},
+		{"256",	10,	256},
+		{"257",	10,	257},
+		{"32766",	10,	32766},
+		{"32767",	10,	32767},
+		{"32768",	10,	32768},
+		{"32769",	10,	32769},
+		{"65534",	10,	65534},
+		{"65535",	10,	65535},
+		{"65536",	10,	65536},
+		{"65537",	10,	65537},
+		{"2147483646",	10,	2147483646},
+		{"2147483647",	10,	2147483647},
+	};
+	TEST_OK(kstrtos32, s32, "%d", test_s32_ok);
+}
+
+static void __init test_kstrtos32_fail(void)
+{
+	static DEFINE_TEST_FAIL(test_s32_fail) = {
+		{"2147483648",	10},
+		{"2147483649",	10},
+		{"4294967294",	10},
+		{"4294967295",	10},
+		{"4294967296",	10},
+		{"4294967297",	10},
+		{"9223372036854775806",	10},
+		{"9223372036854775807",	10},
+		{"9223372036854775808",	10},
+		{"9223372036854775809",	10},
+		{"18446744073709551614",	10},
+		{"18446744073709551615",	10},
+		{"18446744073709551616",	10},
+		{"18446744073709551617",	10},
+	};
+	TEST_FAIL(kstrtos32, s32, "%d", test_s32_fail);
+}
+
+static void __init test_kstrtou16_ok(void)
+{
+	DECLARE_TEST_OK(u16, struct test_u16);
+	static DEFINE_TEST_OK(struct test_u16, test_u16_ok) = {
+		{"0",	10,	0},
+		{"1",	10,	1},
+		{"126",	10,	126},
+		{"127",	10,	127},
+		{"128",	10,	128},
+		{"129",	10,	129},
+		{"254",	10,	254},
+		{"255",	10,	255},
+		{"256",	10,	256},
+		{"257",	10,	257},
+		{"32766",	10,	32766},
+		{"32767",	10,	32767},
+		{"32768",	10,	32768},
+		{"32769",	10,	32769},
+		{"65534",	10,	65534},
+		{"65535",	10,	65535},
+	};
+	TEST_OK(kstrtou16, u16, "%hu", test_u16_ok);
+}
+
+static void __init test_kstrtou16_fail(void)
+{
+	static DEFINE_TEST_FAIL(test_u16_fail) = {
+		{"-2",	10},
+		{"-1",	10},
+		{"65536",	10},
+		{"65537",	10},
+		{"2147483646",	10},
+		{"2147483647",	10},
+		{"2147483648",	10},
+		{"2147483649",	10},
+		{"4294967294",	10},
+		{"4294967295",	10},
+		{"4294967296",	10},
+		{"4294967297",	10},
+		{"9223372036854775806",	10},
+		{"9223372036854775807",	10},
+		{"9223372036854775808",	10},
+		{"9223372036854775809",	10},
+		{"18446744073709551614",	10},
+		{"18446744073709551615",	10},
+		{"18446744073709551616",	10},
+		{"18446744073709551617",	10},
+	};
+	TEST_FAIL(kstrtou16, u16, "%hu", test_u16_fail);
+}
+
+static void __init test_kstrtos16_ok(void)
+{
+	DECLARE_TEST_OK(s16, struct test_s16);
+	static DEFINE_TEST_OK(struct test_s16, test_s16_ok) = {
+		{"-130",	10,	-130},
+		{"-129",	10,	-129},
+		{"-128",	10,	-128},
+		{"-127",	10,	-127},
+		{"-1",	10,	-1},
+		{"0",	10,	0},
+		{"1",	10,	1},
+		{"126",	10,	126},
+		{"127",	10,	127},
+		{"128",	10,	128},
+		{"129",	10,	129},
+		{"254",	10,	254},
+		{"255",	10,	255},
+		{"256",	10,	256},
+		{"257",	10,	257},
+		{"32766",	10,	32766},
+		{"32767",	10,	32767},
+	};
+	TEST_OK(kstrtos16, s16, "%hd", test_s16_ok);
+}
+
+static void __init test_kstrtos16_fail(void)
+{
+	static DEFINE_TEST_FAIL(test_s16_fail) = {
+		{"32768",	10},
+		{"32769",	10},
+		{"65534",	10},
+		{"65535",	10},
+		{"65536",	10},
+		{"65537",	10},
+		{"2147483646",	10},
+		{"2147483647",	10},
+		{"2147483648",	10},
+		{"2147483649",	10},
+		{"4294967294",	10},
+		{"4294967295",	10},
+		{"4294967296",	10},
+		{"4294967297",	10},
+		{"9223372036854775806",	10},
+		{"9223372036854775807",	10},
+		{"9223372036854775808",	10},
+		{"9223372036854775809",	10},
+		{"18446744073709551614",	10},
+		{"18446744073709551615",	10},
+		{"18446744073709551616",	10},
+		{"18446744073709551617",	10},
+	};
+	TEST_FAIL(kstrtos16, s16, "%hd", test_s16_fail);
+}
+
+static void __init test_kstrtou8_ok(void)
+{
+	DECLARE_TEST_OK(u8, struct test_u8);
+	static DEFINE_TEST_OK(struct test_u8, test_u8_ok) = {
+		{"0",	10,	0},
+		{"1",	10,	1},
+		{"126",	10,	126},
+		{"127",	10,	127},
+		{"128",	10,	128},
+		{"129",	10,	129},
+		{"254",	10,	254},
+		{"255",	10,	255},
+	};
+	TEST_OK(kstrtou8, u8, "%hhu", test_u8_ok);
+}
+
+static void __init test_kstrtou8_fail(void)
+{
+	static DEFINE_TEST_FAIL(test_u8_fail) = {
+		{"-2",	10},
+		{"-1",	10},
+		{"256",	10},
+		{"257",	10},
+		{"32766",	10},
+		{"32767",	10},
+		{"32768",	10},
+		{"32769",	10},
+		{"65534",	10},
+		{"65535",	10},
+		{"65536",	10},
+		{"65537",	10},
+		{"2147483646",	10},
+		{"2147483647",	10},
+		{"2147483648",	10},
+		{"2147483649",	10},
+		{"4294967294",	10},
+		{"4294967295",	10},
+		{"4294967296",	10},
+		{"4294967297",	10},
+		{"9223372036854775806",	10},
+		{"9223372036854775807",	10},
+		{"9223372036854775808",	10},
+		{"9223372036854775809",	10},
+		{"18446744073709551614",	10},
+		{"18446744073709551615",	10},
+		{"18446744073709551616",	10},
+		{"18446744073709551617",	10},
+	};
+	TEST_FAIL(kstrtou8, u8, "%hhu", test_u8_fail);
+}
+
+static void __init test_kstrtos8_ok(void)
+{
+	DECLARE_TEST_OK(s8, struct test_s8);
+	static DEFINE_TEST_OK(struct test_s8, test_s8_ok) = {
+		{"-128",	10,	-128},
+		{"-127",	10,	-127},
+		{"-1",	10,	-1},
+		{"0",	10,	0},
+		{"1",	10,	1},
+		{"126",	10,	126},
+		{"127",	10,	127},
+	};
+	TEST_OK(kstrtos8, s8, "%hhd", test_s8_ok);
+}
+
+static void __init test_kstrtos8_fail(void)
+{
+	static DEFINE_TEST_FAIL(test_s8_fail) = {
+		{"-130",	10},
+		{"-129",	10},
+		{"128",	10},
+		{"129",	10},
+		{"254",	10},
+		{"255",	10},
+		{"256",	10},
+		{"257",	10},
+		{"32766",	10},
+		{"32767",	10},
+		{"32768",	10},
+		{"32769",	10},
+		{"65534",	10},
+		{"65535",	10},
+		{"65536",	10},
+		{"65537",	10},
+		{"2147483646",	10},
+		{"2147483647",	10},
+		{"2147483648",	10},
+		{"2147483649",	10},
+		{"4294967294",	10},
+		{"4294967295",	10},
+		{"4294967296",	10},
+		{"4294967297",	10},
+		{"9223372036854775806",	10},
+		{"9223372036854775807",	10},
+		{"9223372036854775808",	10},
+		{"9223372036854775809",	10},
+		{"18446744073709551614",	10},
+		{"18446744073709551615",	10},
+		{"18446744073709551616",	10},
+		{"18446744073709551617",	10},
+	};
+	TEST_FAIL(kstrtos8, s8, "%hhd", test_s8_fail);
+}
+
+static int __init test_kstrtox_init(void)
+{
+	test_kstrtoull_ok();
+	test_kstrtoull_fail();
+	test_kstrtoll_ok();
+	test_kstrtoll_fail();
+
+	test_kstrtou64_ok();
+	test_kstrtou64_fail();
+	test_kstrtos64_ok();
+	test_kstrtos64_fail();
+
+	test_kstrtou32_ok();
+	test_kstrtou32_fail();
+	test_kstrtos32_ok();
+	test_kstrtos32_fail();
+
+	test_kstrtou16_ok();
+	test_kstrtou16_fail();
+	test_kstrtos16_ok();
+	test_kstrtos16_fail();
+
+	test_kstrtou8_ok();
+	test_kstrtou8_fail();
+	test_kstrtos8_ok();
+	test_kstrtos8_fail();
+	return -EINVAL;
+}
+module_init(test_kstrtox_init);
+MODULE_LICENSE("Dual BSD/GPL");
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index d3023df..f3fd99a 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -120,147 +120,6 @@ long long simple_strtoll(const char *cp, char **endp, unsigned int base)
 }
 EXPORT_SYMBOL(simple_strtoll);
 
-/**
- * strict_strtoul - convert a string to an unsigned long strictly
- * @cp: The string to be converted
- * @base: The number base to use
- * @res: The converted result value
- *
- * strict_strtoul converts a string to an unsigned long only if the
- * string is really an unsigned long string, any string containing
- * any invalid char at the tail will be rejected and -EINVAL is returned,
- * only a newline char at the tail is acceptible because people generally
- * change a module parameter in the following way:
- *
- * 	echo 1024 > /sys/module/e1000/parameters/copybreak
- *
- * echo will append a newline to the tail.
- *
- * It returns 0 if conversion is successful and *res is set to the converted
- * value, otherwise it returns -EINVAL and *res is set to 0.
- *
- * simple_strtoul just ignores the successive invalid characters and
- * return the converted value of prefix part of the string.
- */
-int strict_strtoul(const char *cp, unsigned int base, unsigned long *res)
-{
-	char *tail;
-	unsigned long val;
-
-	*res = 0;
-	if (!*cp)
-		return -EINVAL;
-
-	val = simple_strtoul(cp, &tail, base);
-	if (tail == cp)
-		return -EINVAL;
-
-	if ((tail[0] == '\0') || (tail[0] == '\n' && tail[1] == '\0')) {
-		*res = val;
-		return 0;
-	}
-
-	return -EINVAL;
-}
-EXPORT_SYMBOL(strict_strtoul);
-
-/**
- * strict_strtol - convert a string to a long strictly
- * @cp: The string to be converted
- * @base: The number base to use
- * @res: The converted result value
- *
- * strict_strtol is similiar to strict_strtoul, but it allows the first
- * character of a string is '-'.
- *
- * It returns 0 if conversion is successful and *res is set to the converted
- * value, otherwise it returns -EINVAL and *res is set to 0.
- */
-int strict_strtol(const char *cp, unsigned int base, long *res)
-{
-	int ret;
-	if (*cp == '-') {
-		ret = strict_strtoul(cp + 1, base, (unsigned long *)res);
-		if (!ret)
-			*res = -(*res);
-	} else {
-		ret = strict_strtoul(cp, base, (unsigned long *)res);
-	}
-
-	return ret;
-}
-EXPORT_SYMBOL(strict_strtol);
-
-/**
- * strict_strtoull - convert a string to an unsigned long long strictly
- * @cp: The string to be converted
- * @base: The number base to use
- * @res: The converted result value
- *
- * strict_strtoull converts a string to an unsigned long long only if the
- * string is really an unsigned long long string, any string containing
- * any invalid char at the tail will be rejected and -EINVAL is returned,
- * only a newline char at the tail is acceptible because people generally
- * change a module parameter in the following way:
- *
- * 	echo 1024 > /sys/module/e1000/parameters/copybreak
- *
- * echo will append a newline to the tail of the string.
- *
- * It returns 0 if conversion is successful and *res is set to the converted
- * value, otherwise it returns -EINVAL and *res is set to 0.
- *
- * simple_strtoull just ignores the successive invalid characters and
- * return the converted value of prefix part of the string.
- */
-int strict_strtoull(const char *cp, unsigned int base, unsigned long long *res)
-{
-	char *tail;
-	unsigned long long val;
-
-	*res = 0;
-	if (!*cp)
-		return -EINVAL;
-
-	val = simple_strtoull(cp, &tail, base);
-	if (tail == cp)
-		return -EINVAL;
-	if ((tail[0] == '\0') || (tail[0] == '\n' && tail[1] == '\0')) {
-		*res = val;
-		return 0;
-	}
-
-	return -EINVAL;
-}
-EXPORT_SYMBOL(strict_strtoull);
-
-/**
- * strict_strtoll - convert a string to a long long strictly
- * @cp: The string to be converted
- * @base: The number base to use
- * @res: The converted result value
- *
- * strict_strtoll is similiar to strict_strtoull, but it allows the first
- * character of a string is '-'.
- *
- * It returns 0 if conversion is successful and *res is set to the converted
- * value, otherwise it returns -EINVAL and *res is set to 0.
- */
-int strict_strtoll(const char *cp, unsigned int base, long long *res)
-{
-	int ret;
-	if (*cp == '-') {
-		ret = strict_strtoull(cp + 1, base, (unsigned long long *)res);
-		if (!ret)
-			*res = -(*res);
-	} else {
-		ret = strict_strtoull(cp, base, (unsigned long long *)res);
-	}
-
-	return ret;
-}
-EXPORT_SYMBOL(strict_strtoll);
-
 static noinline_for_stack
 int skip_atoi(const char **s)
 {
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 4c0383d..58434b3 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2809,9 +2809,9 @@ sub process {
 			WARN("consider using a completion\n" . $herecurr);
 
 		}
-# recommend strict_strto* over simple_strto*
+# recommend kstrto* over simple_strto*
 		if ($line =~ /\bsimple_(strto.*?)\s*\(/) {
-			WARN("consider using strict_$1 in preference to simple_$1\n" . $herecurr);
+			WARN("consider using kstrto* in preference to simple_$1\n" . $herecurr);
 		}
 # check for __initcall(), use device_initcall() explicitly please
 		if ($line =~ /^.\s*__initcall\s*\(/) {
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 02/52] kstrtox: convert kernel/
  2011-02-05 14:20 [PATCH 01/52] kstrtox: converting strings to integers done (hopefully) right Alexey Dobriyan
@ 2011-02-05 14:20 ` Alexey Dobriyan
  2011-02-05 14:20 ` [PATCH 03/52] kstrtox: convert kernel/trace/ Alexey Dobriyan
                   ` (49 subsequent siblings)
  50 siblings, 0 replies; 58+ messages in thread
From: Alexey Dobriyan @ 2011-02-05 14:20 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, adobriyan


Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
 kernel/gcov/fs.c    |    5 +----
 kernel/ksysfs.c     |    5 +++--
 kernel/params.c     |   24 +++++++++++-------------
 kernel/power/main.c |    8 +++++---
 4 files changed, 20 insertions(+), 22 deletions(-)

diff --git a/kernel/gcov/fs.c b/kernel/gcov/fs.c
index 9bd0934..347c2b3 100644
--- a/kernel/gcov/fs.c
+++ b/kernel/gcov/fs.c
@@ -72,13 +72,10 @@ static int gcov_persist = 1;
 
 static int __init gcov_persist_setup(char *str)
 {
-	unsigned long val;
-
-	if (strict_strtoul(str, 0, &val)) {
+	if (kstrtoint(str, 0, &gcov_persist) < 0) {
 		pr_warning("invalid gcov_persist parameter '%s'\n", str);
 		return 0;
 	}
-	gcov_persist = val;
 	pr_info("setting gcov_persist to %d\n", gcov_persist);
 
 	return 1;
diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
index 0b624e7..b0b4681 100644
--- a/kernel/ksysfs.c
+++ b/kernel/ksysfs.c
@@ -112,8 +112,9 @@ static ssize_t kexec_crash_size_store(struct kobject *kobj,
 	unsigned long cnt;
 	int ret;
 
-	if (strict_strtoul(buf, 0, &cnt))
-		return -EINVAL;
+	ret = kstrtoul(buf, 0, &cnt);
+	if (ret < 0)
+		return ret;
 
 	ret = crash_shrink_memory(cnt);
 	return ret < 0 ? ret : count;
diff --git a/kernel/params.c b/kernel/params.c
index 0da1411..0c36a99 100644
--- a/kernel/params.c
+++ b/kernel/params.c
@@ -218,16 +218,14 @@ int parse_args(const char *name,
 }
 
 /* Lazy bastard, eh? */
-#define STANDARD_PARAM_DEF(name, type, format, tmptype, strtolfn)      	\
+#define STANDARD_PARAM_DEF(name, type, format, strtolfn)		\
 	int param_set_##name(const char *val, const struct kernel_param *kp) \
 	{								\
-		tmptype l;						\
 		int ret;						\
 									\
-		ret = strtolfn(val, 0, &l);				\
-		if (ret == -EINVAL || ((type)l != l))			\
-			return -EINVAL;					\
-		*((type *)kp->arg) = l;					\
+		ret = strtolfn(val, 0, (type *)kp->arg);		\
+		if (ret < 0)						\
+			return ret;					\
 		return 0;						\
 	}								\
 	int param_get_##name(char *buffer, const struct kernel_param *kp) \
@@ -243,13 +241,13 @@ int parse_args(const char *name,
 	EXPORT_SYMBOL(param_ops_##name)
 
 
-STANDARD_PARAM_DEF(byte, unsigned char, "%c", unsigned long, strict_strtoul);
-STANDARD_PARAM_DEF(short, short, "%hi", long, strict_strtol);
-STANDARD_PARAM_DEF(ushort, unsigned short, "%hu", unsigned long, strict_strtoul);
-STANDARD_PARAM_DEF(int, int, "%i", long, strict_strtol);
-STANDARD_PARAM_DEF(uint, unsigned int, "%u", unsigned long, strict_strtoul);
-STANDARD_PARAM_DEF(long, long, "%li", long, strict_strtol);
-STANDARD_PARAM_DEF(ulong, unsigned long, "%lu", unsigned long, strict_strtoul);
+STANDARD_PARAM_DEF(byte, u8, "%c", kstrtou8);
+STANDARD_PARAM_DEF(short, s16, "%hi", kstrtos16);
+STANDARD_PARAM_DEF(ushort, u16, "%hu", kstrtou16);
+STANDARD_PARAM_DEF(int, int, "%i", kstrtoint);
+STANDARD_PARAM_DEF(uint, unsigned int, "%u", kstrtouint);
+STANDARD_PARAM_DEF(long, long, "%li", kstrtol);
+STANDARD_PARAM_DEF(ulong, unsigned long, "%lu", kstrtoul);
 
 int param_set_charp(const char *val, const struct kernel_param *kp)
 {
diff --git a/kernel/power/main.c b/kernel/power/main.c
index 7b5db6a..c53c77e 100644
--- a/kernel/power/main.c
+++ b/kernel/power/main.c
@@ -56,10 +56,12 @@ static ssize_t pm_async_show(struct kobject *kobj, struct kobj_attribute *attr,
 static ssize_t pm_async_store(struct kobject *kobj, struct kobj_attribute *attr,
 			      const char *buf, size_t n)
 {
-	unsigned long val;
+	unsigned int val;
+	int rv;
 
-	if (strict_strtoul(buf, 10, &val))
-		return -EINVAL;
+	rv = kstrtouint(buf, 10, &val);
+	if (rv < 0)
+		return rv;
 
 	if (val > 1)
 		return -EINVAL;
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 03/52] kstrtox: convert kernel/trace/
  2011-02-05 14:20 [PATCH 01/52] kstrtox: converting strings to integers done (hopefully) right Alexey Dobriyan
  2011-02-05 14:20 ` [PATCH 02/52] kstrtox: convert kernel/ Alexey Dobriyan
@ 2011-02-05 14:20 ` Alexey Dobriyan
  2011-02-05 14:20 ` [PATCH 04/52] kstrtox: convert mm/ Alexey Dobriyan
                   ` (48 subsequent siblings)
  50 siblings, 0 replies; 58+ messages in thread
From: Alexey Dobriyan @ 2011-02-05 14:20 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, adobriyan


Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
 kernel/trace/ftrace.c              |    6 +++---
 kernel/trace/ring_buffer.c         |    2 +-
 kernel/trace/trace.c               |   16 ++++++++--------
 kernel/trace/trace_events.c        |    8 ++++----
 kernel/trace/trace_events_filter.c |    4 ++--
 kernel/trace/trace_functions.c     |    4 ++--
 kernel/trace/trace_kprobe.c        |   25 ++++++++++++-------------
 kernel/trace/trace_stack.c         |    4 ++--
 8 files changed, 34 insertions(+), 35 deletions(-)

diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index f3dadae..537fd31 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -747,7 +747,7 @@ ftrace_profile_write(struct file *filp, const char __user *ubuf,
 
 	buf[cnt] = 0;
 
-	ret = strict_strtoul(buf, 10, &val);
+	ret = kstrtoul(buf, 10, &val);
 	if (ret < 0)
 		return ret;
 
@@ -3053,7 +3053,7 @@ ftrace_pid_write(struct file *filp, const char __user *ubuf,
 		   size_t cnt, loff_t *ppos)
 {
 	char buf[64], *tmp;
-	long val;
+	int val;
 	int ret;
 
 	if (cnt >= sizeof(buf))
@@ -3072,7 +3072,7 @@ ftrace_pid_write(struct file *filp, const char __user *ubuf,
 	if (strlen(tmp) == 0)
 		return 1;
 
-	ret = strict_strtol(tmp, 10, &val);
+	ret = kstrtoint(tmp, 10, &val);
 	if (ret < 0)
 		return ret;
 
diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index bd1c35a..82ca69e 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -3972,7 +3972,7 @@ rb_simple_write(struct file *filp, const char __user *ubuf,
 
 	buf[cnt] = 0;
 
-	ret = strict_strtoul(buf, 10, &val);
+	ret = kstrtoul(buf, 10, &val);
 	if (ret < 0)
 		return ret;
 
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index dc53ecb..9b24a46 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -389,7 +389,7 @@ static int __init set_tracing_thresh(char *str)
 
 	if (!str)
 		return 0;
-	ret = strict_strtoul(str, 0, &threshhold);
+	ret = kstrtoul(str, 0, &threshhold);
 	if (ret < 0)
 		return 0;
 	tracing_thresh = threshhold * 1000;
@@ -2702,7 +2702,7 @@ tracing_ctrl_write(struct file *filp, const char __user *ubuf,
 
 	buf[cnt] = 0;
 
-	ret = strict_strtoul(buf, 10, &val);
+	ret = kstrtoul(buf, 10, &val);
 	if (ret < 0)
 		return ret;
 
@@ -2963,7 +2963,7 @@ tracing_max_lat_write(struct file *filp, const char __user *ubuf,
 
 	buf[cnt] = 0;
 
-	ret = strict_strtoul(buf, 10, &val);
+	ret = kstrtoul(buf, 10, &val);
 	if (ret < 0)
 		return ret;
 
@@ -3422,7 +3422,7 @@ tracing_entries_write(struct file *filp, const char __user *ubuf,
 
 	buf[cnt] = 0;
 
-	ret = strict_strtoul(buf, 10, &val);
+	ret = kstrtoul(buf, 10, &val);
 	if (ret < 0)
 		return ret;
 
@@ -4075,7 +4075,7 @@ trace_options_write(struct file *filp, const char __user *ubuf, size_t cnt,
 			 loff_t *ppos)
 {
 	struct trace_option_dentry *topt = filp->private_data;
-	unsigned long val;
+	unsigned int val;
 	char buf[64];
 	int ret;
 
@@ -4087,7 +4087,7 @@ trace_options_write(struct file *filp, const char __user *ubuf, size_t cnt,
 
 	buf[cnt] = 0;
 
-	ret = strict_strtoul(buf, 10, &val);
+	ret = kstrtouint(buf, 10, &val);
 	if (ret < 0)
 		return ret;
 
@@ -4137,7 +4137,7 @@ trace_options_core_write(struct file *filp, const char __user *ubuf, size_t cnt,
 {
 	long index = (long)filp->private_data;
 	char buf[64];
-	unsigned long val;
+	unsigned int val;
 	int ret;
 
 	if (cnt >= sizeof(buf))
@@ -4148,7 +4148,7 @@ trace_options_core_write(struct file *filp, const char __user *ubuf, size_t cnt,
 
 	buf[cnt] = 0;
 
-	ret = strict_strtoul(buf, 10, &val);
+	ret = kstrtouint(buf, 10, &val);
 	if (ret < 0)
 		return ret;
 
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index 35fde09..c968830 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -486,7 +486,7 @@ event_enable_write(struct file *filp, const char __user *ubuf, size_t cnt,
 {
 	struct ftrace_event_call *call = filp->private_data;
 	char buf[64];
-	unsigned long val;
+	int val;
 	int ret;
 
 	if (cnt >= sizeof(buf))
@@ -497,7 +497,7 @@ event_enable_write(struct file *filp, const char __user *ubuf, size_t cnt,
 
 	buf[cnt] = 0;
 
-	ret = strict_strtoul(buf, 10, &val);
+	ret = kstrtoint(buf, 10, &val);
 	if (ret < 0)
 		return ret;
 
@@ -569,8 +569,8 @@ system_enable_write(struct file *filp, const char __user *ubuf, size_t cnt,
 		    loff_t *ppos)
 {
 	const char *system = filp->private_data;
-	unsigned long val;
 	char buf[64];
+	int val;
 	ssize_t ret;
 
 	if (cnt >= sizeof(buf))
@@ -581,7 +581,7 @@ system_enable_write(struct file *filp, const char __user *ubuf, size_t cnt,
 
 	buf[cnt] = 0;
 
-	ret = strict_strtoul(buf, 10, &val);
+	ret = kstrtoint(buf, 10, &val);
 	if (ret < 0)
 		return ret;
 
diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c
index 36d4010..f17f6a0 100644
--- a/kernel/trace/trace_events_filter.c
+++ b/kernel/trace/trace_events_filter.c
@@ -807,9 +807,9 @@ static int filter_add_pred(struct filter_parse_state *ps,
 			fn = filter_pred_pchar;
 	} else {
 		if (field->is_signed)
-			ret = strict_strtoll(pred->regex.pattern, 0, &val);
+			ret = kstrtoll(pred->regex.pattern, 0, &val);
 		else
-			ret = strict_strtoull(pred->regex.pattern, 0, &val);
+			ret = kstrtoull(pred->regex.pattern, 0, &val);
 		if (ret) {
 			parse_error(ps, FILT_ERR_ILLEGAL_INTVAL, 0);
 			return -EINVAL;
diff --git a/kernel/trace/trace_functions.c b/kernel/trace/trace_functions.c
index 16aee4d..2f0dab3 100644
--- a/kernel/trace/trace_functions.c
+++ b/kernel/trace/trace_functions.c
@@ -354,8 +354,8 @@ ftrace_trace_onoff_callback(char *glob, char *cmd, char *param, int enable)
 	 * We use the callback data field (which is a pointer)
 	 * as our counter.
 	 */
-	ret = strict_strtoul(number, 0, (unsigned long *)&count);
-	if (ret)
+	ret = kstrtoul(number, 0, (unsigned long *)&count);
+	if (ret < 0)
 		return ret;
 
  out_reg:
diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
index 2dec9bc..e29849d 100644
--- a/kernel/trace/trace_kprobe.c
+++ b/kernel/trace/trace_kprobe.c
@@ -684,9 +684,8 @@ static int split_symbol_offset(char *symbol, unsigned long *offset)
 
 	tmp = strchr(symbol, '+');
 	if (tmp) {
-		/* skip sign because strict_strtol doesn't accept '+' */
-		ret = strict_strtoul(tmp + 1, 0, offset);
-		if (ret)
+		ret = kstrtoul(tmp, 0, offset);
+		if (ret < 0)
 			return ret;
 		*tmp = '\0';
 	} else
@@ -715,8 +714,10 @@ static int parse_probe_vars(char *arg, const struct fetch_type *t,
 			else
 				ret = -EINVAL;
 		} else if (isdigit(arg[5])) {
-			ret = strict_strtoul(arg + 5, 10, &param);
-			if (ret || param > PARAM_MAX_STACK)
+			ret = kstrtoul(arg + 5, 10, &param);
+			if (ret < 0)
+				return ret;
+			if (param > PARAM_MAX_STACK)
 				ret = -EINVAL;
 			else {
 				f->fn = t->fetch[FETCH_MTD_stack];
@@ -752,8 +753,8 @@ static int __parse_probe_arg(char *arg, const struct fetch_type *t,
 		break;
 	case '@':	/* memory or symbol */
 		if (isdigit(arg[1])) {
-			ret = strict_strtoul(arg + 1, 0, &param);
-			if (ret)
+			ret = kstrtoul(arg + 1, 0, &param);
+			if (ret < 0)
 				break;
 			f->fn = t->fetch[FETCH_MTD_memory];
 			f->data = (void *)param;
@@ -772,11 +773,9 @@ static int __parse_probe_arg(char *arg, const struct fetch_type *t,
 		if (!tmp)
 			break;
 		*tmp = '\0';
-		ret = strict_strtol(arg + 1, 0, &offset);
-		if (ret)
+		ret = kstrtol(arg, 0, &offset);
+		if (ret < 0)
 			break;
-		if (arg[0] == '-')
-			offset = -offset;
 		arg = tmp + 1;
 		tmp = strrchr(arg, ')');
 		if (tmp) {
@@ -948,8 +947,8 @@ static int create_trace_probe(int argc, char **argv)
 			return -EINVAL;
 		}
 		/* an address specified */
-		ret = strict_strtoul(&argv[1][0], 0, (unsigned long *)&addr);
-		if (ret) {
+		ret = kstrtoul(&argv[1][0], 0, (unsigned long *)&addr);
+		if (ret < 0) {
 			pr_info("Failed to parse address.\n");
 			return ret;
 		}
diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
index 4c5dead..36ebd3b 100644
--- a/kernel/trace/trace_stack.c
+++ b/kernel/trace/trace_stack.c
@@ -153,7 +153,7 @@ static ssize_t
 stack_max_size_write(struct file *filp, const char __user *ubuf,
 		     size_t count, loff_t *ppos)
 {
-	long *ptr = filp->private_data;
+	unsigned long *ptr = filp->private_data;
 	unsigned long val, flags;
 	char buf[64];
 	int ret;
@@ -167,7 +167,7 @@ stack_max_size_write(struct file *filp, const char __user *ubuf,
 
 	buf[count] = 0;
 
-	ret = strict_strtoul(buf, 10, &val);
+	ret = kstrtoul(buf, 10, &val);
 	if (ret < 0)
 		return ret;
 
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 04/52] kstrtox: convert mm/
  2011-02-05 14:20 [PATCH 01/52] kstrtox: converting strings to integers done (hopefully) right Alexey Dobriyan
  2011-02-05 14:20 ` [PATCH 02/52] kstrtox: convert kernel/ Alexey Dobriyan
  2011-02-05 14:20 ` [PATCH 03/52] kstrtox: convert kernel/trace/ Alexey Dobriyan
@ 2011-02-05 14:20 ` Alexey Dobriyan
  2011-02-05 14:20 ` [PATCH 05/52] kstrtox: convert block/ Alexey Dobriyan
                   ` (47 subsequent siblings)
  50 siblings, 0 replies; 58+ messages in thread
From: Alexey Dobriyan @ 2011-02-05 14:20 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, adobriyan


Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
 include/linux/slub_def.h |    2 +-
 mm/huge_memory.c         |   35 ++++++++++++++++-------------------
 mm/hugetlb.c             |    8 ++++----
 mm/kmemleak.c            |    4 ++--
 mm/ksm.c                 |   28 ++++++++++------------------
 mm/slub.c                |   19 ++++++++++---------
 mm/vmscan.c              |   25 ++++++++++---------------
 7 files changed, 53 insertions(+), 68 deletions(-)

diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
index 8b6e8ae..aa128b9 100644
--- a/include/linux/slub_def.h
+++ b/include/linux/slub_def.h
@@ -94,7 +94,7 @@ struct kmem_cache {
 	/*
 	 * Defragmentation by allocating from a remote node.
 	 */
-	int remote_node_defrag_ratio;
+	unsigned int remote_node_defrag_ratio;
 #endif
 	struct kmem_cache_node *node[MAX_NUMNODES];
 };
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index b6c1ce3..665b8ff 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -331,14 +331,11 @@ static ssize_t scan_sleep_millisecs_store(struct kobject *kobj,
 					  struct kobj_attribute *attr,
 					  const char *buf, size_t count)
 {
-	unsigned long msecs;
 	int err;
 
-	err = strict_strtoul(buf, 10, &msecs);
-	if (err || msecs > UINT_MAX)
-		return -EINVAL;
-
-	khugepaged_scan_sleep_millisecs = msecs;
+	err = kstrtouint(buf, 10, &khugepaged_scan_sleep_millisecs);
+	if (err < 0)
+		return err;
 	wake_up_interruptible(&khugepaged_wait);
 
 	return count;
@@ -358,14 +355,11 @@ static ssize_t alloc_sleep_millisecs_store(struct kobject *kobj,
 					   struct kobj_attribute *attr,
 					   const char *buf, size_t count)
 {
-	unsigned long msecs;
 	int err;
 
-	err = strict_strtoul(buf, 10, &msecs);
-	if (err || msecs > UINT_MAX)
-		return -EINVAL;
-
-	khugepaged_alloc_sleep_millisecs = msecs;
+	err = kstrtouint(buf, 10, &khugepaged_alloc_sleep_millisecs);
+	if (err < 0)
+		return err;
 	wake_up_interruptible(&khugepaged_wait);
 
 	return count;
@@ -384,13 +378,14 @@ static ssize_t pages_to_scan_store(struct kobject *kobj,
 				   struct kobj_attribute *attr,
 				   const char *buf, size_t count)
 {
+	unsigned int pages;
 	int err;
-	unsigned long pages;
 
-	err = strict_strtoul(buf, 10, &pages);
-	if (err || !pages || pages > UINT_MAX)
+	err = kstrtouint(buf, 10, &pages);
+	if (err < 0)
+		return err;
+	if (pages == 0)
 		return -EINVAL;
-
 	khugepaged_pages_to_scan = pages;
 
 	return count;
@@ -452,11 +447,13 @@ static ssize_t khugepaged_max_ptes_none_store(struct kobject *kobj,
 					      struct kobj_attribute *attr,
 					      const char *buf, size_t count)
 {
+	unsigned int max_ptes_none;
 	int err;
-	unsigned long max_ptes_none;
 
-	err = strict_strtoul(buf, 10, &max_ptes_none);
-	if (err || max_ptes_none > HPAGE_PMD_NR-1)
+	err = kstrtouint(buf, 10, &max_ptes_none);
+	if (err < 0)
+		return err;
+	if (max_ptes_none > HPAGE_PMD_NR - 1)
 		return -EINVAL;
 
 	khugepaged_max_ptes_none = max_ptes_none;
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index bb0b7c1..92086ba 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -1374,8 +1374,8 @@ static ssize_t nr_hugepages_store_common(bool obey_mempolicy,
 	struct hstate *h;
 	NODEMASK_ALLOC(nodemask_t, nodes_allowed, GFP_KERNEL | __GFP_NORETRY);
 
-	err = strict_strtoul(buf, 10, &count);
-	if (err)
+	err = kstrtoul(buf, 10, &count);
+	if (err < 0)
 		goto out;
 
 	h = kobj_to_hstate(kobj, &nid);
@@ -1465,8 +1465,8 @@ static ssize_t nr_overcommit_hugepages_store(struct kobject *kobj,
 	if (h->order >= MAX_ORDER)
 		return -EINVAL;
 
-	err = strict_strtoul(buf, 10, &input);
-	if (err)
+	err = kstrtoul(buf, 10, &input);
+	if (err < 0)
 		return err;
 
 	spin_lock(&hugetlb_lock);
diff --git a/mm/kmemleak.c b/mm/kmemleak.c
index 84225f3..a2b3cbe 100644
--- a/mm/kmemleak.c
+++ b/mm/kmemleak.c
@@ -1560,9 +1560,9 @@ static ssize_t kmemleak_write(struct file *file, const char __user *user_buf,
 	else if (strncmp(buf, "scan=off", 8) == 0)
 		stop_scan_thread();
 	else if (strncmp(buf, "scan=", 5) == 0) {
-		unsigned long secs;
+		unsigned int secs;
 
-		ret = strict_strtoul(buf + 5, 0, &secs);
+		ret = kstrtouint(buf + 5, 0, &secs);
 		if (ret < 0)
 			goto out;
 		stop_scan_thread();
diff --git a/mm/ksm.c b/mm/ksm.c
index c2b2a94..07d08da 100644
--- a/mm/ksm.c
+++ b/mm/ksm.c
@@ -1842,15 +1842,11 @@ static ssize_t sleep_millisecs_store(struct kobject *kobj,
 				     struct kobj_attribute *attr,
 				     const char *buf, size_t count)
 {
-	unsigned long msecs;
 	int err;
 
-	err = strict_strtoul(buf, 10, &msecs);
-	if (err || msecs > UINT_MAX)
-		return -EINVAL;
-
-	ksm_thread_sleep_millisecs = msecs;
-
+	err = kstrtouint(buf, 10, &ksm_thread_sleep_millisecs);
+	if (err < 0)
+		return err;
 	return count;
 }
 KSM_ATTR(sleep_millisecs);
@@ -1866,14 +1862,10 @@ static ssize_t pages_to_scan_store(struct kobject *kobj,
 				   const char *buf, size_t count)
 {
 	int err;
-	unsigned long nr_pages;
-
-	err = strict_strtoul(buf, 10, &nr_pages);
-	if (err || nr_pages > UINT_MAX)
-		return -EINVAL;
-
-	ksm_thread_pages_to_scan = nr_pages;
 
+	err = kstrtouint(buf, 10, &ksm_thread_pages_to_scan);
+	if (err < 0)
+		return err;
 	return count;
 }
 KSM_ATTR(pages_to_scan);
@@ -1888,11 +1880,11 @@ static ssize_t run_store(struct kobject *kobj, struct kobj_attribute *attr,
 			 const char *buf, size_t count)
 {
 	int err;
-	unsigned long flags;
+	unsigned int flags;
 
-	err = strict_strtoul(buf, 10, &flags);
-	if (err || flags > UINT_MAX)
-		return -EINVAL;
+	err = kstrtouint(buf, 10, &flags);
+	if (err < 0)
+		return err;
 	if (flags > KSM_RUN_UNMERGE)
 		return -EINVAL;
 
diff --git a/mm/slub.c b/mm/slub.c
index e15aa7f..8dc7dd9 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -3904,11 +3904,11 @@ SLAB_ATTR_RO(objs_per_slab);
 static ssize_t order_store(struct kmem_cache *s,
 				const char *buf, size_t length)
 {
-	unsigned long order;
+	int order;
 	int err;
 
-	err = strict_strtoul(buf, 10, &order);
-	if (err)
+	err = kstrtoint(buf, 10, &order);
+	if (err < 0)
 		return err;
 
 	if (order > slub_max_order || order < slub_min_order)
@@ -3935,7 +3935,7 @@ static ssize_t min_partial_store(struct kmem_cache *s, const char *buf,
 	unsigned long min;
 	int err;
 
-	err = strict_strtoul(buf, 10, &min);
+	err = kstrtoul(buf, 10, &min);
 	if (err)
 		return err;
 
@@ -4192,21 +4192,22 @@ SLAB_ATTR(shrink);
 #ifdef CONFIG_NUMA
 static ssize_t remote_node_defrag_ratio_show(struct kmem_cache *s, char *buf)
 {
-	return sprintf(buf, "%d\n", s->remote_node_defrag_ratio / 10);
+	return sprintf(buf, "%u\n", s->remote_node_defrag_ratio / 10);
 }
 
 static ssize_t remote_node_defrag_ratio_store(struct kmem_cache *s,
 				const char *buf, size_t length)
 {
-	unsigned long ratio;
+	unsigned int ratio;
 	int err;
 
-	err = strict_strtoul(buf, 10, &ratio);
+	err = kstrtouint(buf, 10, &ratio);
 	if (err)
 		return err;
+	if (ratio > 100)
+		return -EINVAL;
 
-	if (ratio <= 100)
-		s->remote_node_defrag_ratio = ratio * 10;
+	s->remote_node_defrag_ratio = ratio * 10;
 
 	return length;
 }
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 148c6e6..7e00f77 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -3284,37 +3284,32 @@ int scan_unevictable_handler(struct ctl_table *table, int write,
  * per node 'scan_unevictable_pages' attribute.  On demand re-scan of
  * a specified node's per zone unevictable lists for evictable pages.
  */
-
-static ssize_t read_scan_unevictable_node(struct sys_device *dev,
-					  struct sysdev_attribute *attr,
-					  char *buf)
-{
-	return sprintf(buf, "0\n");	/* always zero; should fit... */
-}
-
 static ssize_t write_scan_unevictable_node(struct sys_device *dev,
 					   struct sysdev_attribute *attr,
 					const char *buf, size_t count)
 {
 	struct zone *node_zones = NODE_DATA(dev->id)->node_zones;
 	struct zone *zone;
-	unsigned long res;
-	unsigned long req = strict_strtoul(buf, 10, &res);
+	unsigned long val;
+	int rv;
 
-	if (!req)
-		return 1;	/* zero is no-op */
+	rv = kstrtoul(buf, 10, &val);
+	if (rv < 0)
+		return rv;
+	if (val == 0)
+		return count;
 
 	for (zone = node_zones; zone - node_zones < MAX_NR_ZONES; ++zone) {
 		if (!populated_zone(zone))
 			continue;
 		scan_zone_unevictable_pages(zone);
 	}
-	return 1;
+	return count;
 }
 
 
-static SYSDEV_ATTR(scan_unevictable_pages, S_IRUGO | S_IWUSR,
-			read_scan_unevictable_node,
+static SYSDEV_ATTR(scan_unevictable_pages, S_IWUSR,
+			NULL,
 			write_scan_unevictable_node);
 
 int scan_unevictable_register_node(struct node *node)
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 05/52] kstrtox: convert block/
  2011-02-05 14:20 [PATCH 01/52] kstrtox: converting strings to integers done (hopefully) right Alexey Dobriyan
                   ` (2 preceding siblings ...)
  2011-02-05 14:20 ` [PATCH 04/52] kstrtox: convert mm/ Alexey Dobriyan
@ 2011-02-05 14:20 ` Alexey Dobriyan
  2011-02-05 14:20 ` [PATCH 06/52] kstrtox: convert security/ Alexey Dobriyan
                   ` (46 subsequent siblings)
  50 siblings, 0 replies; 58+ messages in thread
From: Alexey Dobriyan @ 2011-02-05 14:20 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, adobriyan


Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
 block/blk-cgroup.c |   47 ++++++++++++++++++++++++-----------------------
 1 files changed, 24 insertions(+), 23 deletions(-)

diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index 455768a..d94110e 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -656,10 +656,9 @@ static int blkio_policy_parse_and_set(char *buf,
 {
 	char *s[4], *p, *major_s = NULL, *minor_s = NULL;
 	int ret;
-	unsigned long major, minor, temp;
+	unsigned int major, minor;
 	int i = 0;
 	dev_t dev;
-	u64 bps, iops;
 
 	memset(s, 0, sizeof(s));
 
@@ -687,15 +686,15 @@ static int blkio_policy_parse_and_set(char *buf,
 	if (!minor_s)
 		return -EINVAL;
 
-	ret = strict_strtoul(major_s, 10, &major);
-	if (ret)
-		return -EINVAL;
-
-	ret = strict_strtoul(minor_s, 10, &minor);
+	ret = kstrtouint(major_s, 10, &major);
+	if (ret < 0)
+		return ret;
+	ret = kstrtouint(minor_s, 10, &minor);
 	if (ret)
-		return -EINVAL;
-
+		return ret;
 	dev = MKDEV(major, minor);
+	if (MAJOR(dev) != major || MINOR(dev) != minor)
+		return -EINVAL;
 
 	ret = blkio_check_dev_num(dev);
 	if (ret)
@@ -707,40 +706,42 @@ static int blkio_policy_parse_and_set(char *buf,
 		return -EINVAL;
 
 	switch (plid) {
+		unsigned int weigth;
+
 	case BLKIO_POLICY_PROP:
-		ret = strict_strtoul(s[1], 10, &temp);
-		if (ret || (temp < BLKIO_WEIGHT_MIN && temp > 0) ||
-			temp > BLKIO_WEIGHT_MAX)
+		ret = kstrtouint(s[1], 10, &weigth);
+		if (ret < 0)
+			return ret;
+		if (weigth < BLKIO_WEIGHT_MIN || weigth > BLKIO_WEIGHT_MAX)
 			return -EINVAL;
 
 		newpn->plid = plid;
 		newpn->fileid = fileid;
-		newpn->val.weight = temp;
+		newpn->val.weight = weigth;
 		break;
 	case BLKIO_POLICY_THROTL:
 		switch(fileid) {
+			unsigned int iops;
+
 		case BLKIO_THROTL_read_bps_device:
 		case BLKIO_THROTL_write_bps_device:
-			ret = strict_strtoull(s[1], 10, &bps);
-			if (ret)
-				return -EINVAL;
-
 			newpn->plid = plid;
 			newpn->fileid = fileid;
-			newpn->val.bps = bps;
+			ret = kstrtou64(s[1], 10, &newpn->val.bps);
+			if (ret < 0)
+				return ret;
 			break;
 		case BLKIO_THROTL_read_iops_device:
 		case BLKIO_THROTL_write_iops_device:
-			ret = strict_strtoull(s[1], 10, &iops);
-			if (ret)
-				return -EINVAL;
-
+			ret = kstrtouint(s[1], 10, &iops);
+			if (ret < 0)
+				return ret;
 			if (iops > THROTL_IOPS_MAX)
 				return -EINVAL;
 
 			newpn->plid = plid;
 			newpn->fileid = fileid;
-			newpn->val.iops = (unsigned int)iops;
+			newpn->val.iops = iops;
 			break;
 		}
 		break;
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 06/52] kstrtox: convert security/
  2011-02-05 14:20 [PATCH 01/52] kstrtox: converting strings to integers done (hopefully) right Alexey Dobriyan
                   ` (3 preceding siblings ...)
  2011-02-05 14:20 ` [PATCH 05/52] kstrtox: convert block/ Alexey Dobriyan
@ 2011-02-05 14:20 ` Alexey Dobriyan
  2011-02-05 14:20 ` [PATCH 07/52] kstrtox: convert fs/fuse/ Alexey Dobriyan
                   ` (45 subsequent siblings)
  50 siblings, 0 replies; 58+ messages in thread
From: Alexey Dobriyan @ 2011-02-05 14:20 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, adobriyan


Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
 security/apparmor/lsm.c             |    2 +-
 security/integrity/ima/ima_audit.c  |    2 +-
 security/integrity/ima/ima_policy.c |   15 ++++-----------
 security/keys/encrypted.c           |    8 +++++---
 security/keys/trusted.c             |   23 +++++++++++------------
 security/selinux/hooks.c            |    4 ++--
 security/selinux/selinuxfs.c        |    2 +-
 security/tomoyo/common.c            |    8 +++++---
 8 files changed, 30 insertions(+), 34 deletions(-)

diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
index b7106f1..990ff86 100644
--- a/security/apparmor/lsm.c
+++ b/security/apparmor/lsm.c
@@ -754,7 +754,7 @@ module_param_named(enabled, apparmor_enabled, aabool, S_IRUSR);
 static int __init apparmor_enabled_setup(char *str)
 {
 	unsigned long enabled;
-	int error = strict_strtoul(str, 0, &enabled);
+	int error = kstrtoul(str, 0, &enabled);
 	if (!error)
 		apparmor_enabled = enabled ? 1 : 0;
 	return 1;
diff --git a/security/integrity/ima/ima_audit.c b/security/integrity/ima/ima_audit.c
index c5c5a72..b4a203c 100644
--- a/security/integrity/ima/ima_audit.c
+++ b/security/integrity/ima/ima_audit.c
@@ -24,7 +24,7 @@ static int __init ima_audit_setup(char *str)
 {
 	unsigned long audit;
 
-	if (!strict_strtoul(str, 0, &audit))
+	if (!kstrtoul(str, 0, &audit))
 		ima_audit = audit ? 1 : 0;
 	return 1;
 }
diff --git a/security/integrity/ima/ima_policy.c b/security/integrity/ima/ima_policy.c
index d661afb..3d5c491 100644
--- a/security/integrity/ima/ima_policy.c
+++ b/security/integrity/ima/ima_policy.c
@@ -278,7 +278,6 @@ static int ima_parse_rule(char *rule, struct ima_measure_rule_entry *entry)
 	while ((p = strsep(&rule, " \t")) != NULL) {
 		substring_t args[MAX_OPT_ARGS];
 		int token;
-		unsigned long lnum;
 
 		if (result < 0)
 			break;
@@ -349,8 +348,7 @@ static int ima_parse_rule(char *rule, struct ima_measure_rule_entry *entry)
 				break;
 			}
 
-			result = strict_strtoul(args[0].from, 16,
-						&entry->fsmagic);
+			result = kstrtoul(args[0].from, 16, &entry->fsmagic);
 			if (!result)
 				entry->flags |= IMA_FSMAGIC;
 			break;
@@ -362,14 +360,9 @@ static int ima_parse_rule(char *rule, struct ima_measure_rule_entry *entry)
 				break;
 			}
 
-			result = strict_strtoul(args[0].from, 10, &lnum);
-			if (!result) {
-				entry->uid = (uid_t) lnum;
-				if (entry->uid != lnum)
-					result = -EINVAL;
-				else
-					entry->flags |= IMA_UID;
-			}
+			result = kstrtou32(args[0].from, 10, &entry->uid);
+			if (!result)
+				entry->flags |= IMA_UID;
 			break;
 		case Opt_obj_user:
 			ima_log_string(ab, "obj_user", args[0].from);
diff --git a/security/keys/encrypted.c b/security/keys/encrypted.c
index 9e7e4ce..859e1e8 100644
--- a/security/keys/encrypted.c
+++ b/security/keys/encrypted.c
@@ -521,11 +521,13 @@ static struct encrypted_key_payload *encrypted_key_alloc(struct key *key,
 	unsigned short datablob_len;
 	unsigned short decrypted_datalen;
 	unsigned int encrypted_datalen;
-	long dlen;
+	unsigned int dlen;
 	int ret;
 
-	ret = strict_strtol(datalen, 10, &dlen);
-	if (ret < 0 || dlen < MIN_DATA_SIZE || dlen > MAX_DATA_SIZE)
+	ret = kstrtouint(datalen, 10, &dlen);
+	if (ret < 0)
+		return ERR_PTR(ret);
+	if (dlen < MIN_DATA_SIZE || dlen > MAX_DATA_SIZE)
 		return ERR_PTR(-EINVAL);
 
 	decrypted_datalen = dlen;
diff --git a/security/keys/trusted.c b/security/keys/trusted.c
index 83fc92e..ac59eb9 100644
--- a/security/keys/trusted.c
+++ b/security/keys/trusted.c
@@ -766,8 +766,6 @@ static int getoptions(char *c, struct trusted_key_payload *pay,
 	char *p = c;
 	int token;
 	int res;
-	unsigned long handle;
-	unsigned long lock;
 
 	while ((p = strsep(&c, " \t"))) {
 		if (*p == '\0' || *p == ' ' || *p == '\t')
@@ -782,11 +780,10 @@ static int getoptions(char *c, struct trusted_key_payload *pay,
 			hex2bin(opt->pcrinfo, args[0].from, opt->pcrinfo_len);
 			break;
 		case Opt_keyhandle:
-			res = strict_strtoul(args[0].from, 16, &handle);
-			if (res < 0)
-				return -EINVAL;
 			opt->keytype = SEAL_keytype;
-			opt->keyhandle = handle;
+			res = kstrtou32(args[0].from, 16, &opt->keyhandle);
+			if (res < 0)
+				return res;
 			break;
 		case Opt_keyauth:
 			if (strlen(args[0].from) != 2 * SHA1_DIGEST_SIZE)
@@ -805,10 +802,9 @@ static int getoptions(char *c, struct trusted_key_payload *pay,
 				return -EINVAL;
 			break;
 		case Opt_pcrlock:
-			res = strict_strtoul(args[0].from, 10, &lock);
+			res = kstrtoint(args[0].from, 10, &opt->pcrlock);
 			if (res < 0)
-				return -EINVAL;
-			opt->pcrlock = lock;
+				return res;
 			break;
 		default:
 			return -EINVAL;
@@ -827,7 +823,6 @@ static int datablob_parse(char *datablob, struct trusted_key_payload *p,
 			  struct trusted_key_options *o)
 {
 	substring_t args[MAX_OPT_ARGS];
-	long keylen;
 	int ret = -EINVAL;
 	int key_cmd;
 	char *c;
@@ -838,13 +833,17 @@ static int datablob_parse(char *datablob, struct trusted_key_payload *p,
 		return -EINVAL;
 	key_cmd = match_token(c, key_tokens, args);
 	switch (key_cmd) {
+		unsigned int keylen;
+
 	case Opt_new:
 		/* first argument is key size */
 		c = strsep(&datablob, " \t");
 		if (!c)
 			return -EINVAL;
-		ret = strict_strtol(c, 10, &keylen);
-		if (ret < 0 || keylen < MIN_KEY_SIZE || keylen > MAX_KEY_SIZE)
+		ret = kstrtouint(c, 10, &keylen);
+		if (ret < 0)
+			return ret;
+		if (keylen < MIN_KEY_SIZE || keylen > MAX_KEY_SIZE)
 			return -EINVAL;
 		p->key_len = keylen;
 		ret = getoptions(datablob, p, o);
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index e276eb4..521b2b9 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -101,7 +101,7 @@ int selinux_enforcing;
 static int __init enforcing_setup(char *str)
 {
 	unsigned long enforcing;
-	if (!strict_strtoul(str, 0, &enforcing))
+	if (!kstrtoul(str, 0, &enforcing))
 		selinux_enforcing = enforcing ? 1 : 0;
 	return 1;
 }
@@ -114,7 +114,7 @@ int selinux_enabled = CONFIG_SECURITY_SELINUX_BOOTPARAM_VALUE;
 static int __init selinux_enabled_setup(char *str)
 {
 	unsigned long enabled;
-	if (!strict_strtoul(str, 0, &enabled))
+	if (!kstrtoul(str, 0, &enabled))
 		selinux_enabled = enabled ? 1 : 0;
 	return 1;
 }
diff --git a/security/selinux/selinuxfs.c b/security/selinux/selinuxfs.c
index ea39cb7..31c63f5 100644
--- a/security/selinux/selinuxfs.c
+++ b/security/selinux/selinuxfs.c
@@ -50,7 +50,7 @@ unsigned int selinux_checkreqprot = CONFIG_SECURITY_SELINUX_CHECKREQPROT_VALUE;
 static int __init checkreqprot_setup(char *str)
 {
 	unsigned long checkreqprot;
-	if (!strict_strtoul(str, 0, &checkreqprot))
+	if (!kstrtoul(str, 0, &checkreqprot))
 		selinux_checkreqprot = checkreqprot ? 1 : 0;
 	return 1;
 }
diff --git a/security/tomoyo/common.c b/security/tomoyo/common.c
index 7556315..1096c81 100644
--- a/security/tomoyo/common.c
+++ b/security/tomoyo/common.c
@@ -1091,14 +1091,16 @@ static int tomoyo_write_domain_profile(struct tomoyo_io_buffer *head)
 	char *data = head->write_buf;
 	char *cp = strchr(data, ' ');
 	struct tomoyo_domain_info *domain;
-	unsigned long profile;
+	unsigned int profile;
+	int rv;
 
 	if (!cp)
 		return -EINVAL;
 	*cp = '\0';
 	domain = tomoyo_find_domain(cp + 1);
-	if (strict_strtoul(data, 10, &profile))
-		return -EINVAL;
+	rv = kstrtouint(data, 10, &profile);
+	if (rv < 0)
+		return rv;
 	if (domain && profile < TOMOYO_MAX_PROFILES
 	    && (tomoyo_profile_ptr[profile] || !tomoyo_policy_loaded))
 		domain->profile = (u8) profile;
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 07/52] kstrtox: convert fs/fuse/
  2011-02-05 14:20 [PATCH 01/52] kstrtox: converting strings to integers done (hopefully) right Alexey Dobriyan
                   ` (4 preceding siblings ...)
  2011-02-05 14:20 ` [PATCH 06/52] kstrtox: convert security/ Alexey Dobriyan
@ 2011-02-05 14:20 ` Alexey Dobriyan
  2011-02-05 14:20 ` [PATCH 08/52] kstrtox: convert fs/nfs/ Alexey Dobriyan
                   ` (44 subsequent siblings)
  50 siblings, 0 replies; 58+ messages in thread
From: Alexey Dobriyan @ 2011-02-05 14:20 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, adobriyan


Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
 fs/fuse/control.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/fuse/control.c b/fs/fuse/control.c
index 85542a7..b916b34 100644
--- a/fs/fuse/control.c
+++ b/fs/fuse/control.c
@@ -74,7 +74,7 @@ static ssize_t fuse_conn_limit_write(struct file *file, const char __user *buf,
 				     size_t count, loff_t *ppos, unsigned *val,
 				     unsigned global_limit)
 {
-	unsigned long t;
+	unsigned int t;
 	char tmp[32];
 	unsigned limit = (1 << 16) - 1;
 	int err;
@@ -87,7 +87,7 @@ static ssize_t fuse_conn_limit_write(struct file *file, const char __user *buf,
 
 	tmp[count] = '\0';
 
-	err = strict_strtoul(tmp, 0, &t);
+	err = kstrtouint(tmp, 0, &t);
 	if (err)
 		return err;
 
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 08/52] kstrtox: convert fs/nfs/
  2011-02-05 14:20 [PATCH 01/52] kstrtox: converting strings to integers done (hopefully) right Alexey Dobriyan
                   ` (5 preceding siblings ...)
  2011-02-05 14:20 ` [PATCH 07/52] kstrtox: convert fs/fuse/ Alexey Dobriyan
@ 2011-02-05 14:20 ` Alexey Dobriyan
  2011-02-05 14:20 ` [PATCH 09/52] kstrtox: convert fs/proc/ Alexey Dobriyan
                   ` (43 subsequent siblings)
  50 siblings, 0 replies; 58+ messages in thread
From: Alexey Dobriyan @ 2011-02-05 14:20 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, adobriyan


Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
 fs/nfs/callback.c |    8 +++--
 fs/nfs/idmap.c    |   12 +++------
 fs/nfs/internal.h |    8 +++---
 fs/nfs/super.c    |   73 ++++++++++++++++++++++++-----------------------------
 4 files changed, 46 insertions(+), 55 deletions(-)

diff --git a/fs/nfs/callback.c b/fs/nfs/callback.c
index e3d2942..0c8b5d8 100644
--- a/fs/nfs/callback.c
+++ b/fs/nfs/callback.c
@@ -44,13 +44,15 @@ unsigned short nfs_callback_tcpport6;
 
 static int param_set_portnr(const char *val, const struct kernel_param *kp)
 {
-	unsigned long num;
+	unsigned int num;
 	int ret;
 
 	if (!val)
 		return -EINVAL;
-	ret = strict_strtoul(val, 0, &num);
-	if (ret == -EINVAL || num > NFS_CALLBACK_MAXPORTNR)
+	ret = kstrtouint(val, 0, &num);
+	if (ret < 0)
+		return ret;
+	if (num > NFS_CALLBACK_MAXPORTNR)
 		return -EINVAL;
 	*((unsigned int *)kp->arg) = num;
 	return 0;
diff --git a/fs/nfs/idmap.c b/fs/nfs/idmap.c
index 1869688..714def8 100644
--- a/fs/nfs/idmap.c
+++ b/fs/nfs/idmap.c
@@ -205,17 +205,13 @@ static int nfs_idmap_lookup_id(const char *name, size_t namelen,
 				const char *type, __u32 *id)
 {
 	char id_str[NFS_UINT_MAXLEN];
-	long id_long;
 	ssize_t data_size;
-	int ret = 0;
+	int ret;
 
 	data_size = nfs_idmap_request_key(name, namelen, type, id_str, NFS_UINT_MAXLEN);
-	if (data_size <= 0) {
-		ret = -EINVAL;
-	} else {
-		ret = strict_strtol(id_str, 10, &id_long);
-		*id = (__u32)id_long;
-	}
+	ret = -EINVAL;
+	if (data_size > 0)
+		ret = kstrtou32(id_str, 10, id);
 	return ret;
 }
 
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
index cf9fdbd..6415783 100644
--- a/fs/nfs/internal.h
+++ b/fs/nfs/internal.h
@@ -73,11 +73,11 @@ struct nfs_clone_mount {
  */
 struct nfs_parsed_mount_data {
 	int			flags;
-	int			rsize, wsize;
-	int			timeo, retrans;
-	int			acregmin, acregmax,
+	unsigned int		rsize, wsize;
+	unsigned int		timeo, retrans;
+	unsigned int		acregmin, acregmax,
 				acdirmin, acdirmax;
-	int			namlen;
+	unsigned int		namlen;
 	unsigned int		options;
 	unsigned int		bsize;
 	unsigned int		auth_flavor_len;
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index b68c860..1902bd4 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -1015,7 +1015,8 @@ static int nfs_parse_mount_options(char *raw,
 
 	while ((p = strsep(&raw, ",")) != NULL) {
 		substring_t args[MAX_OPT_ARGS];
-		unsigned long option;
+		unsigned int val_uint;
+		u16 val_u16;
 		int token;
 
 		if (!*p)
@@ -1130,154 +1131,146 @@ static int nfs_parse_mount_options(char *raw,
 			string = match_strdup(args);
 			if (string == NULL)
 				goto out_nomem;
-			rc = strict_strtoul(string, 10, &option);
+			rc = kstrtou16(string, 10, &val_u16);
 			kfree(string);
-			if (rc != 0 || option > USHRT_MAX)
+			if (rc != 0)
 				goto out_invalid_value;
-			mnt->nfs_server.port = option;
+			mnt->nfs_server.port = val_u16;
 			break;
 		case Opt_rsize:
 			string = match_strdup(args);
 			if (string == NULL)
 				goto out_nomem;
-			rc = strict_strtoul(string, 10, &option);
+			rc = kstrtouint(string, 10, &mnt->rsize);
 			kfree(string);
 			if (rc != 0)
 				goto out_invalid_value;
-			mnt->rsize = option;
 			break;
 		case Opt_wsize:
 			string = match_strdup(args);
 			if (string == NULL)
 				goto out_nomem;
-			rc = strict_strtoul(string, 10, &option);
+			rc = kstrtouint(string, 10, &mnt->wsize);
 			kfree(string);
 			if (rc != 0)
 				goto out_invalid_value;
-			mnt->wsize = option;
 			break;
 		case Opt_bsize:
 			string = match_strdup(args);
 			if (string == NULL)
 				goto out_nomem;
-			rc = strict_strtoul(string, 10, &option);
+			rc = kstrtouint(string, 10, &mnt->bsize);
 			kfree(string);
 			if (rc != 0)
 				goto out_invalid_value;
-			mnt->bsize = option;
 			break;
 		case Opt_timeo:
 			string = match_strdup(args);
 			if (string == NULL)
 				goto out_nomem;
-			rc = strict_strtoul(string, 10, &option);
+			rc = kstrtouint(string, 10, &val_uint);
 			kfree(string);
-			if (rc != 0 || option == 0)
+			if (rc != 0 || val_uint == 0)
 				goto out_invalid_value;
-			mnt->timeo = option;
+			mnt->timeo = val_uint;
 			break;
 		case Opt_retrans:
 			string = match_strdup(args);
 			if (string == NULL)
 				goto out_nomem;
-			rc = strict_strtoul(string, 10, &option);
+			rc = kstrtouint(string, 10, &val_uint);
 			kfree(string);
-			if (rc != 0 || option == 0)
+			if (rc != 0 || val_uint == 0)
 				goto out_invalid_value;
-			mnt->retrans = option;
+			mnt->retrans = val_uint;
 			break;
 		case Opt_acregmin:
 			string = match_strdup(args);
 			if (string == NULL)
 				goto out_nomem;
-			rc = strict_strtoul(string, 10, &option);
+			rc = kstrtouint(string, 10, &mnt->acregmin);
 			kfree(string);
 			if (rc != 0)
 				goto out_invalid_value;
-			mnt->acregmin = option;
 			break;
 		case Opt_acregmax:
 			string = match_strdup(args);
 			if (string == NULL)
 				goto out_nomem;
-			rc = strict_strtoul(string, 10, &option);
+			rc = kstrtouint(string, 10, &mnt->acregmax);
 			kfree(string);
 			if (rc != 0)
 				goto out_invalid_value;
-			mnt->acregmax = option;
 			break;
 		case Opt_acdirmin:
 			string = match_strdup(args);
 			if (string == NULL)
 				goto out_nomem;
-			rc = strict_strtoul(string, 10, &option);
+			rc = kstrtouint(string, 10, &mnt->acdirmin);
 			kfree(string);
 			if (rc != 0)
 				goto out_invalid_value;
-			mnt->acdirmin = option;
 			break;
 		case Opt_acdirmax:
 			string = match_strdup(args);
 			if (string == NULL)
 				goto out_nomem;
-			rc = strict_strtoul(string, 10, &option);
+			rc = kstrtouint(string, 10, &mnt->acdirmax);
 			kfree(string);
 			if (rc != 0)
 				goto out_invalid_value;
-			mnt->acdirmax = option;
 			break;
 		case Opt_actimeo:
 			string = match_strdup(args);
 			if (string == NULL)
 				goto out_nomem;
-			rc = strict_strtoul(string, 10, &option);
+			rc = kstrtouint(string, 10, &val_uint);
 			kfree(string);
 			if (rc != 0)
 				goto out_invalid_value;
 			mnt->acregmin = mnt->acregmax =
-			mnt->acdirmin = mnt->acdirmax = option;
+			mnt->acdirmin = mnt->acdirmax = val_uint;
 			break;
 		case Opt_namelen:
 			string = match_strdup(args);
 			if (string == NULL)
 				goto out_nomem;
-			rc = strict_strtoul(string, 10, &option);
+			rc = kstrtouint(string, 10, &mnt->namlen);
 			kfree(string);
 			if (rc != 0)
 				goto out_invalid_value;
-			mnt->namlen = option;
 			break;
 		case Opt_mountport:
 			string = match_strdup(args);
 			if (string == NULL)
 				goto out_nomem;
-			rc = strict_strtoul(string, 10, &option);
+			rc = kstrtou16(string, 10, &val_u16);
 			kfree(string);
-			if (rc != 0 || option > USHRT_MAX)
+			if (rc != 0)
 				goto out_invalid_value;
-			mnt->mount_server.port = option;
+			mnt->mount_server.port = val_u16;
 			break;
 		case Opt_mountvers:
 			string = match_strdup(args);
 			if (string == NULL)
 				goto out_nomem;
-			rc = strict_strtoul(string, 10, &option);
+			rc = kstrtouint(string, 10, &val_uint);
 			kfree(string);
 			if (rc != 0 ||
-			    option < NFS_MNT_VERSION ||
-			    option > NFS_MNT3_VERSION)
+			    val_uint < NFS_MNT_VERSION ||
+			    val_uint > NFS_MNT3_VERSION)
 				goto out_invalid_value;
-			mnt->mount_server.version = option;
+			mnt->mount_server.version = val_uint;
 			break;
 		case Opt_nfsvers:
 			string = match_strdup(args);
 			if (string == NULL)
 				goto out_nomem;
-			rc = strict_strtoul(string, 10, &option);
+			rc = kstrtouint(string, 10, &val_uint);
 			kfree(string);
 			if (rc != 0)
 				goto out_invalid_value;
-			switch (option) {
+			switch (val_uint) {
 			case NFS2_VERSION:
 				mnt->flags &= ~NFS_MOUNT_VER3;
 				mnt->version = 2;
@@ -1298,13 +1291,13 @@ static int nfs_parse_mount_options(char *raw,
 			string = match_strdup(args);
 			if (string == NULL)
 				goto out_nomem;
-			rc = strict_strtoul(string, 10, &option);
+			rc = kstrtouint(string, 10, &val_uint);
 			kfree(string);
 			if (rc != 0)
 				goto out_invalid_value;
-			if (option > NFS4_MAX_MINOR_VERSION)
+			if (val_uint > NFS4_MAX_MINOR_VERSION)
 				goto out_invalid_value;
-			mnt->minorversion = option;
+			mnt->minorversion = val_uint;
 			break;
 
 		/*
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 09/52] kstrtox: convert fs/proc/
  2011-02-05 14:20 [PATCH 01/52] kstrtox: converting strings to integers done (hopefully) right Alexey Dobriyan
                   ` (6 preceding siblings ...)
  2011-02-05 14:20 ` [PATCH 08/52] kstrtox: convert fs/nfs/ Alexey Dobriyan
@ 2011-02-05 14:20 ` Alexey Dobriyan
  2011-02-05 14:20 ` [PATCH 10/52] kstrtox: convert drivers/acpi/ Alexey Dobriyan
                   ` (42 subsequent siblings)
  50 siblings, 0 replies; 58+ messages in thread
From: Alexey Dobriyan @ 2011-02-05 14:20 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, adobriyan


Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
 fs/proc/base.c           |   21 ++++++++++-----------
 fs/proc/task_mmu.c       |    8 +++++---
 include/linux/sched.h    |    2 +-
 kernel/sched_autogroup.c |   12 ++++++------
 4 files changed, 22 insertions(+), 21 deletions(-)

diff --git a/fs/proc/base.c b/fs/proc/base.c
index 9d096e8..43c3941 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -1005,7 +1005,7 @@ static ssize_t oom_adjust_write(struct file *file, const char __user *buf,
 {
 	struct task_struct *task;
 	char buffer[PROC_NUMBUF];
-	long oom_adjust;
+	int oom_adjust;
 	unsigned long flags;
 	int err;
 
@@ -1017,8 +1017,8 @@ static ssize_t oom_adjust_write(struct file *file, const char __user *buf,
 		goto out;
 	}
 
-	err = strict_strtol(strstrip(buffer), 0, &oom_adjust);
-	if (err)
+	err = kstrtoint(strstrip(buffer), 0, &oom_adjust);
+	if (err < 0)
 		goto out;
 	if ((oom_adjust < OOM_ADJUST_MIN || oom_adjust > OOM_ADJUST_MAX) &&
 	     oom_adjust != OOM_DISABLE) {
@@ -1114,7 +1114,7 @@ static ssize_t oom_score_adj_write(struct file *file, const char __user *buf,
 	struct task_struct *task;
 	char buffer[PROC_NUMBUF];
 	unsigned long flags;
-	long oom_score_adj;
+	int oom_score_adj;
 	int err;
 
 	memset(buffer, 0, sizeof(buffer));
@@ -1125,8 +1125,8 @@ static ssize_t oom_score_adj_write(struct file *file, const char __user *buf,
 		goto out;
 	}
 
-	err = strict_strtol(strstrip(buffer), 0, &oom_score_adj);
-	if (err)
+	err = kstrtoint(strstrip(buffer), 0, &oom_score_adj);
+	if (err < 0)
 		goto out;
 	if (oom_score_adj < OOM_SCORE_ADJ_MIN ||
 			oom_score_adj > OOM_SCORE_ADJ_MAX) {
@@ -1414,7 +1414,7 @@ sched_autogroup_write(struct file *file, const char __user *buf,
 	struct inode *inode = file->f_path.dentry->d_inode;
 	struct task_struct *p;
 	char buffer[PROC_NUMBUF];
-	long nice;
+	int nice;
 	int err;
 
 	memset(buffer, 0, sizeof(buffer));
@@ -1423,16 +1423,15 @@ sched_autogroup_write(struct file *file, const char __user *buf,
 	if (copy_from_user(buffer, buf, count))
 		return -EFAULT;
 
-	err = strict_strtol(strstrip(buffer), 0, &nice);
+	err = kstrtoint(strstrip(buffer), 0, &nice);
 	if (err)
-		return -EINVAL;
+		return err;
 
 	p = get_proc_task(inode);
 	if (!p)
 		return -ESRCH;
 
-	err = nice;
-	err = proc_sched_autogroup_set_nice(p, &err);
+	err = proc_sched_autogroup_set_nice(p, nice);
 	if (err)
 		count = err;
 
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index 60b9148..b47c827 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -497,15 +497,17 @@ static ssize_t clear_refs_write(struct file *file, const char __user *buf,
 	char buffer[PROC_NUMBUF];
 	struct mm_struct *mm;
 	struct vm_area_struct *vma;
-	long type;
+	int type;
+	int rv;
 
 	memset(buffer, 0, sizeof(buffer));
 	if (count > sizeof(buffer) - 1)
 		count = sizeof(buffer) - 1;
 	if (copy_from_user(buffer, buf, count))
 		return -EFAULT;
-	if (strict_strtol(strstrip(buffer), 10, &type))
-		return -EINVAL;
+	rv = kstrtoint(strstrip(buffer), 10, &type);
+	if (rv < 0)
+		return rv;
 	if (type < CLEAR_REFS_ALL || type > CLEAR_REFS_MAPPED)
 		return -EINVAL;
 	task = get_proc_task(file->f_path.dentry->d_inode);
diff --git a/include/linux/sched.h b/include/linux/sched.h
index d747f94..762eb38 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1956,7 +1956,7 @@ extern void sched_autogroup_fork(struct signal_struct *sig);
 extern void sched_autogroup_exit(struct signal_struct *sig);
 #ifdef CONFIG_PROC_FS
 extern void proc_sched_autogroup_show_task(struct task_struct *p, struct seq_file *m);
-extern int proc_sched_autogroup_set_nice(struct task_struct *p, int *nice);
+extern int proc_sched_autogroup_set_nice(struct task_struct *p, int nice);
 #endif
 #else
 static inline void sched_autogroup_create_attach(struct task_struct *p) { }
diff --git a/kernel/sched_autogroup.c b/kernel/sched_autogroup.c
index 9fb6562..4b14c36 100644
--- a/kernel/sched_autogroup.c
+++ b/kernel/sched_autogroup.c
@@ -209,20 +209,20 @@ __setup("noautogroup", setup_autogroup);
 
 #ifdef CONFIG_PROC_FS
 
-int proc_sched_autogroup_set_nice(struct task_struct *p, int *nice)
+int proc_sched_autogroup_set_nice(struct task_struct *p, int nice)
 {
 	static unsigned long next = INITIAL_JIFFIES;
 	struct autogroup *ag;
 	int err;
 
-	if (*nice < -20 || *nice > 19)
+	if (nice < -20 || nice > 19)
 		return -EINVAL;
 
-	err = security_task_setnice(current, *nice);
+	err = security_task_setnice(current, nice);
 	if (err)
 		return err;
 
-	if (*nice < 0 && !can_nice(current, *nice))
+	if (nice < 0 && !can_nice(current, nice))
 		return -EPERM;
 
 	/* this is a heavy operation taking global locks.. */
@@ -233,9 +233,9 @@ int proc_sched_autogroup_set_nice(struct task_struct *p, int *nice)
 	ag = autogroup_task_get(p);
 
 	down_write(&ag->lock);
-	err = sched_group_set_shares(ag->tg, prio_to_weight[*nice + 20]);
+	err = sched_group_set_shares(ag->tg, prio_to_weight[nice + 20]);
 	if (!err)
-		ag->nice = *nice;
+		ag->nice = nice;
 	up_write(&ag->lock);
 
 	autogroup_kref_put(ag);
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 10/52] kstrtox: convert drivers/acpi/
  2011-02-05 14:20 [PATCH 01/52] kstrtox: converting strings to integers done (hopefully) right Alexey Dobriyan
                   ` (7 preceding siblings ...)
  2011-02-05 14:20 ` [PATCH 09/52] kstrtox: convert fs/proc/ Alexey Dobriyan
@ 2011-02-05 14:20 ` Alexey Dobriyan
  2011-02-05 14:20 ` [PATCH 11/52] kstrtox: convert drivers/ata/ Alexey Dobriyan
                   ` (41 subsequent siblings)
  50 siblings, 0 replies; 58+ messages in thread
From: Alexey Dobriyan @ 2011-02-05 14:20 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, adobriyan


Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
 drivers/acpi/acpi_pad.c    |   27 ++++++++++++++++++---------
 drivers/acpi/power_meter.c |   16 +++++++---------
 2 files changed, 25 insertions(+), 18 deletions(-)

diff --git a/drivers/acpi/acpi_pad.c b/drivers/acpi/acpi_pad.c
index 6afceb3..20d1c2d 100644
--- a/drivers/acpi/acpi_pad.c
+++ b/drivers/acpi/acpi_pad.c
@@ -284,9 +284,12 @@ static uint32_t acpi_pad_idle_cpus_num(void)
 static ssize_t acpi_pad_rrtime_store(struct device *dev,
 	struct device_attribute *attr, const char *buf, size_t count)
 {
-	unsigned long num;
-	if (strict_strtoul(buf, 0, &num))
-		return -EINVAL;
+	unsigned int num;
+	int rv;
+
+	rv = kstrtouint(buf, 0, &num);
+	if (rv < 0)
+		return rv;
 	if (num < 1 || num >= 100)
 		return -EINVAL;
 	mutex_lock(&isolated_cpus_lock);
@@ -307,9 +310,12 @@ static DEVICE_ATTR(rrtime, S_IRUGO|S_IWUSR,
 static ssize_t acpi_pad_idlepct_store(struct device *dev,
 	struct device_attribute *attr, const char *buf, size_t count)
 {
-	unsigned long num;
-	if (strict_strtoul(buf, 0, &num))
-		return -EINVAL;
+	unsigned int num;
+	int rv;
+
+	rv = kstrtouint(buf, 0, &num);
+	if (rv < 0)
+		return rv;
 	if (num < 1 || num >= 100)
 		return -EINVAL;
 	mutex_lock(&isolated_cpus_lock);
@@ -330,9 +336,12 @@ static DEVICE_ATTR(idlepct, S_IRUGO|S_IWUSR,
 static ssize_t acpi_pad_idlecpus_store(struct device *dev,
 	struct device_attribute *attr, const char *buf, size_t count)
 {
-	unsigned long num;
-	if (strict_strtoul(buf, 0, &num))
-		return -EINVAL;
+	unsigned int num;
+	int rv;
+
+	rv = kstrtouint(buf, 0, &num);
+	if (rv < 0)
+		return rv;
 	mutex_lock(&isolated_cpus_lock);
 	acpi_pad_idle_cpus(num);
 	mutex_unlock(&isolated_cpus_lock);
diff --git a/drivers/acpi/power_meter.c b/drivers/acpi/power_meter.c
index 66f6729..a468c33 100644
--- a/drivers/acpi/power_meter.c
+++ b/drivers/acpi/power_meter.c
@@ -166,12 +166,12 @@ static ssize_t set_avg_interval(struct device *dev,
 	union acpi_object arg0 = { ACPI_TYPE_INTEGER };
 	struct acpi_object_list args = { 1, &arg0 };
 	int res;
-	unsigned long temp;
+	u64 temp;
 	unsigned long long data;
 	acpi_status status;
 
-	res = strict_strtoul(buf, 10, &temp);
-	if (res)
+	res = kstrtou64(buf, 10, &temp);
+	if (res < 0)
 		return res;
 
 	if (temp > resource->caps.max_avg_interval ||
@@ -241,8 +241,8 @@ static ssize_t set_cap(struct device *dev, struct device_attribute *devattr,
 	unsigned long long data;
 	acpi_status status;
 
-	res = strict_strtoul(buf, 10, &temp);
-	if (res)
+	res = kstrtoul(buf, 10, &temp);
+	if (res < 0)
 		return res;
 
 	temp /= 1000;
@@ -311,13 +311,11 @@ static ssize_t set_trip(struct device *dev, struct device_attribute *devattr,
 	int res;
 	unsigned long temp;
 
-	res = strict_strtoul(buf, 10, &temp);
-	if (res)
+	res = kstrtoul(buf, 10, &temp);
+	if (res < 0)
 		return res;
 
 	temp /= 1000;
-	if (temp < 0)
-		return -EINVAL;
 
 	mutex_lock(&resource->lock);
 	resource->trip[attr->index - 7] = temp;
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 11/52] kstrtox: convert drivers/ata/
  2011-02-05 14:20 [PATCH 01/52] kstrtox: converting strings to integers done (hopefully) right Alexey Dobriyan
                   ` (8 preceding siblings ...)
  2011-02-05 14:20 ` [PATCH 10/52] kstrtox: convert drivers/acpi/ Alexey Dobriyan
@ 2011-02-05 14:20 ` Alexey Dobriyan
  2011-02-05 14:20 ` [PATCH 12/52] kstrtox: convert drivers/base/ Alexey Dobriyan
                   ` (40 subsequent siblings)
  50 siblings, 0 replies; 58+ messages in thread
From: Alexey Dobriyan @ 2011-02-05 14:20 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, adobriyan


Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
 drivers/ata/libata-scsi.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index 600f635..f0b6f48 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -204,7 +204,7 @@ static ssize_t ata_scsi_park_store(struct device *device,
 	unsigned long flags;
 	int rc;
 
-	rc = strict_strtol(buf, 10, &input);
+	rc = kstrtol(buf, 10, &input);
 	if (rc || input < -2)
 		return -EINVAL;
 	if (input > ATA_TMOUT_MAX_PARK) {
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 12/52] kstrtox: convert drivers/base/
  2011-02-05 14:20 [PATCH 01/52] kstrtox: converting strings to integers done (hopefully) right Alexey Dobriyan
                   ` (9 preceding siblings ...)
  2011-02-05 14:20 ` [PATCH 11/52] kstrtox: convert drivers/ata/ Alexey Dobriyan
@ 2011-02-05 14:20 ` Alexey Dobriyan
  2011-02-05 14:20 ` [PATCH 13/52] kstrtox: convert drivers/block/ Alexey Dobriyan
                   ` (39 subsequent siblings)
  50 siblings, 0 replies; 58+ messages in thread
From: Alexey Dobriyan @ 2011-02-05 14:20 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, adobriyan


Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
 drivers/base/core.c        |    6 +++---
 drivers/base/memory.c      |   10 ++++++----
 drivers/base/power/sysfs.c |    9 +++++----
 include/linux/device.h     |    2 +-
 4 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/drivers/base/core.c b/drivers/base/core.c
index 080e9ca..0fccdc4 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -28,13 +28,13 @@
 
 #ifdef CONFIG_SYSFS_DEPRECATED
 #ifdef CONFIG_SYSFS_DEPRECATED_V2
-long sysfs_deprecated = 1;
+int sysfs_deprecated = 1;
 #else
-long sysfs_deprecated = 0;
+int sysfs_deprecated = 0;
 #endif
 static __init int sysfs_deprecated_setup(char *arg)
 {
-	return strict_strtol(arg, 10, &sysfs_deprecated);
+	return kstrtoint(arg, 10, &sysfs_deprecated);
 }
 early_param("sysfs.deprecated", sysfs_deprecated_setup);
 #endif
diff --git a/drivers/base/memory.c b/drivers/base/memory.c
index cafeaaf..2dc57aa 100644
--- a/drivers/base/memory.c
+++ b/drivers/base/memory.c
@@ -380,8 +380,9 @@ store_soft_offline_page(struct class *class,
 	u64 pfn;
 	if (!capable(CAP_SYS_ADMIN))
 		return -EPERM;
-	if (strict_strtoull(buf, 0, &pfn) < 0)
-		return -EINVAL;
+	ret = kstrtou64(buf, 0, &pfn);
+	if (ret < 0)
+		return ret;
 	pfn >>= PAGE_SHIFT;
 	if (!pfn_valid(pfn))
 		return -ENXIO;
@@ -399,8 +400,9 @@ store_hard_offline_page(struct class *class,
 	u64 pfn;
 	if (!capable(CAP_SYS_ADMIN))
 		return -EPERM;
-	if (strict_strtoull(buf, 0, &pfn) < 0)
-		return -EINVAL;
+	ret = kstrtou64(buf, 0, &pfn);
+	if (ret < 0)
+		return ret;
 	pfn >>= PAGE_SHIFT;
 	ret = __memory_failure(pfn, 0, 0);
 	return ret ? ret : count;
diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c
index 0b1e46b..1397768 100644
--- a/drivers/base/power/sysfs.c
+++ b/drivers/base/power/sysfs.c
@@ -197,14 +197,15 @@ static ssize_t autosuspend_delay_ms_show(struct device *dev,
 static ssize_t autosuspend_delay_ms_store(struct device *dev,
 		struct device_attribute *attr, const char *buf, size_t n)
 {
-	long delay;
+	int delay;
+	int rv;
 
 	if (!dev->power.use_autosuspend)
 		return -EIO;
 
-	if (strict_strtol(buf, 10, &delay) != 0 || delay != (int) delay)
-		return -EINVAL;
-
+	rv = kstrtoint(buf, 10, &delay);
+	if (rv < 0)
+		return rv;
 	pm_runtime_set_autosuspend_delay(dev, delay);
 	return n;
 }
diff --git a/include/linux/device.h b/include/linux/device.h
index 1bf5cf0..bf838b5 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -753,7 +753,7 @@ do {						     \
 	MODULE_ALIAS("char-major-" __stringify(major) "-*")
 
 #ifdef CONFIG_SYSFS_DEPRECATED
-extern long sysfs_deprecated;
+extern int sysfs_deprecated;
 #else
 #define sysfs_deprecated 0
 #endif
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 13/52] kstrtox: convert drivers/block/
  2011-02-05 14:20 [PATCH 01/52] kstrtox: converting strings to integers done (hopefully) right Alexey Dobriyan
                   ` (10 preceding siblings ...)
  2011-02-05 14:20 ` [PATCH 12/52] kstrtox: convert drivers/base/ Alexey Dobriyan
@ 2011-02-05 14:20 ` Alexey Dobriyan
  2011-02-05 14:20 ` [PATCH 14/52] kstrtox: convert drivers/bluetooth/ Alexey Dobriyan
                   ` (38 subsequent siblings)
  50 siblings, 0 replies; 58+ messages in thread
From: Alexey Dobriyan @ 2011-02-05 14:20 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, adobriyan


Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
 drivers/block/osdblk.c |   10 ++--------
 drivers/block/rbd.c    |    8 +-------
 2 files changed, 3 insertions(+), 15 deletions(-)

diff --git a/drivers/block/osdblk.c b/drivers/block/osdblk.c
index 87311eb..9a645ed 100644
--- a/drivers/block/osdblk.c
+++ b/drivers/block/osdblk.c
@@ -596,18 +596,12 @@ static ssize_t class_osdblk_remove(struct class *c,
 {
 	struct osdblk_device *osdev = NULL;
 	int target_id, rc;
-	unsigned long ul;
 	struct list_head *tmp;
 
-	rc = strict_strtoul(buf, 10, &ul);
-	if (rc)
+	rc = kstrtoint(buf, 10, &target_id);
+	if (rc < 0)
 		return rc;
 
-	/* convert to int; abort if we lost anything in the conversion */
-	target_id = (int) ul;
-	if (target_id != ul)
-		return -EINVAL;
-
 	/* remove object from list immediately */
 	mutex_lock_nested(&ctl_mutex, SINGLE_DEPTH_NESTING);
 
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index e1e38b1..ffe969f 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -1866,18 +1866,12 @@ static ssize_t rbd_remove(struct bus_type *bus,
 {
 	struct rbd_device *rbd_dev = NULL;
 	int target_id, rc;
-	unsigned long ul;
 	int ret = count;
 
-	rc = strict_strtoul(buf, 10, &ul);
+	rc = kstrtoint(buf, 10, &target_id);
 	if (rc)
 		return rc;
 
-	/* convert to int; abort if we lost anything in the conversion */
-	target_id = (int) ul;
-	if (target_id != ul)
-		return -EINVAL;
-
 	mutex_lock_nested(&ctl_mutex, SINGLE_DEPTH_NESTING);
 
 	rbd_dev = __rbd_get_dev(target_id);
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 14/52] kstrtox: convert drivers/bluetooth/
  2011-02-05 14:20 [PATCH 01/52] kstrtox: converting strings to integers done (hopefully) right Alexey Dobriyan
                   ` (11 preceding siblings ...)
  2011-02-05 14:20 ` [PATCH 13/52] kstrtox: convert drivers/block/ Alexey Dobriyan
@ 2011-02-05 14:20 ` Alexey Dobriyan
  2011-02-05 14:20 ` [PATCH 15/52] kstrtox: convert drivers/clocksource/ Alexey Dobriyan
                   ` (37 subsequent siblings)
  50 siblings, 0 replies; 58+ messages in thread
From: Alexey Dobriyan @ 2011-02-05 14:20 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, adobriyan


Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
 drivers/bluetooth/btmrvl_debugfs.c |   50 +++++++++++++++++------------------
 1 files changed, 24 insertions(+), 26 deletions(-)

diff --git a/drivers/bluetooth/btmrvl_debugfs.c b/drivers/bluetooth/btmrvl_debugfs.c
index fd6305b..ffc4324 100644
--- a/drivers/bluetooth/btmrvl_debugfs.c
+++ b/drivers/bluetooth/btmrvl_debugfs.c
@@ -56,16 +56,16 @@ static ssize_t btmrvl_hscfgcmd_write(struct file *file,
 {
 	struct btmrvl_private *priv = file->private_data;
 	char buf[16];
-	long result, ret;
+	int ret;
 
 	memset(buf, 0, sizeof(buf));
 
 	if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
 		return -EFAULT;
 
-	ret = strict_strtol(buf, 10, &result);
-
-	priv->btmrvl_dev.hscfgcmd = result;
+	ret = kstrtou8(buf, 10, &priv->btmrvl_dev.hscfgcmd);
+	if (ret < 0)
+		return ret;
 
 	if (priv->btmrvl_dev.hscfgcmd) {
 		btmrvl_prepare_command(priv);
@@ -100,17 +100,16 @@ static ssize_t btmrvl_psmode_write(struct file *file, const char __user *ubuf,
 {
 	struct btmrvl_private *priv = file->private_data;
 	char buf[16];
-	long result, ret;
+	int ret;
 
 	memset(buf, 0, sizeof(buf));
 
 	if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
 		return -EFAULT;
 
-	ret = strict_strtol(buf, 10, &result);
-
-	priv->btmrvl_dev.psmode = result;
-
+	ret = kstrtou8(buf, 10, &priv->btmrvl_dev.psmode);
+	if (ret < 0)
+		return ret;
 	return count;
 }
 
@@ -139,16 +138,16 @@ static ssize_t btmrvl_pscmd_write(struct file *file, const char __user *ubuf,
 {
 	struct btmrvl_private *priv = file->private_data;
 	char buf[16];
-	long result, ret;
+	int ret;
 
 	memset(buf, 0, sizeof(buf));
 
 	if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
 		return -EFAULT;
 
-	ret = strict_strtol(buf, 10, &result);
-
-	priv->btmrvl_dev.pscmd = result;
+	ret = kstrtou8(buf, 10, &priv->btmrvl_dev.pscmd);
+	if (ret < 0)
+		return ret;
 
 	if (priv->btmrvl_dev.pscmd) {
 		btmrvl_prepare_command(priv);
@@ -183,17 +182,16 @@ static ssize_t btmrvl_gpiogap_write(struct file *file, const char __user *ubuf,
 {
 	struct btmrvl_private *priv = file->private_data;
 	char buf[16];
-	long result, ret;
+	int ret;
 
 	memset(buf, 0, sizeof(buf));
 
 	if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
 		return -EFAULT;
 
-	ret = strict_strtol(buf, 16, &result);
-
-	priv->btmrvl_dev.gpio_gap = result;
-
+	ret = kstrtou16(buf, 16, &priv->btmrvl_dev.gpio_gap);
+	if (ret < 0)
+		return ret;
 	return count;
 }
 
@@ -222,16 +220,17 @@ static ssize_t btmrvl_hscmd_write(struct file *file, const char __user *ubuf,
 {
 	struct btmrvl_private *priv = file->private_data;
 	char buf[16];
-	long result, ret;
+	int ret;
 
 	memset(buf, 0, sizeof(buf));
 
 	if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
 		return -EFAULT;
 
-	ret = strict_strtol(buf, 10, &result);
+	ret = kstrtou8(buf, 10, &priv->btmrvl_dev.hscmd);
+	if (ret < 0)
+		return ret;
 
-	priv->btmrvl_dev.hscmd = result;
 	if (priv->btmrvl_dev.hscmd) {
 		btmrvl_prepare_command(priv);
 		wake_up_interruptible(&priv->main_thread.wait_q);
@@ -264,17 +263,16 @@ static ssize_t btmrvl_hsmode_write(struct file *file, const char __user *ubuf,
 {
 	struct btmrvl_private *priv = file->private_data;
 	char buf[16];
-	long result, ret;
+	int ret;
 
 	memset(buf, 0, sizeof(buf));
 
 	if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
 		return -EFAULT;
 
-	ret = strict_strtol(buf, 10, &result);
-
-	priv->btmrvl_dev.hsmode = result;
-
+	ret = kstrtou8(buf, 10, &priv->btmrvl_dev.hsmode);
+	if (ret < 0)
+		return ret;
 	return count;
 }
 
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 15/52] kstrtox: convert drivers/clocksource/
  2011-02-05 14:20 [PATCH 01/52] kstrtox: converting strings to integers done (hopefully) right Alexey Dobriyan
                   ` (12 preceding siblings ...)
  2011-02-05 14:20 ` [PATCH 14/52] kstrtox: convert drivers/bluetooth/ Alexey Dobriyan
@ 2011-02-05 14:20 ` Alexey Dobriyan
  2011-02-05 14:20 ` [PATCH 16/52] kstrtox: convert drivers/edac/ Alexey Dobriyan
                   ` (36 subsequent siblings)
  50 siblings, 0 replies; 58+ messages in thread
From: Alexey Dobriyan @ 2011-02-05 14:20 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, adobriyan


Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
 drivers/clocksource/acpi_pm.c |   14 ++++++--------
 1 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/clocksource/acpi_pm.c b/drivers/clocksource/acpi_pm.c
index effe797..79643d5 100644
--- a/drivers/clocksource/acpi_pm.c
+++ b/drivers/clocksource/acpi_pm.c
@@ -233,15 +233,13 @@ fs_initcall(init_acpi_pm_clocksource);
  */
 static int __init parse_pmtmr(char *arg)
 {
-	unsigned long base;
+	u32 base;
+	int rv;
 
-	if (strict_strtoul(arg, 16, &base))
-		return -EINVAL;
-#ifdef CONFIG_X86_64
-	if (base > UINT_MAX)
-		return -ERANGE;
-#endif
-	printk(KERN_INFO "PMTMR IOPort override: 0x%04x -> 0x%04lx\n",
+	rv = kstrtou32(arg, 16, &base);
+	if (rv < 0)
+		return rv;
+	printk(KERN_INFO "PMTMR IOPort override: 0x%04x -> 0x%04x\n",
 	       pmtmr_ioport, base);
 	pmtmr_ioport = base;
 
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 16/52] kstrtox: convert drivers/edac/
  2011-02-05 14:20 [PATCH 01/52] kstrtox: converting strings to integers done (hopefully) right Alexey Dobriyan
                   ` (13 preceding siblings ...)
  2011-02-05 14:20 ` [PATCH 15/52] kstrtox: convert drivers/clocksource/ Alexey Dobriyan
@ 2011-02-05 14:20 ` Alexey Dobriyan
  2011-02-05 17:34   ` Borislav Petkov
  2011-02-05 14:20 ` [PATCH 17/52] kstrtox: convert drivers/gpio/ Alexey Dobriyan
                   ` (35 subsequent siblings)
  50 siblings, 1 reply; 58+ messages in thread
From: Alexey Dobriyan @ 2011-02-05 14:20 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, adobriyan


Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
 drivers/edac/amd64_edac_inj.c |  135 +++++++++++++++++------------------------
 drivers/edac/edac_mc_sysfs.c  |   20 +++---
 drivers/edac/i7core_edac.c    |   41 +++++++------
 drivers/edac/mce_amd_inj.c    |   28 ++++-----
 4 files changed, 101 insertions(+), 123 deletions(-)

diff --git a/drivers/edac/amd64_edac_inj.c b/drivers/edac/amd64_edac_inj.c
index 688478d..180a498 100644
--- a/drivers/edac/amd64_edac_inj.c
+++ b/drivers/edac/amd64_edac_inj.c
@@ -16,21 +16,18 @@ static ssize_t amd64_inject_section_store(struct mem_ctl_info *mci,
 					  const char *data, size_t count)
 {
 	struct amd64_pvt *pvt = mci->pvt_info;
-	unsigned long value;
-	int ret = 0;
-
-	ret = strict_strtoul(data, 10, &value);
-	if (ret != -EINVAL) {
-
-		if (value > 3) {
-			amd64_warn("%s: invalid section 0x%lx\n", __func__, value);
-			return -EINVAL;
-		}
-
-		pvt->injection.section = (u32) value;
-		return count;
+	u32 value;
+	int ret;
+
+	ret = kstrtou32(data, 10, &value);
+	if (ret < 0)
+		return ret;
+	if (value > 3) {
+		amd64_warn("%s: invalid section 0x%x\n", __func__, value);
+		return -EINVAL;
 	}
-	return ret;
+	pvt->injection.section = value;
+	return count;
 }
 
 static ssize_t amd64_inject_word_show(struct mem_ctl_info *mci, char *buf)
@@ -49,21 +46,18 @@ static ssize_t amd64_inject_word_store(struct mem_ctl_info *mci,
 					const char *data, size_t count)
 {
 	struct amd64_pvt *pvt = mci->pvt_info;
-	unsigned long value;
-	int ret = 0;
-
-	ret = strict_strtoul(data, 10, &value);
-	if (ret != -EINVAL) {
-
-		if (value > 8) {
-			amd64_warn("%s: invalid word 0x%lx\n", __func__, value);
-			return -EINVAL;
-		}
-
-		pvt->injection.word = (u32) value;
-		return count;
+	u32 value;
+	int ret;
+
+	ret = kstrtou32(data, 10, &value);
+	if (ret < 0)
+		return ret;
+	if (value > 8) {
+		amd64_warn("%s: invalid word 0x%x\n", __func__, value);
+		return -EINVAL;
 	}
-	return ret;
+	pvt->injection.word = value;
+	return count;
 }
 
 static ssize_t amd64_inject_ecc_vector_show(struct mem_ctl_info *mci, char *buf)
@@ -81,22 +75,19 @@ static ssize_t amd64_inject_ecc_vector_store(struct mem_ctl_info *mci,
 					     const char *data, size_t count)
 {
 	struct amd64_pvt *pvt = mci->pvt_info;
-	unsigned long value;
-	int ret = 0;
-
-	ret = strict_strtoul(data, 16, &value);
-	if (ret != -EINVAL) {
-
-		if (value & 0xFFFF0000) {
-			amd64_warn("%s: invalid EccVector: 0x%lx\n",
+	u32 value;
+	int ret;
+
+	ret = kstrtou32(data, 16, &value);
+	if (ret < 0)
+		return ret;
+	if (value & 0xFFFF0000) {
+		amd64_warn("%s: invalid EccVector: 0x%x\n",
 				   __func__, value);
-			return -EINVAL;
-		}
-
-		pvt->injection.bit_map = (u32) value;
-		return count;
+		return -EINVAL;
 	}
-	return ret;
+	pvt->injection.bit_map = value;
+	return count;
 }
 
 /*
@@ -107,29 +98,22 @@ static ssize_t amd64_inject_read_store(struct mem_ctl_info *mci,
 					const char *data, size_t count)
 {
 	struct amd64_pvt *pvt = mci->pvt_info;
-	unsigned long value;
 	u32 section, word_bits;
-	int ret = 0;
-
-	ret = strict_strtoul(data, 10, &value);
-	if (ret != -EINVAL) {
 
-		/* Form value to choose 16-byte section of cacheline */
-		section = F10_NB_ARRAY_DRAM_ECC |
-				SET_NB_ARRAY_ADDRESS(pvt->injection.section);
-		pci_write_config_dword(pvt->F3, F10_NB_ARRAY_ADDR, section);
+	/* Form value to choose 16-byte section of cacheline */
+	section = F10_NB_ARRAY_DRAM_ECC |
+		SET_NB_ARRAY_ADDRESS(pvt->injection.section);
+	pci_write_config_dword(pvt->F3, F10_NB_ARRAY_ADDR, section);
 
-		word_bits = SET_NB_DRAM_INJECTION_READ(pvt->injection.word,
-						pvt->injection.bit_map);
+	word_bits = SET_NB_DRAM_INJECTION_READ(pvt->injection.word,
+			pvt->injection.bit_map);
 
-		/* Issue 'word' and 'bit' along with the READ request */
-		pci_write_config_dword(pvt->F3, F10_NB_ARRAY_DATA, word_bits);
+	/* Issue 'word' and 'bit' along with the READ request */
+	pci_write_config_dword(pvt->F3, F10_NB_ARRAY_DATA, word_bits);
 
-		debugf0("section=0x%x word_bits=0x%x\n", section, word_bits);
+	debugf0("section=0x%x word_bits=0x%x\n", section, word_bits);
 
-		return count;
-	}
-	return ret;
+	return count;
 }
 
 /*
@@ -140,29 +124,22 @@ static ssize_t amd64_inject_write_store(struct mem_ctl_info *mci,
 					const char *data, size_t count)
 {
 	struct amd64_pvt *pvt = mci->pvt_info;
-	unsigned long value;
 	u32 section, word_bits;
-	int ret = 0;
-
-	ret = strict_strtoul(data, 10, &value);
-	if (ret != -EINVAL) {
 
-		/* Form value to choose 16-byte section of cacheline */
-		section = F10_NB_ARRAY_DRAM_ECC |
-				SET_NB_ARRAY_ADDRESS(pvt->injection.section);
-		pci_write_config_dword(pvt->F3, F10_NB_ARRAY_ADDR, section);
+	/* Form value to choose 16-byte section of cacheline */
+	section = F10_NB_ARRAY_DRAM_ECC |
+		SET_NB_ARRAY_ADDRESS(pvt->injection.section);
+	pci_write_config_dword(pvt->F3, F10_NB_ARRAY_ADDR, section);
 
-		word_bits = SET_NB_DRAM_INJECTION_WRITE(pvt->injection.word,
-						pvt->injection.bit_map);
+	word_bits = SET_NB_DRAM_INJECTION_WRITE(pvt->injection.word,
+			pvt->injection.bit_map);
 
-		/* Issue 'word' and 'bit' along with the READ request */
-		pci_write_config_dword(pvt->F3, F10_NB_ARRAY_DATA, word_bits);
+	/* Issue 'word' and 'bit' along with the READ request */
+	pci_write_config_dword(pvt->F3, F10_NB_ARRAY_DATA, word_bits);
 
-		debugf0("section=0x%x word_bits=0x%x\n", section, word_bits);
+	debugf0("section=0x%x word_bits=0x%x\n", section, word_bits);
 
-		return count;
-	}
-	return ret;
+	return count;
 }
 
 /*
@@ -197,17 +174,15 @@ struct mcidev_sysfs_attribute amd64_inj_attrs[] = {
 	{
 		.attr = {
 			.name = "inject_write",
-			.mode = (S_IRUGO | S_IWUSR)
+			.mode = S_IWUSR,
 		},
-		.show = NULL,
 		.store = amd64_inject_write_store,
 	},
 	{
 		.attr = {
 			.name = "inject_read",
-			.mode = (S_IRUGO | S_IWUSR)
+			.mode = S_IWUSR,
 		},
-		.show = NULL,
 		.store = amd64_inject_read_store,
 	},
 };
diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
index 39d97cf..c8cb71d 100644
--- a/drivers/edac/edac_mc_sysfs.c
+++ b/drivers/edac/edac_mc_sysfs.c
@@ -48,16 +48,16 @@ int edac_mc_get_poll_msec(void)
 
 static int edac_set_poll_msec(const char *val, struct kernel_param *kp)
 {
-	long l;
+	unsigned int l;
 	int ret;
 
 	if (!val)
 		return -EINVAL;
 
-	ret = strict_strtol(val, 0, &l);
-	if (ret == -EINVAL || ((int)l != l))
-		return -EINVAL;
-	*((int *)kp->arg) = l;
+	ret = kstrtouint(val, 0, &l);
+	if (ret < 0)
+		return ret;
+	*(unsigned int *)kp->arg = l;
 
 	/* notify edac_mc engine to reset the poll period */
 	edac_mc_reset_delay_period(l);
@@ -448,14 +448,16 @@ static ssize_t mci_reset_counters_store(struct mem_ctl_info *mci,
 static ssize_t mci_sdram_scrub_rate_store(struct mem_ctl_info *mci,
 					  const char *data, size_t count)
 {
-	unsigned long bandwidth = 0;
+	u32 bandwidth;
 	int new_bw = 0;
+	int rv;
 
 	if (!mci->set_sdram_scrub_rate)
 		return -EINVAL;
 
-	if (strict_strtoul(data, 10, &bandwidth) < 0)
-		return -EINVAL;
+	rv = kstrtou32(data, 10, &bandwidth);
+	if (rv < 0)
+		return rv;
 
 	new_bw = mci->set_sdram_scrub_rate(mci, bandwidth);
 	if (new_bw >= 0) {
@@ -463,7 +465,7 @@ static ssize_t mci_sdram_scrub_rate_store(struct mem_ctl_info *mci,
 		return count;
 	}
 
-	edac_printk(KERN_DEBUG, EDAC_MC, "Error setting scrub rate to: %lu\n", bandwidth);
+	edac_printk(KERN_DEBUG, EDAC_MC, "Error setting scrub rate to: %u\n", bandwidth);
 	return -EINVAL;
 }
 
diff --git a/drivers/edac/i7core_edac.c b/drivers/edac/i7core_edac.c
index 81154ab..8dcdfaf 100644
--- a/drivers/edac/i7core_edac.c
+++ b/drivers/edac/i7core_edac.c
@@ -774,17 +774,19 @@ static ssize_t i7core_inject_section_store(struct mem_ctl_info *mci,
 					   const char *data, size_t count)
 {
 	struct i7core_pvt *pvt = mci->pvt_info;
-	unsigned long value;
+	u32 value;
 	int rc;
 
 	if (pvt->inject.enable)
 		disable_inject(mci);
 
-	rc = strict_strtoul(data, 10, &value);
-	if ((rc < 0) || (value > 3))
+	rc = kstrtou32(data, 10, &value);
+	if (rc < 0)
+		return rc;
+	if (value > 3)
 		return -EIO;
 
-	pvt->inject.section = (u32) value;
+	pvt->inject.section = value;
 	return count;
 }
 
@@ -807,17 +809,19 @@ static ssize_t i7core_inject_type_store(struct mem_ctl_info *mci,
 					const char *data, size_t count)
 {
 	struct i7core_pvt *pvt = mci->pvt_info;
-	unsigned long value;
+	u32 value;
 	int rc;
 
 	if (pvt->inject.enable)
 		disable_inject(mci);
 
-	rc = strict_strtoul(data, 10, &value);
-	if ((rc < 0) || (value > 7))
+	rc = kstrtou32(data, 10, &value);
+	if (rc < 0)
+		return rc;
+	if (value > 7)
 		return -EIO;
 
-	pvt->inject.type = (u32) value;
+	pvt->inject.type = value;
 	return count;
 }
 
@@ -842,17 +846,14 @@ static ssize_t i7core_inject_eccmask_store(struct mem_ctl_info *mci,
 					const char *data, size_t count)
 {
 	struct i7core_pvt *pvt = mci->pvt_info;
-	unsigned long value;
 	int rc;
 
 	if (pvt->inject.enable)
 		disable_inject(mci);
 
-	rc = strict_strtoul(data, 10, &value);
+	rc = kstrtou32(data, 10, &pvt->inject.eccmask);
 	if (rc < 0)
-		return -EIO;
-
-	pvt->inject.eccmask = (u32) value;
+		return rc;
 	return count;
 }
 
@@ -880,7 +881,7 @@ static ssize_t i7core_inject_store_##param(			\
 		const char *data, size_t count)			\
 {								\
 	struct i7core_pvt *pvt;					\
-	long value;						\
+	u32 value;						\
 	int rc;							\
 								\
 	debugf1("%s()\n", __func__);				\
@@ -892,8 +893,10 @@ static ssize_t i7core_inject_store_##param(			\
 	if (!strcasecmp(data, "any") || !strcasecmp(data, "any\n"))\
 		value = -1;					\
 	else {							\
-		rc = strict_strtoul(data, 10, &value);		\
-		if ((rc < 0) || (value >= limit))		\
+		rc = kstrtou32(data, 10, &value);		\
+		if (rc < 0)					\
+			return rc;				\
+		if (value >= limit)				\
 			return -EIO;				\
 	}							\
 								\
@@ -990,9 +993,9 @@ static ssize_t i7core_inject_enable_store(struct mem_ctl_info *mci,
 	if (!pvt->pci_ch[pvt->inject.channel][0])
 		return 0;
 
-	rc = strict_strtoul(data, 10, &enable);
-	if ((rc < 0))
-		return 0;
+	rc = kstrtoul(data, 10, &enable);
+	if (rc < 0)
+		return rc;
 
 	if (enable) {
 		pvt->inject.enable = 1;
diff --git a/drivers/edac/mce_amd_inj.c b/drivers/edac/mce_amd_inj.c
index 733a7e7..ecade92 100644
--- a/drivers/edac/mce_amd_inj.c
+++ b/drivers/edac/mce_amd_inj.c
@@ -39,15 +39,13 @@ static ssize_t edac_inject_##reg##_store(struct kobject *kobj,		\
 					 struct edac_mce_attr *attr,	\
 					 const char *data, size_t count)\
 {									\
-	int ret = 0;							\
-	unsigned long value;						\
+	int ret;							\
 									\
-	ret = strict_strtoul(data, 16, &value);				\
-	if (ret < 0)							\
+	ret = kstrtou64(data, 16, &i_mce.reg);				\
+	if (ret < 0) {							\
 		printk(KERN_ERR "Error writing MCE " #reg " field.\n");	\
-									\
-	i_mce.reg = value;						\
-									\
+		return ret;						\
+	}								\
 	return count;							\
 }
 
@@ -79,22 +77,22 @@ static ssize_t edac_inject_bank_store(struct kobject *kobj,
 				      struct edac_mce_attr *attr,
 				      const char *data, size_t count)
 {
-	int ret = 0;
-	unsigned long value;
+	u8 bank;
+	int ret;
 
-	ret = strict_strtoul(data, 10, &value);
+	ret = kstrtou8(data, 10, &bank);
 	if (ret < 0) {
 		printk(KERN_ERR "Invalid bank value!\n");
-		return -EINVAL;
+		return ret;
 	}
 
-	if (value > 5)
-		if (boot_cpu_data.x86 != 0x15 || value > 6) {
-			printk(KERN_ERR "Non-existant MCE bank: %lu\n", value);
+	if (bank > 5)
+		if (boot_cpu_data.x86 != 0x15 || bank > 6) {
+			printk(KERN_ERR "Non-existant MCE bank: %hhu\n", bank);
 			return -EINVAL;
 		}
 
-	i_mce.bank = value;
+	i_mce.bank = bank;
 
 	amd_decode_mce(NULL, 0, &i_mce);
 
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 17/52] kstrtox: convert drivers/gpio/
  2011-02-05 14:20 [PATCH 01/52] kstrtox: converting strings to integers done (hopefully) right Alexey Dobriyan
                   ` (14 preceding siblings ...)
  2011-02-05 14:20 ` [PATCH 16/52] kstrtox: convert drivers/edac/ Alexey Dobriyan
@ 2011-02-05 14:20 ` Alexey Dobriyan
  2011-02-05 14:20 ` [PATCH 18/52] kstrtox: convert drivers/gpu/drm/nouveau/ Alexey Dobriyan
                   ` (34 subsequent siblings)
  50 siblings, 0 replies; 58+ messages in thread
From: Alexey Dobriyan @ 2011-02-05 14:20 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, adobriyan


Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
 drivers/gpio/gpiolib.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 649550e..374775d 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -302,7 +302,7 @@ static ssize_t gpio_value_store(struct device *dev,
 	else {
 		long		value;
 
-		status = strict_strtol(buf, 0, &value);
+		status = kstrtol(buf, 0, &value);
 		if (status == 0) {
 			if (test_bit(FLAG_ACTIVE_LOW, &desc->flags))
 				value = !value;
@@ -528,7 +528,7 @@ static ssize_t gpio_active_low_store(struct device *dev,
 	} else {
 		long		value;
 
-		status = strict_strtol(buf, 0, &value);
+		status = kstrtol(buf, 0, &value);
 		if (status == 0)
 			status = sysfs_set_active_low(desc, dev, value != 0);
 	}
@@ -606,10 +606,10 @@ static ssize_t export_store(struct class *class,
 				struct class_attribute *attr,
 				const char *buf, size_t len)
 {
-	long	gpio;
+	unsigned int	gpio;
 	int	status;
 
-	status = strict_strtol(buf, 0, &gpio);
+	status = kstrtouint(buf, 0, &gpio);
 	if (status < 0)
 		goto done;
 
@@ -638,10 +638,10 @@ static ssize_t unexport_store(struct class *class,
 				struct class_attribute *attr,
 				const char *buf, size_t len)
 {
-	long	gpio;
+	unsigned int	gpio;
 	int	status;
 
-	status = strict_strtol(buf, 0, &gpio);
+	status = kstrtouint(buf, 0, &gpio);
 	if (status < 0)
 		goto done;
 
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 18/52] kstrtox: convert drivers/gpu/drm/nouveau/
  2011-02-05 14:20 [PATCH 01/52] kstrtox: converting strings to integers done (hopefully) right Alexey Dobriyan
                   ` (15 preceding siblings ...)
  2011-02-05 14:20 ` [PATCH 17/52] kstrtox: convert drivers/gpio/ Alexey Dobriyan
@ 2011-02-05 14:20 ` Alexey Dobriyan
  2011-02-05 14:20 ` [PATCH 19/52] kstrtox: convert drivers/hid/ Alexey Dobriyan
                   ` (33 subsequent siblings)
  50 siblings, 0 replies; 58+ messages in thread
From: Alexey Dobriyan @ 2011-02-05 14:20 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, adobriyan


Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
 drivers/gpu/drm/nouveau/nouveau_pm.c |   16 ++++++++++------
 1 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_pm.c b/drivers/gpu/drm/nouveau/nouveau_pm.c
index f05c0cd..9fb5b6e 100644
--- a/drivers/gpu/drm/nouveau/nouveau_pm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_pm.c
@@ -319,10 +319,12 @@ nouveau_hwmon_set_max_temp(struct device *d, struct device_attribute *a,
 	struct drm_nouveau_private *dev_priv = dev->dev_private;
 	struct nouveau_pm_engine *pm = &dev_priv->engine.pm;
 	struct nouveau_pm_threshold_temp *temp = &pm->threshold_temp;
-	long value;
+	int value;
+	int rv;
 
-	if (strict_strtol(buf, 10, &value) == -EINVAL)
-		return count;
+	rv = kstrtoint(buf, 10, &value);
+	if (rv < 0)
+		return rv;
 
 	temp->down_clock = value/1000;
 
@@ -354,10 +356,12 @@ nouveau_hwmon_set_critical_temp(struct device *d, struct device_attribute *a,
 	struct drm_nouveau_private *dev_priv = dev->dev_private;
 	struct nouveau_pm_engine *pm = &dev_priv->engine.pm;
 	struct nouveau_pm_threshold_temp *temp = &pm->threshold_temp;
-	long value;
+	int value;
+	int rv;
 
-	if (strict_strtol(buf, 10, &value) == -EINVAL)
-		return count;
+	rv = kstrtoint(buf, 10, &value);
+	if (rv < 0)
+		return rv;
 
 	temp->critical = value/1000;
 
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 19/52] kstrtox: convert drivers/hid/
  2011-02-05 14:20 [PATCH 01/52] kstrtox: converting strings to integers done (hopefully) right Alexey Dobriyan
                   ` (16 preceding siblings ...)
  2011-02-05 14:20 ` [PATCH 18/52] kstrtox: convert drivers/gpu/drm/nouveau/ Alexey Dobriyan
@ 2011-02-05 14:20 ` Alexey Dobriyan
  2011-02-05 14:20 ` [PATCH 20/52] kstrtox: convert drivers/hwmon/ Alexey Dobriyan
                   ` (32 subsequent siblings)
  50 siblings, 0 replies; 58+ messages in thread
From: Alexey Dobriyan @ 2011-02-05 14:20 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, adobriyan


Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
 drivers/hid/hid-magicmouse.c      |   14 +++++++--
 drivers/hid/hid-ntrig.c           |   54 ++++++++++++++++++++----------------
 drivers/hid/hid-roccat-kone.c     |    8 +++---
 drivers/hid/hid-roccat-koneplus.c |    4 +-
 4 files changed, 47 insertions(+), 33 deletions(-)

diff --git a/drivers/hid/hid-magicmouse.c b/drivers/hid/hid-magicmouse.c
index 698e645..f3ce099 100644
--- a/drivers/hid/hid-magicmouse.c
+++ b/drivers/hid/hid-magicmouse.c
@@ -34,9 +34,17 @@ module_param(emulate_scroll_wheel, bool, 0644);
 MODULE_PARM_DESC(emulate_scroll_wheel, "Emulate a scroll wheel");
 
 static unsigned int scroll_speed = 32;
-static int param_set_scroll_speed(const char *val, struct kernel_param *kp) {
-	unsigned long speed;
-	if (!val || strict_strtoul(val, 0, &speed) || speed > 63)
+static int param_set_scroll_speed(const char *val, struct kernel_param *kp)
+{
+	unsigned int speed;
+	int rv;
+
+	if (!val)
+		return -EINVAL;
+	rv = kstrtouint(val, 0, &speed);
+	if (rv < 0)
+		return rv;
+	if (speed > 63)
 		return -EINVAL;
 	scroll_speed = speed;
 	return 0;
diff --git a/drivers/hid/hid-ntrig.c b/drivers/hid/hid-ntrig.c
index beb4034..4bbab1a 100644
--- a/drivers/hid/hid-ntrig.c
+++ b/drivers/hid/hid-ntrig.c
@@ -205,11 +205,12 @@ static ssize_t set_min_width(struct device *dev,
 	struct hid_device *hdev = container_of(dev, struct hid_device, dev);
 	struct ntrig_data *nd = hid_get_drvdata(hdev);
 
-	unsigned long val;
-
-	if (strict_strtoul(buf, 0, &val))
-		return -EINVAL;
+	u16 val;
+	int rv;
 
+	rv = kstrtou16(buf, 0, &val);
+	if (rv < 0)
+		return rv;
 	if (val > nd->sensor_physical_width)
 		return -EINVAL;
 
@@ -240,11 +241,12 @@ static ssize_t set_min_height(struct device *dev,
 	struct hid_device *hdev = container_of(dev, struct hid_device, dev);
 	struct ntrig_data *nd = hid_get_drvdata(hdev);
 
-	unsigned long val;
-
-	if (strict_strtoul(buf, 0, &val))
-		return -EINVAL;
+	u16 val;
+	int rv;
 
+	rv = kstrtou16(buf, 0, &val);
+	if (rv < 0)
+		return rv;
 	if (val > nd->sensor_physical_height)
 		return -EINVAL;
 
@@ -274,11 +276,12 @@ static ssize_t set_activate_slack(struct device *dev,
 	struct hid_device *hdev = container_of(dev, struct hid_device, dev);
 	struct ntrig_data *nd = hid_get_drvdata(hdev);
 
-	unsigned long val;
-
-	if (strict_strtoul(buf, 0, &val))
-		return -EINVAL;
+	u8 val;
+	int rv;
 
+	rv = kstrtou8(buf, 0, &val);
+	if (rv < 0)
+		return rv;
 	if (val > 0x7f)
 		return -EINVAL;
 
@@ -309,11 +312,12 @@ static ssize_t set_activation_width(struct device *dev,
 	struct hid_device *hdev = container_of(dev, struct hid_device, dev);
 	struct ntrig_data *nd = hid_get_drvdata(hdev);
 
-	unsigned long val;
-
-	if (strict_strtoul(buf, 0, &val))
-		return -EINVAL;
+	u16 val;
+	int rv;
 
+	rv = kstrtou16(buf, 0, &val);
+	if (rv < 0)
+		return rv;
 	if (val > nd->sensor_physical_width)
 		return -EINVAL;
 
@@ -345,11 +349,12 @@ static ssize_t set_activation_height(struct device *dev,
 	struct hid_device *hdev = container_of(dev, struct hid_device, dev);
 	struct ntrig_data *nd = hid_get_drvdata(hdev);
 
-	unsigned long val;
-
-	if (strict_strtoul(buf, 0, &val))
-		return -EINVAL;
+	u16 val;
+	int rv;
 
+	rv = kstrtou16(buf, 0, &val);
+	if (rv < 0)
+		return rv;
 	if (val > nd->sensor_physical_height)
 		return -EINVAL;
 
@@ -379,11 +384,12 @@ static ssize_t set_deactivate_slack(struct device *dev,
 	struct hid_device *hdev = container_of(dev, struct hid_device, dev);
 	struct ntrig_data *nd = hid_get_drvdata(hdev);
 
-	unsigned long val;
-
-	if (strict_strtoul(buf, 0, &val))
-		return -EINVAL;
+	u8 val;
+	int rv;
 
+	rv = kstrtou8(buf, 0, &val);
+	if (rv < 0)
+		return rv;
 	/*
 	 * No more than 8 terminal frames have been observed so far
 	 * and higher slack is highly likely to leave the single
diff --git a/drivers/hid/hid-roccat-kone.c b/drivers/hid/hid-roccat-kone.c
index cbd8cc4..f803932 100644
--- a/drivers/hid/hid-roccat-kone.c
+++ b/drivers/hid/hid-roccat-kone.c
@@ -464,13 +464,13 @@ static ssize_t kone_sysfs_set_tcu(struct device *dev,
 	struct kone_device *kone;
 	struct usb_device *usb_dev;
 	int retval;
-	unsigned long state;
+	int state;
 
 	dev = dev->parent->parent;
 	kone = hid_get_drvdata(dev_get_drvdata(dev));
 	usb_dev = interface_to_usbdev(to_usb_interface(dev));
 
-	retval = strict_strtoul(buf, 10, &state);
+	retval = kstrtoint(buf, 10, &state);
 	if (retval)
 		return retval;
 
@@ -551,13 +551,13 @@ static ssize_t kone_sysfs_set_startup_profile(struct device *dev,
 	struct kone_device *kone;
 	struct usb_device *usb_dev;
 	int retval;
-	unsigned long new_startup_profile;
+	int new_startup_profile;
 
 	dev = dev->parent->parent;
 	kone = hid_get_drvdata(dev_get_drvdata(dev));
 	usb_dev = interface_to_usbdev(to_usb_interface(dev));
 
-	retval = strict_strtoul(buf, 10, &new_startup_profile);
+	retval = kstrtoint(buf, 10, &new_startup_profile);
 	if (retval)
 		return retval;
 
diff --git a/drivers/hid/hid-roccat-koneplus.c b/drivers/hid/hid-roccat-koneplus.c
index 1608c8d..6e13756 100644
--- a/drivers/hid/hid-roccat-koneplus.c
+++ b/drivers/hid/hid-roccat-koneplus.c
@@ -463,14 +463,14 @@ static ssize_t koneplus_sysfs_set_startup_profile(struct device *dev,
 {
 	struct koneplus_device *koneplus;
 	struct usb_device *usb_dev;
-	unsigned long profile;
+	u8 profile;
 	int retval;
 
 	dev = dev->parent->parent;
 	koneplus = hid_get_drvdata(dev_get_drvdata(dev));
 	usb_dev = interface_to_usbdev(to_usb_interface(dev));
 
-	retval = strict_strtoul(buf, 10, &profile);
+	retval = kstrtou8(buf, 10, &profile);
 	if (retval)
 		return retval;
 
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 20/52] kstrtox: convert drivers/hwmon/
  2011-02-05 14:20 [PATCH 01/52] kstrtox: converting strings to integers done (hopefully) right Alexey Dobriyan
                   ` (17 preceding siblings ...)
  2011-02-05 14:20 ` [PATCH 19/52] kstrtox: convert drivers/hid/ Alexey Dobriyan
@ 2011-02-05 14:20 ` Alexey Dobriyan
  2011-02-05 14:20 ` [PATCH 21/52] kstrtox: convert drivers/ide/ Alexey Dobriyan
                   ` (31 subsequent siblings)
  50 siblings, 0 replies; 58+ messages in thread
From: Alexey Dobriyan @ 2011-02-05 14:20 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, adobriyan


Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
 drivers/hwmon/adcxx.c     |    8 ++-
 drivers/hwmon/adm1031.c   |    6 +-
 drivers/hwmon/adm9240.c   |    2 +-
 drivers/hwmon/adt7411.c   |    8 ++-
 drivers/hwmon/adt7462.c   |   87 +++++++++++++++++++++++++----------
 drivers/hwmon/adt7470.c   |   80 +++++++++++++++++++++++----------
 drivers/hwmon/adt7475.c   |   83 +++++++++++++++++++---------------
 drivers/hwmon/amc6821.c   |   45 ++++++++++++-------
 drivers/hwmon/applesmc.c  |   27 +++++++-----
 drivers/hwmon/asc7621.c   |   83 ++++++++++++++++++++++------------
 drivers/hwmon/ds620.c     |    2 +-
 drivers/hwmon/emc1403.c   |   17 ++++---
 drivers/hwmon/emc2103.c   |   32 +++++++------
 drivers/hwmon/f71882fg.c  |   62 +++++++++++++-------------
 drivers/hwmon/g760a.c     |    6 ++-
 drivers/hwmon/gpio-fan.c  |   24 +++++++---
 drivers/hwmon/ibmaem.c    |    4 +-
 drivers/hwmon/it87.c      |  109 ++++++++++++++++++++++++++++++---------------
 drivers/hwmon/jc42.c      |   34 +++++++-------
 drivers/hwmon/lis3lv02d.c |    8 ++-
 drivers/hwmon/lm73.c      |    3 +-
 drivers/hwmon/lm75.c      |    4 +-
 drivers/hwmon/lm90.c      |   16 +++---
 drivers/hwmon/lm95241.c   |    8 ++--
 drivers/hwmon/pc87427.c   |   20 ++++++---
 drivers/hwmon/tmp102.c    |    5 +-
 drivers/hwmon/tmp401.c    |   37 +++++++++------
 drivers/hwmon/w83791d.c   |   28 +++++++----
 drivers/hwmon/w83792d.c   |    2 +-
 drivers/hwmon/w83793.c    |    2 +-
 drivers/hwmon/w83795.c    |  109 +++++++++++++++++++++++++++++---------------
 31 files changed, 603 insertions(+), 358 deletions(-)

diff --git a/drivers/hwmon/adcxx.c b/drivers/hwmon/adcxx.c
index fbdc765..b6367e8 100644
--- a/drivers/hwmon/adcxx.c
+++ b/drivers/hwmon/adcxx.c
@@ -123,10 +123,12 @@ static ssize_t adcxx_set_max(struct device *dev,
 {
 	struct spi_device *spi = to_spi_device(dev);
 	struct adcxx *adc = dev_get_drvdata(&spi->dev);
-	unsigned long value;
+	u32 value;
+	int rv;
 
-	if (strict_strtoul(buf, 10, &value))
-		return -EINVAL;
+	rv = kstrtou32(buf, 10, &value);
+	if (rv < 0)
+		return rv;
 
 	if (mutex_lock_interruptible(&adc->lock))
 		return -ERESTARTSYS;
diff --git a/drivers/hwmon/adm1031.c b/drivers/hwmon/adm1031.c
index 0683e6b..641a7e9 100644
--- a/drivers/hwmon/adm1031.c
+++ b/drivers/hwmon/adm1031.c
@@ -763,12 +763,12 @@ static ssize_t set_update_interval(struct device *dev,
 {
 	struct i2c_client *client = to_i2c_client(dev);
 	struct adm1031_data *data = i2c_get_clientdata(client);
-	unsigned long val;
+	unsigned int val;
 	int i, err;
 	u8 reg;
 
-	err = strict_strtoul(buf, 10, &val);
-	if (err)
+	err = kstrtouint(buf, 10, &val);
+	if (err < 0)
 		return err;
 
 	/*
diff --git a/drivers/hwmon/adm9240.c b/drivers/hwmon/adm9240.c
index 9e234b9..3f63f5f 100644
--- a/drivers/hwmon/adm9240.c
+++ b/drivers/hwmon/adm9240.c
@@ -503,7 +503,7 @@ static ssize_t chassis_clear(struct device *dev,
 	struct adm9240_data *data = i2c_get_clientdata(client);
 	unsigned long val;
 
-	if (strict_strtoul(buf, 10, &val) || val != 0)
+	if (kstrtoul(buf, 10, &val) || val != 0)
 		return -EINVAL;
 
 	mutex_lock(&data->update_lock);
diff --git a/drivers/hwmon/adt7411.c b/drivers/hwmon/adt7411.c
index f13c843..dbc35a8 100644
--- a/drivers/hwmon/adt7411.c
+++ b/drivers/hwmon/adt7411.c
@@ -195,10 +195,12 @@ static ssize_t adt7411_set_bit(struct device *dev,
 	struct i2c_client *client = to_i2c_client(dev);
 	struct adt7411_data *data = i2c_get_clientdata(client);
 	int ret;
-	unsigned long flag;
+	unsigned int flag;
 
-	ret = strict_strtoul(buf, 0, &flag);
-	if (ret || flag > 1)
+	ret = kstrtouint(buf, 0, &flag);
+	if (ret < 0)
+		return ret;
+	if (flag > 1)
 		return -EINVAL;
 
 	ret = adt7411_modify_bit(client, s_attr2->index, s_attr2->nr, flag);
diff --git a/drivers/hwmon/adt7462.c b/drivers/hwmon/adt7462.c
index 2af0c7b..c9a3dcb 100644
--- a/drivers/hwmon/adt7462.c
+++ b/drivers/hwmon/adt7462.c
@@ -832,8 +832,12 @@ static ssize_t set_temp_min(struct device *dev,
 	struct i2c_client *client = to_i2c_client(dev);
 	struct adt7462_data *data = i2c_get_clientdata(client);
 	long temp;
+	int rv;
 
-	if (strict_strtol(buf, 10, &temp) || !temp_enabled(data, attr->index))
+	rv = kstrtol(buf, 10, &temp);
+	if (rv < 0)
+		return rv;
+	if (!temp_enabled(data, attr->index))
 		return -EINVAL;
 
 	temp = DIV_ROUND_CLOSEST(temp, 1000) + 64;
@@ -870,8 +874,12 @@ static ssize_t set_temp_max(struct device *dev,
 	struct i2c_client *client = to_i2c_client(dev);
 	struct adt7462_data *data = i2c_get_clientdata(client);
 	long temp;
+	int rv;
 
-	if (strict_strtol(buf, 10, &temp) || !temp_enabled(data, attr->index))
+	rv = kstrtol(buf, 10, &temp);
+	if (rv < 0)
+		return rv;
+	if (!temp_enabled(data, attr->index))
 		return -EINVAL;
 
 	temp = DIV_ROUND_CLOSEST(temp, 1000) + 64;
@@ -934,8 +942,12 @@ static ssize_t set_volt_max(struct device *dev,
 	struct adt7462_data *data = i2c_get_clientdata(client);
 	int x = voltage_multiplier(data, attr->index);
 	long temp;
+	int rv;
 
-	if (strict_strtol(buf, 10, &temp) || !x)
+	rv = kstrtol(buf, 10, &temp);
+	if (rv < 0)
+		return rv;
+	if (!x)
 		return -EINVAL;
 
 	temp *= 1000; /* convert mV to uV */
@@ -976,8 +988,12 @@ static ssize_t set_volt_min(struct device *dev,
 	struct adt7462_data *data = i2c_get_clientdata(client);
 	int x = voltage_multiplier(data, attr->index);
 	long temp;
+	int rv;
 
-	if (strict_strtol(buf, 10, &temp) || !x)
+	rv = kstrtol(buf, 10, &temp);
+	if (rv < 0)
+		return rv;
+	if (!x)
 		return -EINVAL;
 
 	temp *= 1000; /* convert mV to uV */
@@ -1065,9 +1081,12 @@ static ssize_t set_fan_min(struct device *dev,
 	struct i2c_client *client = to_i2c_client(dev);
 	struct adt7462_data *data = i2c_get_clientdata(client);
 	long temp;
+	int rv;
 
-	if (strict_strtol(buf, 10, &temp) || !temp ||
-	    !fan_enabled(data, attr->index))
+	rv = kstrtol(buf, 10, &temp);
+	if (rv < 0)
+		return rv;
+	if (!temp || !fan_enabled(data, attr->index))
 		return -EINVAL;
 
 	temp = FAN_RPM_TO_PERIOD(temp);
@@ -1114,9 +1133,11 @@ static ssize_t set_force_pwm_max(struct device *dev,
 	struct adt7462_data *data = i2c_get_clientdata(client);
 	long temp;
 	u8 reg;
+	int rv;
 
-	if (strict_strtol(buf, 10, &temp))
-		return -EINVAL;
+	rv = kstrtol(buf, 10, &temp);
+	if (rv < 0)
+		return rv;
 
 	mutex_lock(&data->lock);
 	reg = i2c_smbus_read_byte_data(client, ADT7462_REG_CFG2);
@@ -1146,9 +1167,11 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *devattr,
 	struct i2c_client *client = to_i2c_client(dev);
 	struct adt7462_data *data = i2c_get_clientdata(client);
 	long temp;
+	int rv;
 
-	if (strict_strtol(buf, 10, &temp))
-		return -EINVAL;
+	rv = kstrtol(buf, 10, &temp);
+	if (rv < 0)
+		return rv;
 
 	temp = SENSORS_LIMIT(temp, 0, 255);
 
@@ -1176,9 +1199,11 @@ static ssize_t set_pwm_max(struct device *dev,
 	struct i2c_client *client = to_i2c_client(dev);
 	struct adt7462_data *data = i2c_get_clientdata(client);
 	long temp;
+	int rv;
 
-	if (strict_strtol(buf, 10, &temp))
-		return -EINVAL;
+	rv = kstrtol(buf, 10, &temp);
+	if (rv < 0)
+		return rv;
 
 	temp = SENSORS_LIMIT(temp, 0, 255);
 
@@ -1208,9 +1233,11 @@ static ssize_t set_pwm_min(struct device *dev,
 	struct i2c_client *client = to_i2c_client(dev);
 	struct adt7462_data *data = i2c_get_clientdata(client);
 	long temp;
+	int rv;
 
-	if (strict_strtol(buf, 10, &temp))
-		return -EINVAL;
+	rv = kstrtol(buf, 10, &temp);
+	if (rv < 0)
+		return rv;
 
 	temp = SENSORS_LIMIT(temp, 0, 255);
 
@@ -1242,9 +1269,11 @@ static ssize_t set_pwm_hyst(struct device *dev,
 	struct i2c_client *client = to_i2c_client(dev);
 	struct adt7462_data *data = i2c_get_clientdata(client);
 	long temp;
+	int rv;
 
-	if (strict_strtol(buf, 10, &temp))
-		return -EINVAL;
+	rv = kstrtol(buf, 10, &temp);
+	if (rv < 0)
+		return rv;
 
 	temp = DIV_ROUND_CLOSEST(temp, 1000);
 	temp = SENSORS_LIMIT(temp, 0, 15);
@@ -1288,9 +1317,11 @@ static ssize_t set_pwm_tmax(struct device *dev,
 	struct adt7462_data *data = i2c_get_clientdata(client);
 	int tmin, trange_value;
 	long trange;
+	int rv;
 
-	if (strict_strtol(buf, 10, &trange))
-		return -EINVAL;
+	rv = kstrtol(buf, 10, &trange);
+	if (rv < 0)
+		return rv;
 
 	/* trange = tmax - tmin */
 	tmin = (data->pwm_tmin[attr->index] - 64) * 1000;
@@ -1329,9 +1360,11 @@ static ssize_t set_pwm_tmin(struct device *dev,
 	struct i2c_client *client = to_i2c_client(dev);
 	struct adt7462_data *data = i2c_get_clientdata(client);
 	long temp;
+	int rv;
 
-	if (strict_strtol(buf, 10, &temp))
-		return -EINVAL;
+	rv = kstrtol(buf, 10, &temp);
+	if (rv < 0)
+		return rv;
 
 	temp = DIV_ROUND_CLOSEST(temp, 1000) + 64;
 	temp = SENSORS_LIMIT(temp, 0, 255);
@@ -1385,10 +1418,12 @@ static ssize_t set_pwm_auto(struct device *dev,
 	struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
 	struct i2c_client *client = to_i2c_client(dev);
 	struct adt7462_data *data = i2c_get_clientdata(client);
-	long temp;
+	int temp;
+	int rv;
 
-	if (strict_strtol(buf, 10, &temp))
-		return -EINVAL;
+	rv = kstrtoint(buf, 10, &temp);
+	if (rv < 0)
+		return rv;
 
 	switch (temp) {
 	case 0: /* off */
@@ -1445,9 +1480,11 @@ static ssize_t set_pwm_auto_temp(struct device *dev,
 	struct i2c_client *client = to_i2c_client(dev);
 	struct adt7462_data *data = i2c_get_clientdata(client);
 	long temp;
+	int rv;
 
-	if (strict_strtol(buf, 10, &temp))
-		return -EINVAL;
+	rv = kstrtol(buf, 10, &temp);
+	if (rv < 0)
+		return rv;
 
 	temp = cvt_auto_temp(temp);
 	if (temp < 0)
diff --git a/drivers/hwmon/adt7470.c b/drivers/hwmon/adt7470.c
index c6d1ce0..37cf052 100644
--- a/drivers/hwmon/adt7470.c
+++ b/drivers/hwmon/adt7470.c
@@ -448,9 +448,11 @@ static ssize_t set_auto_update_interval(struct device *dev,
 	struct i2c_client *client = to_i2c_client(dev);
 	struct adt7470_data *data = i2c_get_clientdata(client);
 	long temp;
+	int rv;
 
-	if (strict_strtol(buf, 10, &temp))
-		return -EINVAL;
+	rv = kstrtol(buf, 10, &temp);
+	if (rv < 0)
+		return rv;
 
 	temp = SENSORS_LIMIT(temp, 0, 60000);
 
@@ -477,9 +479,11 @@ static ssize_t set_num_temp_sensors(struct device *dev,
 	struct i2c_client *client = to_i2c_client(dev);
 	struct adt7470_data *data = i2c_get_clientdata(client);
 	long temp;
+	int rv;
 
-	if (strict_strtol(buf, 10, &temp))
-		return -EINVAL;
+	rv = kstrtol(buf, 10, &temp);
+	if (rv < 0)
+		return rv;
 
 	temp = SENSORS_LIMIT(temp, -1, 10);
 
@@ -510,9 +514,11 @@ static ssize_t set_temp_min(struct device *dev,
 	struct i2c_client *client = to_i2c_client(dev);
 	struct adt7470_data *data = i2c_get_clientdata(client);
 	long temp;
+	int rv;
 
-	if (strict_strtol(buf, 10, &temp))
-		return -EINVAL;
+	rv = kstrtol(buf, 10, &temp);
+	if (rv < 0)
+		return rv;
 
 	temp = DIV_ROUND_CLOSEST(temp, 1000);
 	temp = SENSORS_LIMIT(temp, 0, 255);
@@ -544,9 +550,11 @@ static ssize_t set_temp_max(struct device *dev,
 	struct i2c_client *client = to_i2c_client(dev);
 	struct adt7470_data *data = i2c_get_clientdata(client);
 	long temp;
+	int rv;
 
-	if (strict_strtol(buf, 10, &temp))
-		return -EINVAL;
+	rv = kstrtol(buf, 10, &temp);
+	if (rv < 0)
+		return rv;
 
 	temp = DIV_ROUND_CLOSEST(temp, 1000);
 	temp = SENSORS_LIMIT(temp, 0, 255);
@@ -599,8 +607,12 @@ static ssize_t set_fan_max(struct device *dev,
 	struct i2c_client *client = to_i2c_client(dev);
 	struct adt7470_data *data = i2c_get_clientdata(client);
 	long temp;
+	int rv;
 
-	if (strict_strtol(buf, 10, &temp) || !temp)
+	rv = kstrtol(buf, 10, &temp);
+	if (rv < 0)
+		return rv;
+	if (!temp)
 		return -EINVAL;
 
 	temp = FAN_RPM_TO_PERIOD(temp);
@@ -636,8 +648,12 @@ static ssize_t set_fan_min(struct device *dev,
 	struct i2c_client *client = to_i2c_client(dev);
 	struct adt7470_data *data = i2c_get_clientdata(client);
 	long temp;
+	int rv;
 
-	if (strict_strtol(buf, 10, &temp) || !temp)
+	rv = kstrtol(buf, 10, &temp);
+	if (rv < 0)
+		return rv;
+	if (!temp)
 		return -EINVAL;
 
 	temp = FAN_RPM_TO_PERIOD(temp);
@@ -681,9 +697,11 @@ static ssize_t set_force_pwm_max(struct device *dev,
 	struct adt7470_data *data = i2c_get_clientdata(client);
 	long temp;
 	u8 reg;
+	int rv;
 
-	if (strict_strtol(buf, 10, &temp))
-		return -EINVAL;
+	rv = kstrtol(buf, 10, &temp);
+	if (rv < 0)
+		return rv;
 
 	mutex_lock(&data->lock);
 	data->force_pwm_max = temp;
@@ -713,9 +731,11 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *devattr,
 	struct i2c_client *client = to_i2c_client(dev);
 	struct adt7470_data *data = i2c_get_clientdata(client);
 	long temp;
+	int rv;
 
-	if (strict_strtol(buf, 10, &temp))
-		return -EINVAL;
+	rv = kstrtol(buf, 10, &temp);
+	if (rv < 0)
+		return rv;
 
 	temp = SENSORS_LIMIT(temp, 0, 255);
 
@@ -745,9 +765,11 @@ static ssize_t set_pwm_max(struct device *dev,
 	struct i2c_client *client = to_i2c_client(dev);
 	struct adt7470_data *data = i2c_get_clientdata(client);
 	long temp;
+	int rv;
 
-	if (strict_strtol(buf, 10, &temp))
-		return -EINVAL;
+	rv = kstrtol(buf, 10, &temp);
+	if (rv < 0)
+		return rv;
 
 	temp = SENSORS_LIMIT(temp, 0, 255);
 
@@ -778,9 +800,11 @@ static ssize_t set_pwm_min(struct device *dev,
 	struct i2c_client *client = to_i2c_client(dev);
 	struct adt7470_data *data = i2c_get_clientdata(client);
 	long temp;
+	int rv;
 
-	if (strict_strtol(buf, 10, &temp))
-		return -EINVAL;
+	rv = kstrtol(buf, 10, &temp);
+	if (rv < 0)
+		return rv;
 
 	temp = SENSORS_LIMIT(temp, 0, 255);
 
@@ -821,9 +845,11 @@ static ssize_t set_pwm_tmin(struct device *dev,
 	struct i2c_client *client = to_i2c_client(dev);
 	struct adt7470_data *data = i2c_get_clientdata(client);
 	long temp;
+	int rv;
 
-	if (strict_strtol(buf, 10, &temp))
-		return -EINVAL;
+	rv = kstrtol(buf, 10, &temp);
+	if (rv < 0)
+		return rv;
 
 	temp = DIV_ROUND_CLOSEST(temp, 1000);
 	temp = SENSORS_LIMIT(temp, 0, 255);
@@ -856,11 +882,13 @@ static ssize_t set_pwm_auto(struct device *dev,
 	struct adt7470_data *data = i2c_get_clientdata(client);
 	int pwm_auto_reg = ADT7470_REG_PWM_CFG(attr->index);
 	int pwm_auto_reg_mask;
-	long temp;
+	u8 temp;
 	u8 reg;
+	int rv;
 
-	if (strict_strtol(buf, 10, &temp))
-		return -EINVAL;
+	rv = kstrtou8(buf, 10, &temp);
+	if (rv < 0)
+		return rv;
 
 	if (attr->index % 2)
 		pwm_auto_reg_mask = ADT7470_PWM2_AUTO_MASK;
@@ -918,9 +946,11 @@ static ssize_t set_pwm_auto_temp(struct device *dev,
 	int pwm_auto_reg = ADT7470_REG_PWM_AUTO_TEMP(attr->index);
 	long temp;
 	u8 reg;
+	int rv;
 
-	if (strict_strtol(buf, 10, &temp))
-		return -EINVAL;
+	rv = kstrtol(buf, 10, &temp);
+	if (rv < 0)
+		return rv;
 
 	temp = cvt_auto_temp(temp);
 	if (temp < 0)
diff --git a/drivers/hwmon/adt7475.c b/drivers/hwmon/adt7475.c
index b5fcd87..e1867fc 100644
--- a/drivers/hwmon/adt7475.c
+++ b/drivers/hwmon/adt7475.c
@@ -342,9 +342,11 @@ static ssize_t set_voltage(struct device *dev, struct device_attribute *attr,
 	struct adt7475_data *data = i2c_get_clientdata(client);
 	unsigned char reg;
 	long val;
+	int rv;
 
-	if (strict_strtol(buf, 10, &val))
-		return -EINVAL;
+	rv = kstrtol(buf, 10, &val);
+	if (rv < 0)
+		return rv;
 
 	mutex_lock(&data->lock);
 
@@ -431,9 +433,11 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *attr,
 	u8 out;
 	int temp;
 	long val;
+	int rv;
 
-	if (strict_strtol(buf, 10, &val))
-		return -EINVAL;
+	rv = kstrtol(buf, 10, &val);
+	if (rv < 0)
+		return rv;
 
 	mutex_lock(&data->lock);
 
@@ -545,9 +549,11 @@ static ssize_t set_point2(struct device *dev, struct device_attribute *attr,
 	struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr);
 	int temp;
 	long val;
+	int rv;
 
-	if (strict_strtol(buf, 10, &val))
-		return -EINVAL;
+	rv = kstrtol(buf, 10, &val);
+	if (rv < 0)
+		return rv;
 
 	mutex_lock(&data->lock);
 
@@ -601,9 +607,11 @@ static ssize_t set_tach(struct device *dev, struct device_attribute *attr,
 	struct i2c_client *client = to_i2c_client(dev);
 	struct adt7475_data *data = i2c_get_clientdata(client);
 	unsigned long val;
+	int rv;
 
-	if (strict_strtoul(buf, 10, &val))
-		return -EINVAL;
+	rv = kstrtoul(buf, 10, &val);
+	if (rv < 0)
+		return rv;
 
 	mutex_lock(&data->lock);
 
@@ -652,9 +660,11 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
 	struct adt7475_data *data = i2c_get_clientdata(client);
 	unsigned char reg = 0;
 	long val;
+	int rv;
 
-	if (strict_strtol(buf, 10, &val))
-		return -EINVAL;
+	rv = kstrtol(buf, 10, &val);
+	if (rv < 0)
+		return rv;
 
 	mutex_lock(&data->lock);
 
@@ -755,20 +765,20 @@ static ssize_t set_pwmchan(struct device *dev, struct device_attribute *attr,
 	struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr);
 	struct i2c_client *client = to_i2c_client(dev);
 	struct adt7475_data *data = i2c_get_clientdata(client);
-	int r;
 	long val;
+	int rv;
 
-	if (strict_strtol(buf, 10, &val))
-		return -EINVAL;
+	rv = kstrtol(buf, 10, &val);
+	if (rv < 0)
+		return rv;
 
 	mutex_lock(&data->lock);
 	/* Read Modify Write PWM values */
 	adt7475_read_pwm(client, sattr->index);
-	r = hw_set_pwm(client, sattr->index, data->pwmctl[sattr->index], val);
-	if (r)
-		count = r;
+	rv = hw_set_pwm(client, sattr->index, data->pwmctl[sattr->index], val);
 	mutex_unlock(&data->lock);
-
+	if (rv < 0)
+		return rv;
 	return count;
 }
 
@@ -778,20 +788,20 @@ static ssize_t set_pwmctrl(struct device *dev, struct device_attribute *attr,
 	struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr);
 	struct i2c_client *client = to_i2c_client(dev);
 	struct adt7475_data *data = i2c_get_clientdata(client);
-	int r;
 	long val;
+	int rv;
 
-	if (strict_strtol(buf, 10, &val))
-		return -EINVAL;
+	rv = kstrtol(buf, 10, &val);
+	if (rv < 0)
+		return rv;
 
 	mutex_lock(&data->lock);
 	/* Read Modify Write PWM values */
 	adt7475_read_pwm(client, sattr->index);
-	r = hw_set_pwm(client, sattr->index, val, data->pwmchan[sattr->index]);
-	if (r)
-		count = r;
+	rv = hw_set_pwm(client, sattr->index, val, data->pwmchan[sattr->index]);
 	mutex_unlock(&data->lock);
-
+	if (rv < 0)
+		return rv;
 	return count;
 }
 
@@ -818,9 +828,11 @@ static ssize_t set_pwmfreq(struct device *dev, struct device_attribute *attr,
 	struct adt7475_data *data = i2c_get_clientdata(client);
 	int out;
 	long val;
+	int rv;
 
-	if (strict_strtol(buf, 10, &val))
-		return -EINVAL;
+	rv = kstrtol(buf, 10, &val);
+	if (rv < 0)
+		return rv;
 
 	out = find_nearest(val, pwmfreq_table, ARRAY_SIZE(pwmfreq_table));
 
@@ -851,10 +863,12 @@ static ssize_t set_pwm_at_crit(struct device *dev,
 {
 	struct i2c_client *client = to_i2c_client(dev);
 	struct adt7475_data *data = i2c_get_clientdata(client);
-	long val;
+	int val;
+	int rv;
 
-	if (strict_strtol(buf, 10, &val))
-		return -EINVAL;
+	rv = kstrtoint(buf, 10, &val);
+	if (rv < 0)
+		return rv;
 	if (val != 0 && val != 1)
 		return -EINVAL;
 
@@ -881,14 +895,11 @@ static ssize_t set_vrm(struct device *dev, struct device_attribute *devattr,
 		       const char *buf, size_t count)
 {
 	struct adt7475_data *data = dev_get_drvdata(dev);
-	long val;
-
-	if (strict_strtol(buf, 10, &val))
-		return -EINVAL;
-	if (val < 0 || val > 255)
-		return -EINVAL;
-	data->vrm = val;
+	int rv;
 
+	rv = kstrtou8(buf, 10, &data->vrm);
+	if (rv < 0)
+		return rv;
 	return count;
 }
 
diff --git a/drivers/hwmon/amc6821.c b/drivers/hwmon/amc6821.c
index 4033974..b010cf4 100644
--- a/drivers/hwmon/amc6821.c
+++ b/drivers/hwmon/amc6821.c
@@ -237,9 +237,10 @@ static ssize_t set_temp(
 	struct amc6821_data *data = i2c_get_clientdata(client);
 	int ix = to_sensor_dev_attr(attr)->index;
 	long val;
+	int ret;
 
-	int ret = strict_strtol(buf, 10, &val);
-	if (ret)
+	ret = kstrtol(buf, 10, &val);
+	if (ret < 0)
 		return ret;
 	val = SENSORS_LIMIT(val / 1000, -128, 127);
 
@@ -327,8 +328,10 @@ static ssize_t set_pwm1(
 	struct i2c_client *client = to_i2c_client(dev);
 	struct amc6821_data *data = i2c_get_clientdata(client);
 	long val;
-	int ret = strict_strtol(buf, 10, &val);
-	if (ret)
+	int ret;
+
+	ret = kstrtol(buf, 10, &val);
+	if (ret < 0)
 		return ret;
 
 	mutex_lock(&data->update_lock);
@@ -355,9 +358,11 @@ static ssize_t set_pwm1_enable(
 {
 	struct i2c_client *client = to_i2c_client(dev);
 	struct amc6821_data *data = i2c_get_clientdata(client);
-	long val;
-	int config = strict_strtol(buf, 10, &val);
-	if (config)
+	int val;
+	int config;
+
+	config = kstrtoint(buf, 10, &val);
+	if (config < 0)
 		return config;
 
 	config = i2c_smbus_read_byte_data(client, AMC6821_REG_CONF1);
@@ -477,8 +482,10 @@ static ssize_t set_temp_auto_point_temp(
 	u8 reg;
 	int dpwm;
 	long val;
-	int ret = strict_strtol(buf, 10, &val);
-	if (ret)
+	int ret;
+
+	ret = kstrtol(buf, 10, &val);
+	if (ret < 0)
 		return ret;
 
 	switch (nr) {
@@ -556,8 +563,10 @@ static ssize_t set_pwm1_auto_point_pwm(
 	struct amc6821_data *data = i2c_get_clientdata(client);
 	int dpwm;
 	long val;
-	int ret = strict_strtol(buf, 10, &val);
-	if (ret)
+	int ret;
+
+	ret = kstrtol(buf, 10, &val);
+	if (ret < 0)
 		return ret;
 
 	mutex_lock(&data->update_lock);
@@ -623,8 +632,10 @@ static ssize_t set_fan(
 	struct amc6821_data *data = i2c_get_clientdata(client);
 	long val;
 	int ix = to_sensor_dev_attr(attr)->index;
-	int ret = strict_strtol(buf, 10, &val);
-	if (ret)
+	int ret;
+
+	ret = kstrtol(buf, 10, &val);
+	if (ret < 0)
 		return ret;
 	val = 1 > val ? 0xFFFF : 6000000/val;
 
@@ -664,9 +675,11 @@ static ssize_t set_fan1_div(
 {
 	struct i2c_client *client = to_i2c_client(dev);
 	struct amc6821_data *data = i2c_get_clientdata(client);
-	long val;
-	int config = strict_strtol(buf, 10, &val);
-	if (config)
+	int val;
+	int config;
+
+	config = kstrtoint(buf, 10, &val);
+	if (config < 0)
 		return config;
 
 	config = i2c_smbus_read_byte_data(client, AMC6821_REG_CONF4);
diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
index 4c07436..303b519 100644
--- a/drivers/hwmon/applesmc.c
+++ b/drivers/hwmon/applesmc.c
@@ -777,12 +777,15 @@ static ssize_t applesmc_store_fan_speed(struct device *dev,
 					struct device_attribute *attr,
 					const char *sysfsbuf, size_t count)
 {
-	int ret;
 	unsigned long speed;
 	char newkey[5];
 	u8 buffer[2];
+	int ret;
 
-	if (strict_strtoul(sysfsbuf, 10, &speed) < 0 || speed >= 0x4000)
+	ret = kstrtoul(sysfsbuf, 10, &speed);
+	if (ret < 0)
+		return ret;
+	if (speed >= 0x4000)
 		return -EINVAL;		/* Bigger than a 14-bit value */
 
 	sprintf(newkey, fan_speed_fmt[to_option(attr)], to_index(attr));
@@ -790,11 +793,9 @@ static ssize_t applesmc_store_fan_speed(struct device *dev,
 	buffer[0] = (speed >> 6) & 0xff;
 	buffer[1] = (speed << 2) & 0xff;
 	ret = applesmc_write_key(newkey, buffer, 2);
-
 	if (ret)
 		return ret;
-	else
-		return count;
+	return count;
 }
 
 static ssize_t applesmc_show_fan_manual(struct device *dev,
@@ -817,13 +818,14 @@ static ssize_t applesmc_store_fan_manual(struct device *dev,
 					 struct device_attribute *attr,
 					 const char *sysfsbuf, size_t count)
 {
-	int ret;
 	u8 buffer[2];
 	unsigned long input;
 	u16 val;
+	int ret;
 
-	if (strict_strtoul(sysfsbuf, 10, &input) < 0)
-		return -EINVAL;
+	ret = kstrtoul(sysfsbuf, 10, &input);
+	if (ret < 0)
+		return ret;
 
 	ret = applesmc_read_key(FANS_MANUAL, buffer, 2);
 	val = (buffer[0] << 8 | buffer[1]);
@@ -975,10 +977,13 @@ static ssize_t applesmc_key_at_index_show(struct device *dev,
 static ssize_t applesmc_key_at_index_store(struct device *dev,
 	struct device_attribute *attr, const char *sysfsbuf, size_t count)
 {
-	unsigned long newkey;
+	unsigned int newkey;
+	int rv;
 
-	if (strict_strtoul(sysfsbuf, 10, &newkey) < 0
-	    || newkey >= smcreg.key_count)
+	rv = kstrtouint(sysfsbuf, 10, &newkey);
+	if (rv < 0)
+		return rv;
+	if (newkey >= smcreg.key_count)
 		return -EINVAL;
 
 	key_at_index = newkey;
diff --git a/drivers/hwmon/asc7621.c b/drivers/hwmon/asc7621.c
index d2596ce..03aa1bd 100644
--- a/drivers/hwmon/asc7621.c
+++ b/drivers/hwmon/asc7621.c
@@ -187,9 +187,11 @@ static ssize_t store_u8(struct device *dev, struct device_attribute *attr,
 {
 	SETUP_STORE_data_param(dev, attr);
 	long reqval;
+	int rv;
 
-	if (strict_strtol(buf, 10, &reqval))
-		return -EINVAL;
+	rv = kstrtol(buf, 10, &reqval);
+	if (rv < 0)
+		return rv;
 
 	reqval = SENSORS_LIMIT(reqval, 0, 255);
 
@@ -220,9 +222,11 @@ static ssize_t store_bitmask(struct device *dev,
 	SETUP_STORE_data_param(dev, attr);
 	long reqval;
 	u8 currval;
+	int rv;
 
-	if (strict_strtol(buf, 10, &reqval))
-		return -EINVAL;
+	rv = kstrtol(buf, 10, &reqval);
+	if (rv < 0)
+		return rv;
 
 	reqval = SENSORS_LIMIT(reqval, 0, param->mask[0]);
 
@@ -264,9 +268,11 @@ static ssize_t store_fan16(struct device *dev,
 {
 	SETUP_STORE_data_param(dev, attr);
 	long reqval;
+	int rv;
 
-	if (strict_strtol(buf, 10, &reqval))
-		return -EINVAL;
+	rv = kstrtol(buf, 10, &reqval);
+	if (rv < 0)
+		return rv;
 
 	/* If a minimum RPM of zero is requested, then we set the register to
 	   0xffff. This value allows the fan to be stopped completely without
@@ -337,9 +343,11 @@ static ssize_t store_in8(struct device *dev, struct device_attribute *attr,
 	SETUP_STORE_data_param(dev, attr);
 	long reqval;
 	u8 nr = sda->index;
+	int rv;
 
-	if (strict_strtol(buf, 10, &reqval))
-		return -EINVAL;
+	rv = kstrtol(buf, 10, &reqval);
+	if (rv < 0)
+		return rv;
 
 	reqval = SENSORS_LIMIT(reqval, 0, 0xffff);
 
@@ -370,9 +378,11 @@ static ssize_t store_temp8(struct device *dev,
 	SETUP_STORE_data_param(dev, attr);
 	long reqval;
 	s8 temp;
+	int rv;
 
-	if (strict_strtol(buf, 10, &reqval))
-		return -EINVAL;
+	rv = kstrtol(buf, 10, &reqval);
+	if (rv < 0)
+		return rv;
 
 	reqval = SENSORS_LIMIT(reqval, -127000, 127000);
 
@@ -426,9 +436,11 @@ static ssize_t store_temp62(struct device *dev,
 	SETUP_STORE_data_param(dev, attr);
 	long reqval, i, f;
 	s8 temp;
+	int rv;
 
-	if (strict_strtol(buf, 10, &reqval))
-		return -EINVAL;
+	rv = kstrtol(buf, 10, &reqval);
+	if (rv < 0)
+		return rv;
 
 	reqval = SENSORS_LIMIT(reqval, -32000, 31750);
 	i = reqval / 1000;
@@ -481,9 +493,11 @@ static ssize_t store_ap2_temp(struct device *dev,
 	long reqval, auto_point1;
 	int i;
 	u8 currval, newval = 0;
+	int rv;
 
-	if (strict_strtol(buf, 10, &reqval))
-		return -EINVAL;
+	rv = kstrtol(buf, 10, &reqval);
+	if (rv < 0)
+		return rv;
 
 	mutex_lock(&data->update_lock);
 	auto_point1 = data->reg[param->msb[1]] * 1000;
@@ -529,7 +543,7 @@ static ssize_t store_pwm_ac(struct device *dev,
 			    const char *buf, size_t count)
 {
 	SETUP_STORE_data_param(dev, attr);
-	unsigned long reqval;
+	u8 reqval;
 	u8 currval, config, altbit, newval;
 	u16 map[] = {
 		0x04, 0x00, 0x01, 0xff, 0x02, 0xff, 0x05, 0x06,
@@ -537,10 +551,11 @@ static ssize_t store_pwm_ac(struct device *dev,
 		0x07, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
 		0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03,
 	};
+	int rv;
 
-	if (strict_strtoul(buf, 10, &reqval))
-		return -EINVAL;
-
+	rv = kstrtou8(buf, 10, &reqval);
+	if (rv < 0)
+		return rv;
 	if (reqval > 31)
 		return -EINVAL;
 
@@ -598,11 +613,13 @@ static ssize_t store_pwm_enable(struct device *dev,
 				const char *buf, size_t count)
 {
 	SETUP_STORE_data_param(dev, attr);
-	long reqval;
+	int reqval;
 	u8 currval, config, altbit, newval, minoff = 255;
+	int rv;
 
-	if (strict_strtol(buf, 10, &reqval))
-		return -EINVAL;
+	rv = kstrtoint(buf, 10, &reqval);
+	if (rv < 0)
+		return rv;
 
 	switch (reqval) {
 	case 0:
@@ -671,12 +688,14 @@ static ssize_t store_pwm_freq(struct device *dev,
 			      const char *buf, size_t count)
 {
 	SETUP_STORE_data_param(dev, attr);
-	unsigned long reqval;
+	u32 reqval;
 	u8 currval, newval = 255;
 	int i;
+	int rv;
 
-	if (strict_strtoul(buf, 10, &reqval))
-		return -EINVAL;
+	rv = kstrtou32(buf, 10, &reqval);
+	if (rv < 0)
+		return rv;
 
 	for (i = 0; i < ARRAY_SIZE(asc7621_pwm_freq_map); i++) {
 		if (reqval == asc7621_pwm_freq_map[i]) {
@@ -720,12 +739,14 @@ static ssize_t store_pwm_ast(struct device *dev,
 			     const char *buf, size_t count)
 {
 	SETUP_STORE_data_param(dev, attr);
-	long reqval;
+	u32 reqval;
 	u8 currval, newval = 255;
 	u32 i;
+	int rv;
 
-	if (strict_strtol(buf, 10, &reqval))
-		return -EINVAL;
+	rv = kstrtou32(buf, 10, &reqval);
+	if (rv < 0)
+		return rv;
 
 	for (i = 0; i < ARRAY_SIZE(asc7621_pwm_auto_spinup_map); i++) {
 		if (reqval == asc7621_pwm_auto_spinup_map[i]) {
@@ -767,12 +788,14 @@ static ssize_t store_temp_st(struct device *dev,
 			     const char *buf, size_t count)
 {
 	SETUP_STORE_data_param(dev, attr);
-	long reqval;
+	u32 reqval;
 	u8 currval, newval = 255;
 	u32 i;
+	int rv;
 
-	if (strict_strtol(buf, 10, &reqval))
-		return -EINVAL;
+	rv = kstrtou32(buf, 10, &reqval);
+	if (rv < 0)
+		return rv;
 
 	for (i = 0; i < ARRAY_SIZE(asc7621_temp_smoothing_time_map); i++) {
 		if (reqval == asc7621_temp_smoothing_time_map[i]) {
diff --git a/drivers/hwmon/ds620.c b/drivers/hwmon/ds620.c
index 257957c..2a0529f 100644
--- a/drivers/hwmon/ds620.c
+++ b/drivers/hwmon/ds620.c
@@ -182,7 +182,7 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *da,
 	struct i2c_client *client = to_i2c_client(dev);
 	struct ds620_data *data = i2c_get_clientdata(client);
 
-	res = strict_strtol(buf, 10, &val);
+	res = kstrtol(buf, 10, &val);
 
 	if (res)
 		return res;
diff --git a/drivers/hwmon/emc1403.c b/drivers/hwmon/emc1403.c
index 5dea9fa..fe2b557 100644
--- a/drivers/hwmon/emc1403.c
+++ b/drivers/hwmon/emc1403.c
@@ -80,8 +80,9 @@ static ssize_t store_temp(struct device *dev,
 	unsigned long val;
 	int retval;
 
-	if (strict_strtoul(buf, 10, &val))
-		return -EINVAL;
+	retval = kstrtoul(buf, 10, &val);
+	if (retval < 0)
+		return retval;
 	retval = i2c_smbus_write_byte_data(client, sda->index,
 					DIV_ROUND_CLOSEST(val, 1000));
 	if (retval < 0)
@@ -95,11 +96,12 @@ static ssize_t store_bit(struct device *dev,
 	struct i2c_client *client = to_i2c_client(dev);
 	struct thermal_data *data = i2c_get_clientdata(client);
 	struct sensor_device_attribute_2 *sda = to_sensor_dev_attr_2(attr);
-	unsigned long val;
+	int val;
 	int retval;
 
-	if (strict_strtoul(buf, 10, &val))
-		return -EINVAL;
+	retval = kstrtoint(buf, 10, &val);
+	if (retval < 0)
+		return retval;
 
 	mutex_lock(&data->mutex);
 	retval = i2c_smbus_read_byte_data(client, sda->nr);
@@ -151,8 +153,9 @@ static ssize_t store_hyst(struct device *dev,
 	int hyst;
 	unsigned long val;
 
-	if (strict_strtoul(buf, 10, &val))
-		return -EINVAL;
+	retval = kstrtoul(buf, 10, &val);
+	if (retval < 0)
+		return retval;
 
 	mutex_lock(&data->mutex);
 	retval = i2c_smbus_read_byte_data(client, sda->index);
diff --git a/drivers/hwmon/emc2103.c b/drivers/hwmon/emc2103.c
index af914ad..72bcc0e 100644
--- a/drivers/hwmon/emc2103.c
+++ b/drivers/hwmon/emc2103.c
@@ -243,10 +243,11 @@ static ssize_t set_temp_min(struct device *dev, struct device_attribute *da,
 	struct i2c_client *client = to_i2c_client(dev);
 	struct emc2103_data *data = i2c_get_clientdata(client);
 	long val;
+	int result;
 
-	int result = strict_strtol(buf, 10, &val);
+	result = kstrtol(buf, 10, &val);
 	if (result < 0)
-		return -EINVAL;
+		return result;
 
 	val = DIV_ROUND_CLOSEST(val, 1000);
 	if ((val < -63) || (val > 127))
@@ -267,10 +268,11 @@ static ssize_t set_temp_max(struct device *dev, struct device_attribute *da,
 	struct i2c_client *client = to_i2c_client(dev);
 	struct emc2103_data *data = i2c_get_clientdata(client);
 	long val;
+	int result;
 
-	int result = strict_strtol(buf, 10, &val);
+	result = kstrtol(buf, 10, &val);
 	if (result < 0)
-		return -EINVAL;
+		return result;
 
 	val = DIV_ROUND_CLOSEST(val, 1000);
 	if ((val < -63) || (val > 127))
@@ -313,10 +315,11 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *da,
 	struct i2c_client *client = to_i2c_client(dev);
 	int new_range_bits, old_div = 8 / data->fan_multiplier;
 	long new_div;
+	int status;
 
-	int status = strict_strtol(buf, 10, &new_div);
+	status = kstrtol(buf, 10, &new_div);
 	if (status < 0)
-		return -EINVAL;
+		return status;
 
 	if (new_div == old_div) /* No change */
 		return count;
@@ -386,14 +389,14 @@ static ssize_t set_fan_target(struct device *dev, struct device_attribute *da,
 {
 	struct emc2103_data *data = emc2103_update_device(dev);
 	struct i2c_client *client = to_i2c_client(dev);
-	long rpm_target;
+	unsigned int rpm_target;
+	int result;
 
-	int result = strict_strtol(buf, 10, &rpm_target);
+	result = kstrtouint(buf, 10, &rpm_target);
 	if (result < 0)
-		return -EINVAL;
-
+		return result;
 	/* Datasheet states 16384 as maximum RPM target (table 3.2) */
-	if ((rpm_target < 0) || (rpm_target > 16384))
+	if (rpm_target > 16384)
 		return -EINVAL;
 
 	mutex_lock(&data->update_lock);
@@ -431,12 +434,13 @@ static ssize_t set_pwm_enable(struct device *dev, struct device_attribute *da,
 {
 	struct i2c_client *client = to_i2c_client(dev);
 	struct emc2103_data *data = i2c_get_clientdata(client);
-	long new_value;
+	int new_value;
 	u8 conf_reg;
+	int result;
 
-	int result = strict_strtol(buf, 10, &new_value);
+	result = kstrtoint(buf, 10, &new_value);
 	if (result < 0)
-		return -EINVAL;
+		return result;
 
 	mutex_lock(&data->update_lock);
 	switch (new_value) {
diff --git a/drivers/hwmon/f71882fg.c b/drivers/hwmon/f71882fg.c
index 3f49dd3..935910b 100644
--- a/drivers/hwmon/f71882fg.c
+++ b/drivers/hwmon/f71882fg.c
@@ -1135,8 +1135,8 @@ static ssize_t store_fan_full_speed(struct device *dev,
 	int err, nr = to_sensor_dev_attr_2(devattr)->index;
 	long val;
 
-	err = strict_strtol(buf, 10, &val);
-	if (err)
+	err = kstrtol(buf, 10, &val);
+	if (err < 0)
 		return err;
 
 	val = SENSORS_LIMIT(val, 23, 1500000);
@@ -1169,8 +1169,8 @@ static ssize_t store_fan_beep(struct device *dev, struct device_attribute
 	int err, nr = to_sensor_dev_attr_2(devattr)->index;
 	unsigned long val;
 
-	err = strict_strtoul(buf, 10, &val);
-	if (err)
+	err = kstrtoul(buf, 10, &val);
+	if (err < 0)
 		return err;
 
 	mutex_lock(&data->update_lock);
@@ -1222,8 +1222,8 @@ static ssize_t store_in_max(struct device *dev, struct device_attribute
 	int err;
 	long val;
 
-	err = strict_strtol(buf, 10, &val);
-	if (err)
+	err = kstrtol(buf, 10, &val);
+	if (err < 0)
 		return err;
 
 	val /= 8;
@@ -1256,8 +1256,8 @@ static ssize_t store_in_beep(struct device *dev, struct device_attribute
 	int err, nr = to_sensor_dev_attr_2(devattr)->index;
 	unsigned long val;
 
-	err = strict_strtoul(buf, 10, &val);
-	if (err)
+	err = kstrtoul(buf, 10, &val);
+	if (err < 0)
 		return err;
 
 	mutex_lock(&data->update_lock);
@@ -1326,8 +1326,8 @@ static ssize_t store_temp_max(struct device *dev, struct device_attribute
 	int err, nr = to_sensor_dev_attr_2(devattr)->index;
 	long val;
 
-	err = strict_strtol(buf, 10, &val);
-	if (err)
+	err = kstrtol(buf, 10, &val);
+	if (err < 0)
 		return err;
 
 	val /= 1000;
@@ -1368,8 +1368,8 @@ static ssize_t store_temp_max_hyst(struct device *dev, struct device_attribute
 	u8 reg;
 	long val;
 
-	err = strict_strtol(buf, 10, &val);
-	if (err)
+	err = kstrtol(buf, 10, &val);
+	if (err < 0)
 		return err;
 
 	val /= 1000;
@@ -1411,8 +1411,8 @@ static ssize_t store_temp_crit(struct device *dev, struct device_attribute
 	int err, nr = to_sensor_dev_attr_2(devattr)->index;
 	long val;
 
-	err = strict_strtol(buf, 10, &val);
-	if (err)
+	err = kstrtol(buf, 10, &val);
+	if (err < 0)
 		return err;
 
 	val /= 1000;
@@ -1472,8 +1472,8 @@ static ssize_t store_temp_beep(struct device *dev, struct device_attribute
 	int err, nr = to_sensor_dev_attr_2(devattr)->index;
 	unsigned long val;
 
-	err = strict_strtoul(buf, 10, &val);
-	if (err)
+	err = kstrtoul(buf, 10, &val);
+	if (err < 0)
 		return err;
 
 	mutex_lock(&data->update_lock);
@@ -1539,8 +1539,8 @@ static ssize_t store_pwm(struct device *dev,
 	int err, nr = to_sensor_dev_attr_2(devattr)->index;
 	long val;
 
-	err = strict_strtol(buf, 10, &val);
-	if (err)
+	err = kstrtol(buf, 10, &val);
+	if (err < 0)
 		return err;
 
 	val = SENSORS_LIMIT(val, 0, 255);
@@ -1605,8 +1605,8 @@ static ssize_t store_pwm_enable(struct device *dev, struct device_attribute
 	int err, nr = to_sensor_dev_attr_2(devattr)->index;
 	long val;
 
-	err = strict_strtol(buf, 10, &val);
-	if (err)
+	err = kstrtol(buf, 10, &val);
+	if (err < 0)
 		return err;
 
 	/* Special case for F8000 pwm channel 3 which only does auto mode */
@@ -1685,8 +1685,8 @@ static ssize_t store_pwm_auto_point_pwm(struct device *dev,
 	int point = to_sensor_dev_attr_2(devattr)->nr;
 	long val;
 
-	err = strict_strtol(buf, 10, &val);
-	if (err)
+	err = kstrtol(buf, 10, &val);
+	if (err < 0)
 		return err;
 
 	val = SENSORS_LIMIT(val, 0, 255);
@@ -1739,8 +1739,8 @@ static ssize_t store_pwm_auto_point_temp_hyst(struct device *dev,
 	u8 reg;
 	long val;
 
-	err = strict_strtol(buf, 10, &val);
-	if (err)
+	err = kstrtol(buf, 10, &val);
+	if (err < 0)
 		return err;
 
 	val /= 1000;
@@ -1785,8 +1785,8 @@ static ssize_t store_pwm_interpolate(struct device *dev,
 	int err, nr = to_sensor_dev_attr_2(devattr)->index;
 	unsigned long val;
 
-	err = strict_strtoul(buf, 10, &val);
-	if (err)
+	err = kstrtoul(buf, 10, &val);
+	if (err < 0)
 		return err;
 
 	mutex_lock(&data->update_lock);
@@ -1823,10 +1823,10 @@ static ssize_t store_pwm_auto_point_channel(struct device *dev,
 {
 	struct f71882fg_data *data = dev_get_drvdata(dev);
 	int err, nr = to_sensor_dev_attr_2(devattr)->index;
-	long val;
+	u8 val;
 
-	err = strict_strtol(buf, 10, &val);
-	if (err)
+	err = kstrtou8(buf, 10, &val);
+	if (err < 0)
 		return err;
 
 	switch (val) {
@@ -1876,8 +1876,8 @@ static ssize_t store_pwm_auto_point_temp(struct device *dev,
 	int point = to_sensor_dev_attr_2(devattr)->nr;
 	long val;
 
-	err = strict_strtol(buf, 10, &val);
-	if (err)
+	err = kstrtol(buf, 10, &val);
+	if (err < 0)
 		return err;
 
 	val /= 1000;
diff --git a/drivers/hwmon/g760a.c b/drivers/hwmon/g760a.c
index 1d6a6fa..32191de 100644
--- a/drivers/hwmon/g760a.c
+++ b/drivers/hwmon/g760a.c
@@ -165,9 +165,11 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *da,
 	struct i2c_client *client = to_i2c_client(dev);
 	struct g760a_data *data = g760a_update_client(dev);
 	unsigned long val;
+	int rv;
 
-	if (strict_strtoul(buf, 10, &val))
-		return -EINVAL;
+	rv = kstrtoul(buf, 10, &val);
+	if (rv < 0)
+		return rv;
 
 	mutex_lock(&data->update_lock);
 	data->set_cnt = PWM_TO_CNT(SENSORS_LIMIT(val, 0, 255));
diff --git a/drivers/hwmon/gpio-fan.c b/drivers/hwmon/gpio-fan.c
index f141a1d..5e7bc1e 100644
--- a/drivers/hwmon/gpio-fan.c
+++ b/drivers/hwmon/gpio-fan.c
@@ -222,11 +222,15 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
 	struct gpio_fan_data *fan_data = dev_get_drvdata(dev);
 	unsigned long pwm;
 	int speed_index;
-	int ret = count;
+	int ret;
 
-	if (strict_strtoul(buf, 10, &pwm) || pwm > 255)
+	ret = kstrtoul(buf, 10, &pwm);
+	if (ret < 0)
+		return ret;
+	if (pwm > 255)
 		return -EINVAL;
 
+	ret = count;
 	mutex_lock(&fan_data->lock);
 
 	if (!fan_data->pwm_enable) {
@@ -255,9 +259,13 @@ static ssize_t set_pwm_enable(struct device *dev, struct device_attribute *attr,
 			      const char *buf, size_t count)
 {
 	struct gpio_fan_data *fan_data = dev_get_drvdata(dev);
-	unsigned long val;
+	int val;
+	int rv;
 
-	if (strict_strtoul(buf, 10, &val) || val > 1)
+	rv = kstrtoint(buf, 10, &val);
+	if (rv < 0)
+		return rv;
+	if (val > 1)
 		return -EINVAL;
 
 	if (fan_data->pwm_enable == val)
@@ -312,11 +320,13 @@ static ssize_t set_rpm(struct device *dev, struct device_attribute *attr,
 {
 	struct gpio_fan_data *fan_data = dev_get_drvdata(dev);
 	unsigned long rpm;
-	int ret = count;
+	int ret;
 
-	if (strict_strtoul(buf, 10, &rpm))
-		return -EINVAL;
+	ret = kstrtoul(buf, 10, &rpm);
+	if (ret < 0)
+		return ret;
 
+	ret = count;
 	mutex_lock(&fan_data->lock);
 
 	if (!fan_data->pwm_enable) {
diff --git a/drivers/hwmon/ibmaem.c b/drivers/hwmon/ibmaem.c
index bc6e2ab..570acf8 100644
--- a/drivers/hwmon/ibmaem.c
+++ b/drivers/hwmon/ibmaem.c
@@ -922,8 +922,8 @@ static ssize_t aem_set_power_period(struct device *dev,
 	unsigned long temp;
 	int res;
 
-	res = strict_strtoul(buf, 10, &temp);
-	if (res)
+	res = kstrtoul(buf, 10, &temp);
+	if (res < 0)
 		return res;
 
 	if (temp < AEM_MIN_POWER_INTERVAL)
diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c
index 316b648..10120cf 100644
--- a/drivers/hwmon/it87.c
+++ b/drivers/hwmon/it87.c
@@ -440,9 +440,11 @@ static ssize_t set_in_min(struct device *dev, struct device_attribute *attr,
 
 	struct it87_data *data = dev_get_drvdata(dev);
 	unsigned long val;
+	int rv;
 
-	if (strict_strtoul(buf, 10, &val) < 0)
-		return -EINVAL;
+	rv = kstrtoul(buf, 10, &val);
+	if (rv < 0)
+		return rv;
 
 	mutex_lock(&data->update_lock);
 	data->in_min[nr] = in_to_reg(data, nr, val);
@@ -459,9 +461,11 @@ static ssize_t set_in_max(struct device *dev, struct device_attribute *attr,
 
 	struct it87_data *data = dev_get_drvdata(dev);
 	unsigned long val;
+	int rv;
 
-	if (strict_strtoul(buf, 10, &val) < 0)
-		return -EINVAL;
+	rv = kstrtoul(buf, 10, &val);
+	if (rv < 0)
+		return rv;
 
 	mutex_lock(&data->update_lock);
 	data->in_max[nr] = in_to_reg(data, nr, val);
@@ -535,9 +539,11 @@ static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr,
 
 	struct it87_data *data = dev_get_drvdata(dev);
 	long val;
+	int rv;
 
-	if (strict_strtol(buf, 10, &val) < 0)
-		return -EINVAL;
+	rv = kstrtol(buf, 10, &val);
+	if (rv < 0)
+		return rv;
 
 	mutex_lock(&data->update_lock);
 	data->temp_high[nr] = TEMP_TO_REG(val);
@@ -553,9 +559,11 @@ static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr,
 
 	struct it87_data *data = dev_get_drvdata(dev);
 	long val;
+	int rv;
 
-	if (strict_strtol(buf, 10, &val) < 0)
-		return -EINVAL;
+	rv = kstrtol(buf, 10, &val);
+	if (rv < 0)
+		return rv;
 
 	mutex_lock(&data->update_lock);
 	data->temp_low[nr] = TEMP_TO_REG(val);
@@ -598,11 +606,13 @@ static ssize_t set_sensor(struct device *dev, struct device_attribute *attr,
 	int nr = sensor_attr->index;
 
 	struct it87_data *data = dev_get_drvdata(dev);
-	long val;
+	int val;
 	u8 reg;
+	int rv;
 
-	if (strict_strtol(buf, 10, &val) < 0)
-		return -EINVAL;
+	rv = kstrtoint(buf, 10, &val);
+	if (rv < 0)
+		return rv;
 
 	reg = it87_read_value(data, IT87_REG_TEMP_ENABLE);
 	reg &= ~(1 << nr);
@@ -714,9 +724,11 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr,
 	struct it87_data *data = dev_get_drvdata(dev);
 	long val;
 	u8 reg;
+	int rv;
 
-	if (strict_strtol(buf, 10, &val) < 0)
-		return -EINVAL;
+	rv = kstrtol(buf, 10, &val);
+	if (rv < 0)
+		return rv;
 
 	mutex_lock(&data->update_lock);
 	reg = it87_read_value(data, IT87_REG_FAN_DIV);
@@ -747,9 +759,11 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr,
 	unsigned long val;
 	int min;
 	u8 old;
+	int rv;
 
-	if (strict_strtoul(buf, 10, &val) < 0)
-		return -EINVAL;
+	rv = kstrtoul(buf, 10, &val);
+	if (rv < 0)
+		return rv;
 
 	mutex_lock(&data->update_lock);
 	old = it87_read_value(data, IT87_REG_FAN_DIV);
@@ -815,9 +829,13 @@ static ssize_t set_pwm_enable(struct device *dev,
 	int nr = sensor_attr->index;
 
 	struct it87_data *data = dev_get_drvdata(dev);
-	long val;
+	int val;
+	int rv;
 
-	if (strict_strtol(buf, 10, &val) < 0 || val < 0 || val > 2)
+	rv = kstrtoint(buf, 10, &val);
+	if (rv < 0)
+		return rv;
+	if (val < 0 || val > 2)
 		return -EINVAL;
 
 	/* Check trip points before switching to automatic mode */
@@ -862,8 +880,12 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
 
 	struct it87_data *data = dev_get_drvdata(dev);
 	long val;
+	int rv;
 
-	if (strict_strtol(buf, 10, &val) < 0 || val < 0 || val > 255)
+	rv = kstrtol(buf, 10, &val);
+	if (rv < 0)
+		return rv;
+	if (val < 0 || val > 255)
 		return -EINVAL;
 
 	mutex_lock(&data->update_lock);
@@ -896,9 +918,11 @@ static ssize_t set_pwm_freq(struct device *dev,
 	struct it87_data *data = dev_get_drvdata(dev);
 	unsigned long val;
 	int i;
+	int rv;
 
-	if (strict_strtoul(buf, 10, &val) < 0)
-		return -EINVAL;
+	rv = kstrtoul(buf, 10, &val);
+	if (rv < 0)
+		return rv;
 
 	/* Search for the nearest available frequency */
 	for (i = 0; i < 7; i++) {
@@ -936,8 +960,9 @@ static ssize_t set_pwm_temp_map(struct device *dev,
 	int nr = sensor_attr->index;
 
 	struct it87_data *data = dev_get_drvdata(dev);
-	long val;
+	int val;
 	u8 reg;
+	int rv;
 
 	/* This check can go away if we ever support automatic fan speed
 	   control on newer chips. */
@@ -946,8 +971,9 @@ static ssize_t set_pwm_temp_map(struct device *dev,
 		return -EINVAL;
 	}
 
-	if (strict_strtol(buf, 10, &val) < 0)
-		return -EINVAL;
+	rv = kstrtoint(buf, 10, &val);
+	if (rv < 0)
+		return rv;
 
 	switch (val) {
 	case (1 << 0):
@@ -997,8 +1023,12 @@ static ssize_t set_auto_pwm(struct device *dev,
 	int nr = sensor_attr->nr;
 	int point = sensor_attr->index;
 	long val;
+	int rv;
 
-	if (strict_strtol(buf, 10, &val) < 0 || val < 0 || val > 255)
+	rv = kstrtol(buf, 10, &val);
+	if (rv < 0)
+		return rv;
+	if (val < 0 || val > 255)
 		return -EINVAL;
 
 	mutex_lock(&data->update_lock);
@@ -1030,8 +1060,12 @@ static ssize_t set_auto_temp(struct device *dev,
 	int nr = sensor_attr->nr;
 	int point = sensor_attr->index;
 	long val;
+	int rv;
 
-	if (strict_strtol(buf, 10, &val) < 0 || val < -128000 || val > 127000)
+	rv = kstrtol(buf, 10, &val);
+	if (rv < 0)
+		return rv;
+	if (val < -128000 || val > 127000)
 		return -EINVAL;
 
 	mutex_lock(&data->update_lock);
@@ -1122,9 +1156,11 @@ static ssize_t set_fan16_min(struct device *dev, struct device_attribute *attr,
 	int nr = sensor_attr->index;
 	struct it87_data *data = dev_get_drvdata(dev);
 	long val;
+	int rv;
 
-	if (strict_strtol(buf, 10, &val) < 0)
-		return -EINVAL;
+	rv = kstrtol(buf, 10, &val);
+	if (rv < 0)
+		return rv;
 
 	mutex_lock(&data->update_lock);
 	data->fan_min[nr] = FAN16_TO_REG(val);
@@ -1198,10 +1234,13 @@ static ssize_t set_beep(struct device *dev, struct device_attribute *attr,
 {
 	int bitnr = to_sensor_dev_attr(attr)->index;
 	struct it87_data *data = dev_get_drvdata(dev);
-	long val;
+	int val;
+	int rv;
 
-	if (strict_strtol(buf, 10, &val) < 0
-	 || (val != 0 && val != 1))
+	rv = kstrtoint(buf, 10, &val);
+	if (rv < 0)
+		return rv;
+	if (val != 0 && val != 1)
 		return -EINVAL;
 
 	mutex_lock(&data->update_lock);
@@ -1245,13 +1284,11 @@ static ssize_t store_vrm_reg(struct device *dev, struct device_attribute *attr,
 		const char *buf, size_t count)
 {
 	struct it87_data *data = dev_get_drvdata(dev);
-	unsigned long val;
-
-	if (strict_strtoul(buf, 10, &val) < 0)
-		return -EINVAL;
-
-	data->vrm = val;
+	int rv;
 
+	rv = kstrtou8(buf, 10, &data->vrm);
+	if (rv < 0)
+		return rv;
 	return count;
 }
 static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm_reg, store_vrm_reg);
diff --git a/drivers/hwmon/jc42.c b/drivers/hwmon/jc42.c
index 340fc78..2f269f8 100644
--- a/drivers/hwmon/jc42.c
+++ b/drivers/hwmon/jc42.c
@@ -307,17 +307,19 @@ static ssize_t set_##value(struct device *dev,				\
 {									\
 	struct i2c_client *client = to_i2c_client(dev);			\
 	struct jc42_data *data = i2c_get_clientdata(client);		\
-	int err, ret = count;						\
-	long val;							\
-	if (strict_strtol(buf, 10, &val) < 0)				\
-		return -EINVAL;						\
+	int val;							\
+	int ret;							\
+									\
+	ret = kstrtoint(buf, 10, &val);					\
+	if (ret < 0)							\
+		return ret;						\
 	mutex_lock(&data->update_lock);					\
 	data->value = jc42_temp_to_reg(val, data->extended);		\
-	err = jc42_write_value(client, reg, data->value);		\
-	if (err < 0)							\
-		ret = err;						\
+	ret = jc42_write_value(client, reg, data->value);		\
 	mutex_unlock(&data->update_lock);				\
-	return ret;							\
+	if (ret < 0)							\
+		return ret;						\
+	return count;							\
 }
 
 set(temp_min, JC42_REG_TEMP_LOWER);
@@ -334,11 +336,11 @@ static ssize_t set_temp_crit_hyst(struct device *dev,
 	struct jc42_data *data = i2c_get_clientdata(client);
 	long val;
 	int diff, hyst;
-	int err;
-	int ret = count;
+	int ret;
 
-	if (strict_strtoul(buf, 10, &val) < 0)
-		return -EINVAL;
+	ret = kstrtoul(buf, 10, &val);
+	if (ret < 0)
+		return ret;
 
 	diff = jc42_temp_from_reg(data->temp_crit) - val;
 	hyst = 0;
@@ -355,11 +357,11 @@ static ssize_t set_temp_crit_hyst(struct device *dev,
 	data->config = (data->config
 			& ~(JC42_CFG_HYST_MASK << JC42_CFG_HYST_SHIFT))
 	  | (hyst << JC42_CFG_HYST_SHIFT);
-	err = jc42_write_value(client, JC42_REG_CONFIG, data->config);
-	if (err < 0)
-		ret = err;
+	ret = jc42_write_value(client, JC42_REG_CONFIG, data->config);
 	mutex_unlock(&data->update_lock);
-	return ret;
+	if (ret < 0)
+		return ret;
+	return count;
 }
 
 static ssize_t show_alarm(struct device *dev,
diff --git a/drivers/hwmon/lis3lv02d.c b/drivers/hwmon/lis3lv02d.c
index d805e8e..f138183 100644
--- a/drivers/hwmon/lis3lv02d.c
+++ b/drivers/hwmon/lis3lv02d.c
@@ -754,10 +754,12 @@ static ssize_t lis3lv02d_rate_set(struct device *dev,
 				struct device_attribute *attr, const char *buf,
 				size_t count)
 {
-	unsigned long rate;
+	int rate;
+	int rv;
 
-	if (strict_strtoul(buf, 0, &rate))
-		return -EINVAL;
+	rv = kstrtoint(buf, 0, &rate);
+	if (rv < 0)
+		return rv;
 
 	lis3lv02d_sysfs_poweron(&lis3_dev);
 	if (lis3lv02d_set_odr(rate))
diff --git a/drivers/hwmon/lm73.c b/drivers/hwmon/lm73.c
index 29b9030..0ab02a6 100644
--- a/drivers/hwmon/lm73.c
+++ b/drivers/hwmon/lm73.c
@@ -49,8 +49,9 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *da,
 	struct i2c_client *client = to_i2c_client(dev);
 	long temp;
 	short value;
+	int status;
 
-	int status = strict_strtol(buf, 10, &temp);
+	status = kstrtol(buf, 10, &temp);
 	if (status < 0)
 		return status;
 
diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c
index f36eb80..dfddb06 100644
--- a/drivers/hwmon/lm75.c
+++ b/drivers/hwmon/lm75.c
@@ -106,8 +106,8 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *da,
 	long temp;
 	int error;
 
-	error = strict_strtol(buf, 10, &temp);
-	if (error)
+	error = kstrtol(buf, 10, &temp);
+	if (error < 0)
 		return error;
 
 	mutex_lock(&data->update_lock);
diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c
index 812781c..34907f5 100644
--- a/drivers/hwmon/lm90.c
+++ b/drivers/hwmon/lm90.c
@@ -708,7 +708,7 @@ static ssize_t set_temp8(struct device *dev, struct device_attribute *devattr,
 	long val;
 	int err;
 
-	err = strict_strtol(buf, 10, &val);
+	err = kstrtol(buf, 10, &val);
 	if (err < 0)
 		return err;
 
@@ -776,7 +776,7 @@ static ssize_t set_temp11(struct device *dev, struct device_attribute *devattr,
 	long val;
 	int err;
 
-	err = strict_strtol(buf, 10, &val);
+	err = kstrtol(buf, 10, &val);
 	if (err < 0)
 		return err;
 
@@ -837,7 +837,7 @@ static ssize_t set_temphyst(struct device *dev, struct device_attribute *dummy,
 	int err;
 	int temp;
 
-	err = strict_strtol(buf, 10, &val);
+	err = kstrtol(buf, 10, &val);
 	if (err < 0)
 		return err;
 
@@ -887,11 +887,11 @@ static ssize_t set_update_interval(struct device *dev,
 {
 	struct i2c_client *client = to_i2c_client(dev);
 	struct lm90_data *data = i2c_get_clientdata(client);
-	unsigned long val;
+	unsigned int val;
 	int err;
 
-	err = strict_strtoul(buf, 10, &val);
-	if (err)
+	err = kstrtouint(buf, 10, &val);
+	if (err < 0)
 		return err;
 
 	mutex_lock(&data->update_lock);
@@ -1055,10 +1055,10 @@ static ssize_t set_pec(struct device *dev, struct device_attribute *dummy,
 		       const char *buf, size_t count)
 {
 	struct i2c_client *client = to_i2c_client(dev);
-	long val;
+	int val;
 	int err;
 
-	err = strict_strtol(buf, 10, &val);
+	err = kstrtoint(buf, 10, &val);
 	if (err < 0)
 		return err;
 
diff --git a/drivers/hwmon/lm95241.c b/drivers/hwmon/lm95241.c
index 1a6dfb6..1c04660 100644
--- a/drivers/hwmon/lm95241.c
+++ b/drivers/hwmon/lm95241.c
@@ -160,7 +160,7 @@ static ssize_t set_type(struct device *dev, struct device_attribute *attr,
 	int shift;
 	u8 mask = to_sensor_dev_attr(attr)->index;
 
-	if (strict_strtoul(buf, 10, &val) < 0)
+	if (kstrtoul(buf, 10, &val) < 0)
 		return -EINVAL;
 	if (val != 1 && val != 2)
 		return -EINVAL;
@@ -207,7 +207,7 @@ static ssize_t set_min(struct device *dev, struct device_attribute *attr,
 	struct lm95241_data *data = i2c_get_clientdata(client);
 	long val;
 
-	if (strict_strtol(buf, 10, &val) < 0)
+	if (kstrtol(buf, 10, &val) < 0)
 		return -EINVAL;
 	if (val < -128000)
 		return -EINVAL;
@@ -245,7 +245,7 @@ static ssize_t set_max(struct device *dev, struct device_attribute *attr,
 	struct lm95241_data *data = i2c_get_clientdata(client);
 	long val;
 
-	if (strict_strtol(buf, 10, &val) < 0)
+	if (kstrtol(buf, 10, &val) < 0)
 		return -EINVAL;
 	if (val >= 256000)
 		return -EINVAL;
@@ -281,7 +281,7 @@ static ssize_t set_interval(struct device *dev, struct device_attribute *attr,
 	struct lm95241_data *data = i2c_get_clientdata(client);
 	unsigned long val;
 
-	if (strict_strtoul(buf, 10, &val) < 0)
+	if (kstrtoul(buf, 10, &val) < 0)
 		return -EINVAL;
 
 	data->interval = val * HZ / 1000;
diff --git a/drivers/hwmon/pc87427.c b/drivers/hwmon/pc87427.c
index 8da2181..7426024 100644
--- a/drivers/hwmon/pc87427.c
+++ b/drivers/hwmon/pc87427.c
@@ -417,9 +417,11 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute
 	int nr = to_sensor_dev_attr(devattr)->index;
 	unsigned long val;
 	int iobase = data->address[LD_FAN];
+	int rv;
 
-	if (strict_strtoul(buf, 10, &val) < 0)
-		return -EINVAL;
+	rv = kstrtoul(buf, 10, &val);
+	if (rv < 0)
+		return rv;
 
 	mutex_lock(&data->lock);
 	outb(BANK_FM(nr), iobase + PC87427_REG_BANK);
@@ -571,8 +573,12 @@ static ssize_t set_pwm_enable(struct device *dev, struct device_attribute
 	struct pc87427_data *data = dev_get_drvdata(dev);
 	int nr = to_sensor_dev_attr(devattr)->index;
 	unsigned long val;
+	int rv;
 
-	if (strict_strtoul(buf, 10, &val) < 0 || val > 2)
+	rv = kstrtoul(buf, 10, &val);
+	if (rv < 0)
+		return rv;
+	if (val > 2)
 		return -EINVAL;
 	/* Can't go to automatic mode if it isn't configured */
 	if (val == 2 && !(data->pwm_auto_ok & (1 << nr)))
@@ -600,12 +606,14 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute
 {
 	struct pc87427_data *data = dev_get_drvdata(dev);
 	int nr = to_sensor_dev_attr(devattr)->index;
-	unsigned long val;
+	u8 val;
 	int iobase = data->address[LD_FAN];
 	u8 mode;
+	int rv;
 
-	if (strict_strtoul(buf, 10, &val) < 0 || val > 0xff)
-		return -EINVAL;
+	rv = kstrtou8(buf, 10, &val);
+	if (rv < 0)
+		return rv;
 
 	mutex_lock(&data->lock);
 	pc87427_readall_pwm(data, nr);
diff --git a/drivers/hwmon/tmp102.c b/drivers/hwmon/tmp102.c
index 93187c3..f839a78 100644
--- a/drivers/hwmon/tmp102.c
+++ b/drivers/hwmon/tmp102.c
@@ -124,8 +124,9 @@ static ssize_t tmp102_set_temp(struct device *dev,
 	long val;
 	int status;
 
-	if (strict_strtol(buf, 10, &val) < 0)
-		return -EINVAL;
+	status = kstrtol(buf, 10, &val);
+	if (status < 0)
+		return status;
 	val = SENSORS_LIMIT(val, -256000, 255000);
 
 	mutex_lock(&tmp102->lock);
diff --git a/drivers/hwmon/tmp401.c b/drivers/hwmon/tmp401.c
index ad8d535..6e67bdb 100644
--- a/drivers/hwmon/tmp401.c
+++ b/drivers/hwmon/tmp401.c
@@ -333,9 +333,11 @@ static ssize_t store_temp_min(struct device *dev, struct device_attribute
 	struct tmp401_data *data = tmp401_update_device(dev);
 	long val;
 	u16 reg;
+	int rv;
 
-	if (strict_strtol(buf, 10, &val))
-		return -EINVAL;
+	rv = kstrtol(buf, 10, &val);
+	if (rv < 0)
+		return rv;
 
 	reg = tmp401_temp_to_register(val, data->config);
 
@@ -360,9 +362,11 @@ static ssize_t store_temp_max(struct device *dev, struct device_attribute
 	struct tmp401_data *data = tmp401_update_device(dev);
 	long val;
 	u16 reg;
+	int rv;
 
-	if (strict_strtol(buf, 10, &val))
-		return -EINVAL;
+	rv = kstrtol(buf, 10, &val);
+	if (rv < 0)
+		return rv;
 
 	reg = tmp401_temp_to_register(val, data->config);
 
@@ -387,9 +391,11 @@ static ssize_t store_temp_crit(struct device *dev, struct device_attribute
 	struct tmp401_data *data = tmp401_update_device(dev);
 	long val;
 	u8 reg;
+	int rv;
 
-	if (strict_strtol(buf, 10, &val))
-		return -EINVAL;
+	rv = kstrtol(buf, 10, &val);
+	if (rv < 0)
+		return rv;
 
 	reg = tmp401_crit_temp_to_register(val, data->config);
 
@@ -412,9 +418,11 @@ static ssize_t store_temp_crit_hyst(struct device *dev, struct device_attribute
 	struct tmp401_data *data = tmp401_update_device(dev);
 	long val;
 	u8 reg;
+	int rv;
 
-	if (strict_strtol(buf, 10, &val))
-		return -EINVAL;
+	rv = kstrtol(buf, 10, &val);
+	if (rv < 0)
+		return rv;
 
 	if (data->config & TMP401_CONFIG_RANGE)
 		val = SENSORS_LIMIT(val, -64000, 191000);
@@ -445,18 +453,19 @@ static ssize_t store_temp_crit_hyst(struct device *dev, struct device_attribute
 static ssize_t reset_temp_history(struct device *dev,
 	struct device_attribute	*devattr, const char *buf, size_t count)
 {
-	long val;
-
-	if (strict_strtol(buf, 10, &val))
-		return -EINVAL;
+	int val;
+	int rv;
 
+	rv = kstrtoint(buf, 10, &val);
+	if (rv < 0)
+		return rv;
 	if (val != 1) {
-		dev_err(dev, "temp_reset_history value %ld not"
+		dev_err(dev, "temp_reset_history value %d not"
 			" supported. Use 1 to reset the history!\n", val);
 		return -EINVAL;
 	}
 	i2c_smbus_write_byte_data(to_i2c_client(dev),
-		TMP411_TEMP_LOWEST_MSB[0], val);
+		TMP411_TEMP_LOWEST_MSB[0], 1);
 
 	return count;
 }
diff --git a/drivers/hwmon/w83791d.c b/drivers/hwmon/w83791d.c
index 400a88b..c588a76 100644
--- a/drivers/hwmon/w83791d.c
+++ b/drivers/hwmon/w83791d.c
@@ -710,9 +710,11 @@ static ssize_t store_pwm(struct device *dev, struct device_attribute *attr,
 	struct w83791d_data *data = i2c_get_clientdata(client);
 	int nr = sensor_attr->index;
 	unsigned long val;
+	int rv;
 
-	if (strict_strtoul(buf, 10, &val))
-		return -EINVAL;
+	rv = kstrtoul(buf, 10, &val);
+	if (rv < 0)
+		return rv;
 
 	mutex_lock(&data->update_lock);
 	data->pwm[nr] = SENSORS_LIMIT(val, 0, 255);
@@ -750,15 +752,17 @@ static ssize_t store_pwmenable(struct device *dev,
 	struct i2c_client *client = to_i2c_client(dev);
 	struct w83791d_data *data = i2c_get_clientdata(client);
 	int nr = sensor_attr->index;
-	unsigned long val;
+	u8 val;
 	u8 reg_cfg_tmp;
 	u8 reg_idx = 0;
 	u8 val_shift = 0;
 	u8 keep_mask = 0;
+	int ret;
 
-	int ret = strict_strtoul(buf, 10, &val);
-
-	if (ret || val < 1 || val > 3)
+	ret = kstrtou8(buf, 10, &val);
+	if (ret < 0)
+		return ret;
+	if (val < 1 || val > 3)
 		return -EINVAL;
 
 	mutex_lock(&data->update_lock);
@@ -818,9 +822,11 @@ static ssize_t store_temp_target(struct device *dev,
 	int nr = sensor_attr->index;
 	unsigned long val;
 	u8 target_mask;
+	int rv;
 
-	if (strict_strtoul(buf, 10, &val))
-		return -EINVAL;
+	rv = kstrtoul(buf, 10, &val);
+	if (rv < 0)
+		return rv;
 
 	mutex_lock(&data->update_lock);
 	data->temp_target[nr] = TARGET_TEMP_TO_REG(val);
@@ -862,9 +868,11 @@ static ssize_t store_temp_tolerance(struct device *dev,
 	u8 reg_idx = 0;
 	u8 val_shift = 0;
 	u8 keep_mask = 0;
+	int rv;
 
-	if (strict_strtoul(buf, 10, &val))
-		return -EINVAL;
+	rv = kstrtoul(buf, 10, &val);
+	if (rv < 0)
+		return rv;
 
 	switch (nr) {
 	case 0:
diff --git a/drivers/hwmon/w83792d.c b/drivers/hwmon/w83792d.c
index 63841f8..f6b8aa1 100644
--- a/drivers/hwmon/w83792d.c
+++ b/drivers/hwmon/w83792d.c
@@ -749,7 +749,7 @@ store_chassis_clear(struct device *dev, struct device_attribute *attr,
 	unsigned long val;
 	u8 reg;
 
-	if (strict_strtoul(buf, 10, &val) || val != 0)
+	if (kstrtoul(buf, 10, &val) || val != 0)
 		return -EINVAL;
 
 	mutex_lock(&data->update_lock);
diff --git a/drivers/hwmon/w83793.c b/drivers/hwmon/w83793.c
index e3bdedf..cc3906c 100644
--- a/drivers/hwmon/w83793.c
+++ b/drivers/hwmon/w83793.c
@@ -450,7 +450,7 @@ store_chassis_clear(struct device *dev,
 	unsigned long val;
 	u8 reg;
 
-	if (strict_strtoul(buf, 10, &val) || val != 0)
+	if (kstrtoul(buf, 10, &val) || val != 0)
 		return -EINVAL;
 
 	mutex_lock(&data->update_lock);
diff --git a/drivers/hwmon/w83795.c b/drivers/hwmon/w83795.c
index 845232d..6bdf597 100644
--- a/drivers/hwmon/w83795.c
+++ b/drivers/hwmon/w83795.c
@@ -728,10 +728,12 @@ store_beep(struct device *dev, struct device_attribute *attr,
 	int index = sensor_attr->index >> 3;
 	int shift = sensor_attr->index & 0x07;
 	u8 beep_bit = 1 << shift;
-	unsigned long val;
+	unsigned int val;
+	int rv;
 
-	if (strict_strtoul(buf, 10, &val) < 0)
-		return -EINVAL;
+	rv = kstrtouint(buf, 10, &val);
+	if (rv < 0)
+		return rv;
 	if (val != 0 && val != 1)
 		return -EINVAL;
 
@@ -753,9 +755,13 @@ store_chassis_clear(struct device *dev,
 {
 	struct i2c_client *client = to_i2c_client(dev);
 	struct w83795_data *data = i2c_get_clientdata(client);
-	unsigned long val;
+	u8 val;
+	int rv;
 
-	if (strict_strtoul(buf, 10, &val) < 0 || val != 0)
+	rv = kstrtou8(buf, 10, &val);
+	if (rv < 0)
+		return rv;
+	if (val != 0)
 		return -EINVAL;
 
 	mutex_lock(&data->update_lock);
@@ -800,9 +806,11 @@ store_fan_min(struct device *dev, struct device_attribute *attr,
 	struct i2c_client *client = to_i2c_client(dev);
 	struct w83795_data *data = i2c_get_clientdata(client);
 	unsigned long val;
+	int rv;
 
-	if (strict_strtoul(buf, 10, &val))
-		return -EINVAL;
+	rv = kstrtoul(buf, 10, &val);
+	if (rv < 0)
+		return rv;
 	val = fan_to_reg(val);
 
 	mutex_lock(&data->update_lock);
@@ -862,9 +870,11 @@ store_pwm(struct device *dev, struct device_attribute *attr,
 	int nr = sensor_attr->nr;
 	int index = sensor_attr->index;
 	unsigned long val;
+	int rv;
 
-	if (strict_strtoul(buf, 10, &val) < 0)
-		return -EINVAL;
+	rv = kstrtoul(buf, 10, &val);
+	if (rv < 0)
+		return rv;
 
 	mutex_lock(&data->update_lock);
 	switch (nr) {
@@ -921,16 +931,18 @@ store_pwm_enable(struct device *dev, struct device_attribute *attr,
 	struct sensor_device_attribute_2 *sensor_attr =
 	    to_sensor_dev_attr_2(attr);
 	int index = sensor_attr->index;
-	unsigned long val;
-	int i;
+	int val;
+	int rv;
 
-	if (strict_strtoul(buf, 10, &val) < 0)
-		return -EINVAL;
+	rv = kstrtoint(buf, 10, &val);
+	if (rv < 0)
+		return rv;
 	if (val < 1 || val > 2)
 		return -EINVAL;
 
 	mutex_lock(&data->update_lock);
 	switch (val) {
+		int i;
 	case 1:
 		/* Clear speed cruise mode bits */
 		data->pwm_fcms[0] &= ~(1 << index);
@@ -1018,11 +1030,14 @@ store_temp_src(struct device *dev, struct device_attribute *attr,
 	    to_sensor_dev_attr_2(attr);
 	int index = sensor_attr->index;
 	int tmp;
-	unsigned long channel;
+	u8 channel;
 	u8 val = index / 2;
+	int rv;
 
-	if (strict_strtoul(buf, 10, &channel) < 0 ||
-	    channel < 1 || channel > 14)
+	rv = kstrtou8(buf, 10, &channel);
+	if (rv < 0)
+		return rv;
+	if (channel < 1 || channel > 14)
 		return -EINVAL;
 
 	/* Check if request can be fulfilled */
@@ -1087,9 +1102,11 @@ store_temp_pwm_enable(struct device *dev, struct device_attribute *attr,
 	int nr = sensor_attr->nr;
 	int index = sensor_attr->index;
 	unsigned long tmp;
+	int rv;
 
-	if (strict_strtoul(buf, 10, &tmp) < 0)
-		return -EINVAL;
+	rv = kstrtoul(buf, 10, &tmp);
+	if (rv < 0)
+		return rv;
 
 	switch (nr) {
 	case TEMP_PWM_ENABLE:
@@ -1148,9 +1165,11 @@ store_fanin(struct device *dev, struct device_attribute *attr,
 	int nr = sensor_attr->nr;
 	int index = sensor_attr->index;
 	unsigned long val;
+	int rv;
 
-	if (strict_strtoul(buf, 10, &val) < 0)
-		return -EINVAL;
+	rv = kstrtoul(buf, 10, &val);
+	if (rv < 0)
+		return rv;
 
 	mutex_lock(&data->update_lock);
 	switch (nr) {
@@ -1197,9 +1216,11 @@ store_temp_pwm(struct device *dev, struct device_attribute *attr,
 	int index = sensor_attr->index;
 	unsigned long val;
 	u8 tmp;
+	int rv;
 
-	if (strict_strtoul(buf, 10, &val) < 0)
-		return -EINVAL;
+	rv = kstrtoul(buf, 10, &val);
+	if (rv < 0)
+		return rv;
 	val /= 1000;
 
 	mutex_lock(&data->update_lock);
@@ -1256,9 +1277,11 @@ store_sf4_pwm(struct device *dev, struct device_attribute *attr,
 	int nr = sensor_attr->nr;
 	int index = sensor_attr->index;
 	unsigned long val;
+	int rv;
 
-	if (strict_strtoul(buf, 10, &val) < 0)
-		return -EINVAL;
+	rv = kstrtoul(buf, 10, &val);
+	if (rv < 0)
+		return rv;
 
 	mutex_lock(&data->update_lock);
 	w83795_write(client, W83795_REG_SF4_PWM(index, nr), val);
@@ -1292,9 +1315,11 @@ store_sf4_temp(struct device *dev, struct device_attribute *attr,
 	int nr = sensor_attr->nr;
 	int index = sensor_attr->index;
 	unsigned long val;
+	int rv;
 
-	if (strict_strtoul(buf, 10, &val) < 0)
-		return -EINVAL;
+	rv = kstrtoul(buf, 10, &val);
+	if (rv < 0)
+		return rv;
 	val /= 1000;
 
 	mutex_lock(&data->update_lock);
@@ -1332,9 +1357,11 @@ store_temp(struct device *dev, struct device_attribute *attr,
 	struct i2c_client *client = to_i2c_client(dev);
 	struct w83795_data *data = i2c_get_clientdata(client);
 	long tmp;
+	int rv;
 
-	if (strict_strtol(buf, 10, &tmp) < 0)
-		return -EINVAL;
+	rv = kstrtol(buf, 10, &tmp);
+	if (rv < 0)
+		return rv;
 
 	mutex_lock(&data->update_lock);
 	data->temp[index][nr] = temp_to_reg(tmp, -128, 127);
@@ -1393,9 +1420,11 @@ store_dts_ext(struct device *dev, struct device_attribute *attr,
 	struct i2c_client *client = to_i2c_client(dev);
 	struct w83795_data *data = i2c_get_clientdata(client);
 	long tmp;
+	int rv;
 
-	if (strict_strtol(buf, 10, &tmp) < 0)
-		return -EINVAL;
+	rv = kstrtol(buf, 10, &tmp);
+	if (rv < 0)
+		return rv;
 
 	mutex_lock(&data->update_lock);
 	data->dts_ext[nr] = temp_to_reg(tmp, -128, 127);
@@ -1433,11 +1462,13 @@ store_temp_mode(struct device *dev, struct device_attribute *attr,
 	    to_sensor_dev_attr_2(attr);
 	int index = sensor_attr->index;
 	int reg_shift;
-	unsigned long val;
+	u8 val;
 	u8 tmp;
+	int rv;
 
-	if (strict_strtoul(buf, 10, &val) < 0)
-		return -EINVAL;
+	rv = kstrtou8(buf, 10, &val);
+	if (rv < 0)
+		return rv;
 	if ((val != 4) && (val != 3))
 		return -EINVAL;
 
@@ -1511,9 +1542,11 @@ store_in(struct device *dev, struct device_attribute *attr,
 	unsigned long val;
 	u8 tmp;
 	u8 lsb_idx;
+	int rv;
 
-	if (strict_strtoul(buf, 10, &val) < 0)
-		return -EINVAL;
+	rv = kstrtoul(buf, 10, &val);
+	if (rv < 0)
+		return rv;
 	val = in_to_reg(index, val);
 
 	if ((index >= 17) &&
@@ -1568,9 +1601,11 @@ store_sf_setup(struct device *dev, struct device_attribute *attr,
 	struct i2c_client *client = to_i2c_client(dev);
 	struct w83795_data *data = i2c_get_clientdata(client);
 	unsigned long val;
+	int rv;
 
-	if (strict_strtoul(buf, 10, &val) < 0)
-		return -EINVAL;
+	rv = kstrtoul(buf, 10, &val);
+	if (rv < 0)
+		return rv;
 
 	switch (nr) {
 	case SETUP_PWM_DEFAULT:
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 21/52] kstrtox: convert drivers/ide/
  2011-02-05 14:20 [PATCH 01/52] kstrtox: converting strings to integers done (hopefully) right Alexey Dobriyan
                   ` (18 preceding siblings ...)
  2011-02-05 14:20 ` [PATCH 20/52] kstrtox: convert drivers/hwmon/ Alexey Dobriyan
@ 2011-02-05 14:20 ` Alexey Dobriyan
  2011-02-05 14:20 ` [PATCH 22/52] kstrtox: convert drivers/infiniband/ Alexey Dobriyan
                   ` (30 subsequent siblings)
  50 siblings, 0 replies; 58+ messages in thread
From: Alexey Dobriyan @ 2011-02-05 14:20 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, adobriyan


Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
 drivers/ide/ide-park.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/ide/ide-park.c b/drivers/ide/ide-park.c
index 88a380c..436ca71 100644
--- a/drivers/ide/ide-park.c
+++ b/drivers/ide/ide-park.c
@@ -113,11 +113,13 @@ ssize_t ide_park_store(struct device *dev, struct device_attribute *attr,
 {
 #define MAX_PARK_TIMEOUT 30000
 	ide_drive_t *drive = to_ide_device(dev);
-	long int input;
+	int input;
 	int rc;
 
-	rc = strict_strtol(buf, 10, &input);
-	if (rc || input < -2)
+	rc = kstrtoint(buf, 10, &input);
+	if (rc < 0)
+		return rc;
+	if (input < -2)
 		return -EINVAL;
 	if (input > MAX_PARK_TIMEOUT) {
 		input = MAX_PARK_TIMEOUT;
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 22/52] kstrtox: convert drivers/infiniband/
  2011-02-05 14:20 [PATCH 01/52] kstrtox: converting strings to integers done (hopefully) right Alexey Dobriyan
                   ` (19 preceding siblings ...)
  2011-02-05 14:20 ` [PATCH 21/52] kstrtox: convert drivers/ide/ Alexey Dobriyan
@ 2011-02-05 14:20 ` Alexey Dobriyan
  2011-02-05 14:20 ` [PATCH 23/52] kstrtox: convert drivers/input/ Alexey Dobriyan
                   ` (29 subsequent siblings)
  50 siblings, 0 replies; 58+ messages in thread
From: Alexey Dobriyan @ 2011-02-05 14:20 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, adobriyan


Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
 drivers/infiniband/hw/nes/nes.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/infiniband/hw/nes/nes.c b/drivers/infiniband/hw/nes/nes.c
index 3b4ec32..bddf69c 100644
--- a/drivers/infiniband/hw/nes/nes.c
+++ b/drivers/infiniband/hw/nes/nes.c
@@ -1132,12 +1132,15 @@ static ssize_t nes_show_wqm_quanta(struct device_driver *ddp, char *buf)
 static ssize_t nes_store_wqm_quanta(struct device_driver *ddp,
 					const char *buf, size_t count)
 {
-	unsigned long wqm_quanta_value;
+	unsigned int wqm_quanta_value;
 	u32 wqm_config1;
 	u32 i = 0;
 	struct nes_device *nesdev;
+	int rv;
 
-	strict_strtoul(buf, 0, &wqm_quanta_value);
+	rv = kstrtouint(buf, 0, &wqm_quanta_value);
+	if (rv < 0)
+		return rv;
 	list_for_each_entry(nesdev, &nes_dev_list, list) {
 		if (i == ee_flsh_adapter) {
 			nesdev->nesadapter->wqm_quanta = wqm_quanta_value;
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 23/52] kstrtox: convert drivers/input/
  2011-02-05 14:20 [PATCH 01/52] kstrtox: converting strings to integers done (hopefully) right Alexey Dobriyan
                   ` (20 preceding siblings ...)
  2011-02-05 14:20 ` [PATCH 22/52] kstrtox: convert drivers/infiniband/ Alexey Dobriyan
@ 2011-02-05 14:20 ` Alexey Dobriyan
  2011-02-05 14:20 ` [PATCH 24/52] kstrtox: convert drivers/isdn/ Alexey Dobriyan
                   ` (28 subsequent siblings)
  50 siblings, 0 replies; 58+ messages in thread
From: Alexey Dobriyan @ 2011-02-05 14:20 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, adobriyan


Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
 drivers/input/input-polldev.c       |    8 ++-
 drivers/input/keyboard/atkbd.c      |   33 ++++++++++----
 drivers/input/keyboard/lm8323.c     |   20 ++++-----
 drivers/input/misc/adxl34x.c        |   14 +++---
 drivers/input/misc/ati_remote2.c    |   31 +++++++------
 drivers/input/mouse/elantech.c      |   10 +---
 drivers/input/mouse/hgpk.c          |   18 +++++---
 drivers/input/mouse/logips2pp.c     |    8 +++-
 drivers/input/mouse/psmouse-base.c  |   31 ++++++-------
 drivers/input/mouse/sentelic.c      |   79 ++++++++++++++++++----------------
 drivers/input/mouse/sentelic.h      |   10 ++--
 drivers/input/mouse/trackpoint.c    |   19 +++++----
 drivers/input/tablet/aiptek.c       |   34 +++++++--------
 drivers/input/touchscreen/ad7877.c  |   16 ++++----
 drivers/input/touchscreen/ad7879.c  |    4 +-
 drivers/input/touchscreen/ads7846.c |    6 ++-
 16 files changed, 182 insertions(+), 159 deletions(-)

diff --git a/drivers/input/input-polldev.c b/drivers/input/input-polldev.c
index 0559e30..25b2fbb 100644
--- a/drivers/input/input-polldev.c
+++ b/drivers/input/input-polldev.c
@@ -130,10 +130,12 @@ static ssize_t input_polldev_set_poll(struct device *dev,
 {
 	struct input_polled_dev *polldev = dev_get_drvdata(dev);
 	struct input_dev *input = polldev->input;
-	unsigned long interval;
+	unsigned int interval;
+	int rv;
 
-	if (strict_strtoul(buf, 0, &interval))
-		return -EINVAL;
+	rv = kstrtouint(buf, 0, &interval);
+	if (rv < 0)
+		return rv;
 
 	if (interval < polldev->poll_interval_min)
 		return -EINVAL;
diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c
index 11478eb..b01c7e7 100644
--- a/drivers/input/keyboard/atkbd.c
+++ b/drivers/input/keyboard/atkbd.c
@@ -1305,7 +1305,7 @@ static ssize_t atkbd_show_extra(struct atkbd *atkbd, char *buf)
 static ssize_t atkbd_set_extra(struct atkbd *atkbd, const char *buf, size_t count)
 {
 	struct input_dev *old_dev, *new_dev;
-	unsigned long value;
+	unsigned int value;
 	int err;
 	bool old_extra;
 	unsigned char old_set;
@@ -1313,7 +1313,10 @@ static ssize_t atkbd_set_extra(struct atkbd *atkbd, const char *buf, size_t coun
 	if (!atkbd->write)
 		return -EIO;
 
-	if (strict_strtoul(buf, 10, &value) || value > 1)
+	err = kstrtouint(buf, 10, &value);
+	if (err < 0)
+		return err;
+	if (value > 1)
 		return -EINVAL;
 
 	if (atkbd->extra != value) {
@@ -1389,11 +1392,14 @@ static ssize_t atkbd_show_scroll(struct atkbd *atkbd, char *buf)
 static ssize_t atkbd_set_scroll(struct atkbd *atkbd, const char *buf, size_t count)
 {
 	struct input_dev *old_dev, *new_dev;
-	unsigned long value;
+	unsigned int value;
 	int err;
 	bool old_scroll;
 
-	if (strict_strtoul(buf, 10, &value) || value > 1)
+	err = kstrtouint(buf, 10, &value);
+	if (err < 0)
+		return err;
+	if (value > 1)
 		return -EINVAL;
 
 	if (atkbd->scroll != value) {
@@ -1433,7 +1439,7 @@ static ssize_t atkbd_show_set(struct atkbd *atkbd, char *buf)
 static ssize_t atkbd_set_set(struct atkbd *atkbd, const char *buf, size_t count)
 {
 	struct input_dev *old_dev, *new_dev;
-	unsigned long value;
+	int value;
 	int err;
 	unsigned char old_set;
 	bool old_extra;
@@ -1441,7 +1447,10 @@ static ssize_t atkbd_set_set(struct atkbd *atkbd, const char *buf, size_t count)
 	if (!atkbd->write)
 		return -EIO;
 
-	if (strict_strtoul(buf, 10, &value) || (value != 2 && value != 3))
+	err = kstrtoint(buf, 10, &value);
+	if (err < 0)
+		return err;
+	if (value != 2 && value != 3)
 		return -EINVAL;
 
 	if (atkbd->set != value) {
@@ -1484,14 +1493,17 @@ static ssize_t atkbd_show_softrepeat(struct atkbd *atkbd, char *buf)
 static ssize_t atkbd_set_softrepeat(struct atkbd *atkbd, const char *buf, size_t count)
 {
 	struct input_dev *old_dev, *new_dev;
-	unsigned long value;
+	unsigned int value;
 	int err;
 	bool old_softrepeat, old_softraw;
 
 	if (!atkbd->write)
 		return -EIO;
 
-	if (strict_strtoul(buf, 10, &value) || value > 1)
+	err = kstrtouint(buf, 10, &value);
+	if (err < 0)
+		return err;
+	if (value > 1)
 		return -EINVAL;
 
 	if (atkbd->softrepeat != value) {
@@ -1534,11 +1546,12 @@ static ssize_t atkbd_show_softraw(struct atkbd *atkbd, char *buf)
 static ssize_t atkbd_set_softraw(struct atkbd *atkbd, const char *buf, size_t count)
 {
 	struct input_dev *old_dev, *new_dev;
-	unsigned long value;
+	unsigned int value;
 	int err;
 	bool old_softraw;
 
-	if (strict_strtoul(buf, 10, &value) || value > 1)
+	err = kstrtouint(buf, 10, &value);
+	if (value > 1)
 		return -EINVAL;
 
 	if (atkbd->softraw != value) {
diff --git a/drivers/input/keyboard/lm8323.c b/drivers/input/keyboard/lm8323.c
index f7c2a16..79ca455 100644
--- a/drivers/input/keyboard/lm8323.c
+++ b/drivers/input/keyboard/lm8323.c
@@ -557,15 +557,10 @@ static ssize_t lm8323_pwm_store_time(struct device *dev,
 	struct led_classdev *led_cdev = dev_get_drvdata(dev);
 	struct lm8323_pwm *pwm = cdev_to_pwm(led_cdev);
 	int ret;
-	unsigned long time;
-
-	ret = strict_strtoul(buf, 10, &time);
-	/* Numbers only, please. */
-	if (ret)
-		return -EINVAL;
-
-	pwm->fade_time = time;
 
+	ret = kstrtoint(buf, 10, &pwm->fade_time);
+	if (ret < 0)
+		return ret;
 	return strlen(buf);
 }
 static DEVICE_ATTR(time, 0644, lm8323_pwm_show_time, lm8323_pwm_store_time);
@@ -623,13 +618,14 @@ static ssize_t lm8323_set_disable(struct device *dev,
 				  const char *buf, size_t count)
 {
 	struct lm8323_chip *lm = dev_get_drvdata(dev);
+	unsigned int kp_enabled;
 	int ret;
-	unsigned long i;
-
-	ret = strict_strtoul(buf, 10, &i);
 
+	ret = kstrtouint(buf, 10, &kp_enabled);
+	if (ret < 0)
+		return ret;
 	mutex_lock(&lm->lock);
-	lm->kp_enabled = !i;
+	lm->kp_enabled = !kp_enabled;
 	mutex_unlock(&lm->lock);
 
 	return count;
diff --git a/drivers/input/misc/adxl34x.c b/drivers/input/misc/adxl34x.c
index de5900d..03b284a 100644
--- a/drivers/input/misc/adxl34x.c
+++ b/drivers/input/misc/adxl34x.c
@@ -454,8 +454,8 @@ static ssize_t adxl34x_disable_store(struct device *dev,
 	unsigned long val;
 	int error;
 
-	error = strict_strtoul(buf, 10, &val);
-	if (error)
+	error = kstrtoul(buf, 10, &val);
+	if (error < 0)
 		return error;
 
 	mutex_lock(&ac->mutex);
@@ -543,7 +543,7 @@ static ssize_t adxl34x_rate_store(struct device *dev,
 	unsigned long val;
 	int error;
 
-	error = strict_strtoul(buf, 10, &val);
+	error = kstrtoul(buf, 10, &val);
 	if (error)
 		return error;
 
@@ -578,7 +578,7 @@ static ssize_t adxl34x_autosleep_store(struct device *dev,
 	unsigned long val;
 	int error;
 
-	error = strict_strtoul(buf, 10, &val);
+	error = kstrtoul(buf, 10, &val);
 	if (error)
 		return error;
 
@@ -622,13 +622,13 @@ static ssize_t adxl34x_write_store(struct device *dev,
 				   const char *buf, size_t count)
 {
 	struct adxl34x *ac = dev_get_drvdata(dev);
-	unsigned long val;
+	u16 val;
 	int error;
 
 	/*
 	 * This allows basic ADXL register write access for debug purposes.
 	 */
-	error = strict_strtoul(buf, 16, &val);
+	error = kstrtou16(buf, 16, &val);
 	if (error)
 		return error;
 
@@ -639,7 +639,7 @@ static ssize_t adxl34x_write_store(struct device *dev,
 	return count;
 }
 
-static DEVICE_ATTR(write, 0664, NULL, adxl34x_write_store);
+static DEVICE_ATTR(write, 0220, NULL, adxl34x_write_store);
 #endif
 
 static struct attribute *adxl34x_attributes[] = {
diff --git a/drivers/input/misc/ati_remote2.c b/drivers/input/misc/ati_remote2.c
index 0b0e9be..3226c9a 100644
--- a/drivers/input/misc/ati_remote2.c
+++ b/drivers/input/misc/ati_remote2.c
@@ -41,14 +41,14 @@ static int ati_remote2_set_mask(const char *val,
 				const struct kernel_param *kp,
 				unsigned int max)
 {
-	unsigned long mask;
+	unsigned int mask;
 	int ret;
 
 	if (!val)
 		return -EINVAL;
 
-	ret = strict_strtoul(val, 0, &mask);
-	if (ret)
+	ret = kstrtouint(val, 0, &mask);
+	if (ret < 0)
 		return ret;
 
 	if (mask & ~max)
@@ -719,20 +719,21 @@ static ssize_t ati_remote2_store_channel_mask(struct device *dev,
 	struct usb_device *udev = to_usb_device(dev);
 	struct usb_interface *intf = usb_ifnum_to_if(udev, 0);
 	struct ati_remote2 *ar2 = usb_get_intfdata(intf);
-	unsigned long mask;
-	int r;
+	unsigned int mask;
+	int rv;
 
-	if (strict_strtoul(buf, 0, &mask))
-		return -EINVAL;
+	rv = kstrtouint(buf, 0, &mask);
+	if (rv < 0)
+		return rv;
 
 	if (mask & ~ATI_REMOTE2_MAX_CHANNEL_MASK)
 		return -EINVAL;
 
-	r = usb_autopm_get_interface(ar2->intf[0]);
-	if (r) {
+	rv = usb_autopm_get_interface(ar2->intf[0]);
+	if (rv) {
 		dev_err(&ar2->intf[0]->dev,
-			"%s(): usb_autopm_get_interface() = %d\n", __func__, r);
-		return r;
+			"%s(): usb_autopm_get_interface() = %d\n", __func__, rv);
+		return rv;
 	}
 
 	mutex_lock(&ati_remote2_mutex);
@@ -765,10 +766,12 @@ static ssize_t ati_remote2_store_mode_mask(struct device *dev,
 	struct usb_device *udev = to_usb_device(dev);
 	struct usb_interface *intf = usb_ifnum_to_if(udev, 0);
 	struct ati_remote2 *ar2 = usb_get_intfdata(intf);
-	unsigned long mask;
+	unsigned int mask;
+	int rv;
 
-	if (strict_strtoul(buf, 0, &mask))
-		return -EINVAL;
+	rv = kstrtouint(buf, 0, &mask);
+	if (rv < 0)
+		return rv;
 
 	if (mask & ~ATI_REMOTE2_MAX_MODE_MASK)
 		return -EINVAL;
diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c
index 04d9bf3..b3c788b 100644
--- a/drivers/input/mouse/elantech.c
+++ b/drivers/input/mouse/elantech.c
@@ -517,16 +517,12 @@ static ssize_t elantech_set_int_attr(struct psmouse *psmouse,
 	struct elantech_data *etd = psmouse->private;
 	struct elantech_attr_data *attr = data;
 	unsigned char *reg = (unsigned char *) etd + attr->field_offset;
-	unsigned long value;
+	u8 value;
 	int err;
 
-	err = strict_strtoul(buf, 16, &value);
-	if (err)
+	err = kstrtou8(buf, 16, &value);
+	if (err < 0)
 		return err;
-
-	if (value > 0xff)
-		return -EINVAL;
-
 	/* Do we need to preserve some bits for version 2 hardware too? */
 	if (etd->hw_version == 1) {
 		if (attr->reg == 0x10)
diff --git a/drivers/input/mouse/hgpk.c b/drivers/input/mouse/hgpk.c
index 95577c1..b98edc7 100644
--- a/drivers/input/mouse/hgpk.c
+++ b/drivers/input/mouse/hgpk.c
@@ -787,11 +787,13 @@ static ssize_t hgpk_set_powered(struct psmouse *psmouse, void *data,
 				const char *buf, size_t count)
 {
 	struct hgpk_data *priv = psmouse->private;
-	unsigned long value;
+	unsigned int value;
 	int err;
 
-	err = strict_strtoul(buf, 10, &value);
-	if (err || value > 1)
+	err = kstrtouint(buf, 10, &value);
+	if (err < 0)
+		return err;
+	if (value > 1)
 		return -EINVAL;
 
 	if (value != priv->powered) {
@@ -879,11 +881,13 @@ static ssize_t hgpk_trigger_recal(struct psmouse *psmouse, void *data,
 				const char *buf, size_t count)
 {
 	struct hgpk_data *priv = psmouse->private;
-	unsigned long value;
+	unsigned int value;
 	int err;
 
-	err = strict_strtoul(buf, 10, &value);
-	if (err || value != 1)
+	err = kstrtouint(buf, 10, &value);
+	if (err < 0)
+		return err;
+	if (value != 1)
 		return -EINVAL;
 
 	/*
@@ -895,7 +899,7 @@ static ssize_t hgpk_trigger_recal(struct psmouse *psmouse, void *data,
 	return count;
 }
 
-__PSMOUSE_DEFINE_ATTR(recalibrate, S_IWUSR | S_IRUGO, NULL,
+__PSMOUSE_DEFINE_ATTR(recalibrate, S_IWUSR, NULL,
 		      hgpk_trigger_recal_show, hgpk_trigger_recal, false);
 
 static void hgpk_disconnect(struct psmouse *psmouse)
diff --git a/drivers/input/mouse/logips2pp.c b/drivers/input/mouse/logips2pp.c
index c9983ae..c977ea9 100644
--- a/drivers/input/mouse/logips2pp.c
+++ b/drivers/input/mouse/logips2pp.c
@@ -155,9 +155,13 @@ static ssize_t ps2pp_attr_show_smartscroll(struct psmouse *psmouse,
 static ssize_t ps2pp_attr_set_smartscroll(struct psmouse *psmouse, void *data,
 					  const char *buf, size_t count)
 {
-	unsigned long value;
+	unsigned int value;
+	int rv;
 
-	if (strict_strtoul(buf, 10, &value) || value > 1)
+	rv = kstrtouint(buf, 10, &value);
+	if (rv < 0)
+		return rv;
+	if (value > 1)
 		return -EINVAL;
 
 	ps2pp_set_smartscroll(psmouse, value);
diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c
index 3f74bae..5438f16 100644
--- a/drivers/input/mouse/psmouse-base.c
+++ b/drivers/input/mouse/psmouse-base.c
@@ -1546,16 +1546,11 @@ static ssize_t psmouse_show_int_attr(struct psmouse *psmouse, void *offset, char
 static ssize_t psmouse_set_int_attr(struct psmouse *psmouse, void *offset, const char *buf, size_t count)
 {
 	unsigned int *field = (unsigned int *)((char *)psmouse + (size_t)offset);
-	unsigned long value;
-
-	if (strict_strtoul(buf, 10, &value))
-		return -EINVAL;
-
-	if ((unsigned int)value != value)
-		return -EINVAL;
-
-	*field = value;
+	int rv;
 
+	rv = kstrtouint(buf, 10, field);
+	if (rv < 0)
+		return rv;
 	return count;
 }
 
@@ -1660,22 +1655,24 @@ static ssize_t psmouse_attr_set_protocol(struct psmouse *psmouse, void *data, co
 
 static ssize_t psmouse_attr_set_rate(struct psmouse *psmouse, void *data, const char *buf, size_t count)
 {
-	unsigned long value;
-
-	if (strict_strtoul(buf, 10, &value))
-		return -EINVAL;
+	unsigned int value;
+	int rv;
 
+	rv = kstrtouint(buf, 10, &value);
+	if (rv < 0)
+		return rv;
 	psmouse->set_rate(psmouse, value);
 	return count;
 }
 
 static ssize_t psmouse_attr_set_resolution(struct psmouse *psmouse, void *data, const char *buf, size_t count)
 {
-	unsigned long value;
-
-	if (strict_strtoul(buf, 10, &value))
-		return -EINVAL;
+	unsigned int value;
+	int rv;
 
+	rv = kstrtouint(buf, 10, &value);
+	if (rv < 0)
+		return rv;
 	psmouse->set_resolution(psmouse, value);
 	return count;
 }
diff --git a/drivers/input/mouse/sentelic.c b/drivers/input/mouse/sentelic.c
index 1242775..baaa141 100644
--- a/drivers/input/mouse/sentelic.c
+++ b/drivers/input/mouse/sentelic.c
@@ -78,7 +78,7 @@ static unsigned char fsp_test_invert_cmd(unsigned char reg_val)
 	}
 }
 
-static int fsp_reg_read(struct psmouse *psmouse, int reg_addr, int *reg_val)
+static int fsp_reg_read(struct psmouse *psmouse, u8 reg_addr, u8 *reg_val)
 {
 	struct ps2dev *ps2dev = &psmouse->ps2dev;
 	unsigned char param[3];
@@ -136,7 +136,7 @@ static int fsp_reg_read(struct psmouse *psmouse, int reg_addr, int *reg_val)
 	return rc;
 }
 
-static int fsp_reg_write(struct psmouse *psmouse, int reg_addr, int reg_val)
+static int fsp_reg_write(struct psmouse *psmouse, u8 reg_addr, u8 reg_val)
 {
 	struct ps2dev *ps2dev = &psmouse->ps2dev;
 	unsigned char v;
@@ -190,7 +190,7 @@ static int fsp_reg_write(struct psmouse *psmouse, int reg_addr, int reg_val)
 /* Enable register clock gating for writing certain registers */
 static int fsp_reg_write_enable(struct psmouse *psmouse, bool enable)
 {
-	int v, nv;
+	u8 v, nv;
 
 	if (fsp_reg_read(psmouse, FSP_REG_SYSCTL1, &v) == -1)
 		return -1;
@@ -284,7 +284,7 @@ static int fsp_page_reg_write(struct psmouse *psmouse, int reg_val)
 	return rc;
 }
 
-static int fsp_get_version(struct psmouse *psmouse, int *version)
+static int fsp_get_version(struct psmouse *psmouse, u8 *version)
 {
 	if (fsp_reg_read(psmouse, FSP_REG_VERSION, version))
 		return -EIO;
@@ -292,7 +292,7 @@ static int fsp_get_version(struct psmouse *psmouse, int *version)
 	return 0;
 }
 
-static int fsp_get_revision(struct psmouse *psmouse, int *rev)
+static int fsp_get_revision(struct psmouse *psmouse, u8 *rev)
 {
 	if (fsp_reg_read(psmouse, FSP_REG_REVISION, rev))
 		return -EIO;
@@ -300,7 +300,7 @@ static int fsp_get_revision(struct psmouse *psmouse, int *rev)
 	return 0;
 }
 
-static int fsp_get_buttons(struct psmouse *psmouse, int *btn)
+static int fsp_get_buttons(struct psmouse *psmouse, u8 *btn)
 {
 	static const int buttons[] = {
 		0x16, /* Left/Middle/Right/Forward/Backward & Scroll Up/Down */
@@ -308,7 +308,7 @@ static int fsp_get_buttons(struct psmouse *psmouse, int *btn)
 		0x04, /* Left/Middle/Right & Scroll Up/Down */
 		0x02, /* Left/Middle/Right */
 	};
-	int val;
+	u8 val;
 
 	if (fsp_reg_read(psmouse, FSP_REG_TMOD_STATUS1, &val) == -1)
 		return -EIO;
@@ -320,7 +320,7 @@ static int fsp_get_buttons(struct psmouse *psmouse, int *btn)
 /* Enable on-pad command tag output */
 static int fsp_opc_tag_enable(struct psmouse *psmouse, bool enable)
 {
-	int v, nv;
+	u8 v, nv;
 	int res = 0;
 
 	if (fsp_reg_read(psmouse, FSP_REG_OPC_QDOWN, &v) == -1) {
@@ -352,7 +352,7 @@ static int fsp_opc_tag_enable(struct psmouse *psmouse, bool enable)
 static int fsp_onpad_vscr(struct psmouse *psmouse, bool enable)
 {
 	struct fsp_data *pad = psmouse->private;
-	int val;
+	u8 val;
 
 	if (fsp_reg_read(psmouse, FSP_REG_ONPAD_CTL, &val))
 		return -EIO;
@@ -373,7 +373,7 @@ static int fsp_onpad_vscr(struct psmouse *psmouse, bool enable)
 static int fsp_onpad_hscr(struct psmouse *psmouse, bool enable)
 {
 	struct fsp_data *pad = psmouse->private;
-	int val, v2;
+	u8 val, v2;
 
 	if (fsp_reg_read(psmouse, FSP_REG_ONPAD_CTL, &val))
 		return -EIO;
@@ -409,24 +409,18 @@ static int fsp_onpad_hscr(struct psmouse *psmouse, bool enable)
 static ssize_t fsp_attr_set_setreg(struct psmouse *psmouse, void *data,
 				   const char *buf, size_t count)
 {
-	unsigned long reg, val;
-	char *rest;
-	ssize_t retval;
+	u8 reg, val;
+	int rv;
 
-	reg = simple_strtoul(buf, &rest, 16);
-	if (rest == buf || *rest != ' ' || reg > 0xff)
-		return -EINVAL;
-
-	if (strict_strtoul(rest + 1, 16, &val) || val > 0xff)
+	if (sscanf(buf, "%hhu %hhu", &reg, &val) != 2)
 		return -EINVAL;
 
 	if (fsp_reg_write_enable(psmouse, true))
 		return -EIO;
-
-	retval = fsp_reg_write(psmouse, reg, val) < 0 ? -EIO : count;
-
+	rv = fsp_reg_write(psmouse, reg, val);
 	fsp_reg_write_enable(psmouse, false);
-
+	if (rv < 0)
+		return -EIO;
 	return count;
 }
 
@@ -449,11 +443,12 @@ static ssize_t fsp_attr_set_getreg(struct psmouse *psmouse, void *data,
 					const char *buf, size_t count)
 {
 	struct fsp_data *pad = psmouse->private;
-	unsigned long reg;
-	int val;
+	u8 reg, val;
+	int rv;
 
-	if (strict_strtoul(buf, 16, &reg) || reg > 0xff)
-		return -EINVAL;
+	rv = kstrtou8(buf, 16, &reg);
+	if (rv < 0)
+		return rv;
 
 	if (fsp_reg_read(psmouse, reg, &val))
 		return -EIO;
@@ -481,10 +476,12 @@ static ssize_t fsp_attr_show_pagereg(struct psmouse *psmouse,
 static ssize_t fsp_attr_set_pagereg(struct psmouse *psmouse, void *data,
 					const char *buf, size_t count)
 {
-	unsigned long val;
+	u8 val;
+	int rv;
 
-	if (strict_strtoul(buf, 16, &val) || val > 0xff)
-		return -EINVAL;
+	rv = kstrtou8(buf, 16, &val);
+	if (rv < 0)
+		return rv;
 
 	if (fsp_page_reg_write(psmouse, val))
 		return -EIO;
@@ -506,9 +503,13 @@ static ssize_t fsp_attr_show_vscroll(struct psmouse *psmouse,
 static ssize_t fsp_attr_set_vscroll(struct psmouse *psmouse, void *data,
 					const char *buf, size_t count)
 {
-	unsigned long val;
+	unsigned int val;
+	int rv;
 
-	if (strict_strtoul(buf, 10, &val) || val > 1)
+	rv = kstrtouint(buf, 10, &val);
+	if (rv < 0)
+		return rv;
+	if (val > 1)
 		return -EINVAL;
 
 	fsp_onpad_vscr(psmouse, val);
@@ -530,9 +531,13 @@ static ssize_t fsp_attr_show_hscroll(struct psmouse *psmouse,
 static ssize_t fsp_attr_set_hscroll(struct psmouse *psmouse, void *data,
 					const char *buf, size_t count)
 {
-	unsigned long val;
+	unsigned int val;
+	int rv;
 
-	if (strict_strtoul(buf, 10, &val) || val > 1)
+	rv = kstrtouint(buf, 10, &val);
+	if (rv < 0)
+		return rv;
+	if (val > 1)
 		return -EINVAL;
 
 	fsp_onpad_hscr(psmouse, val);
@@ -704,7 +709,7 @@ static int fsp_activate_protocol(struct psmouse *psmouse)
 	struct fsp_data *pad = psmouse->private;
 	struct ps2dev *ps2dev = &psmouse->ps2dev;
 	unsigned char param[2];
-	int val;
+	u8 val;
 
 	/*
 	 * Standard procedure to enter FSP Intellimouse mode
@@ -761,7 +766,7 @@ static int fsp_activate_protocol(struct psmouse *psmouse)
 
 int fsp_detect(struct psmouse *psmouse, bool set_properties)
 {
-	int id;
+	u8 id;
 
 	if (fsp_reg_read(psmouse, FSP_REG_DEVICE_ID, &id))
 		return -EIO;
@@ -795,7 +800,7 @@ static void fsp_disconnect(struct psmouse *psmouse)
 
 static int fsp_reconnect(struct psmouse *psmouse)
 {
-	int version;
+	u8 version;
 
 	if (fsp_detect(psmouse, 0))
 		return -ENODEV;
@@ -812,7 +817,7 @@ static int fsp_reconnect(struct psmouse *psmouse)
 int fsp_init(struct psmouse *psmouse)
 {
 	struct fsp_data *priv;
-	int ver, rev, buttons;
+	u8 ver, rev, buttons;
 	int error;
 
 	if (fsp_get_version(psmouse, &ver) ||
diff --git a/drivers/input/mouse/sentelic.h b/drivers/input/mouse/sentelic.h
index ed1395a..363df999 100644
--- a/drivers/input/mouse/sentelic.h
+++ b/drivers/input/mouse/sentelic.h
@@ -66,17 +66,17 @@
 #ifdef __KERNEL__
 
 struct fsp_data {
-	unsigned char	ver;		/* hardware version */
-	unsigned char	rev;		/* hardware revison */
-	unsigned char	buttons;	/* Number of buttons */
+	u8		ver;		/* hardware version */
+	u8		rev;		/* hardware revison */
+	u8		buttons;	/* Number of buttons */
 	unsigned int	flags;
 #define	FSPDRV_FLAG_EN_OPC	(0x001)	/* enable on-pad clicking */
 
 	bool		vscroll;	/* Vertical scroll zone enabled */
 	bool		hscroll;	/* Horizontal scroll zone enabled */
 
-	unsigned char	last_reg;	/* Last register we requested read from */
-	unsigned char	last_val;
+	u8		last_reg;	/* Last register we requested read from */
+	u8		last_val;
 };
 
 #ifdef CONFIG_MOUSE_PS2_SENTELIC
diff --git a/drivers/input/mouse/trackpoint.c b/drivers/input/mouse/trackpoint.c
index 54b2fa8..daf74c4 100644
--- a/drivers/input/mouse/trackpoint.c
+++ b/drivers/input/mouse/trackpoint.c
@@ -89,13 +89,12 @@ static ssize_t trackpoint_set_int_attr(struct psmouse *psmouse, void *data,
 	struct trackpoint_data *tp = psmouse->private;
 	struct trackpoint_attr_data *attr = data;
 	unsigned char *field = (unsigned char *)((char *)tp + attr->field_offset);
-	unsigned long value;
+	int rv;
 
-	if (strict_strtoul(buf, 10, &value) || value > 255)
-		return -EINVAL;
-
-	*field = value;
-	trackpoint_write(&psmouse->ps2dev, attr->command, value);
+	rv = kstrtou8(buf, 10, field);
+	if (rv < 0)
+		return rv;
+	trackpoint_write(&psmouse->ps2dev, attr->command, *field);
 
 	return count;
 }
@@ -115,9 +114,13 @@ static ssize_t trackpoint_set_bit_attr(struct psmouse *psmouse, void *data,
 	struct trackpoint_data *tp = psmouse->private;
 	struct trackpoint_attr_data *attr = data;
 	unsigned char *field = (unsigned char *)((char *)tp + attr->field_offset);
-	unsigned long value;
+	u8 value;
+	int rv;
 
-	if (strict_strtoul(buf, 10, &value) || value > 1)
+	rv = kstrtou8(buf, 10, &value);
+	if (rv < 0)
+		return rv;
+	if (value > 1)
 		return -EINVAL;
 
 	if (attr->inverted)
diff --git a/drivers/input/tablet/aiptek.c b/drivers/input/tablet/aiptek.c
index 0a619c5..6fb2ac2 100644
--- a/drivers/input/tablet/aiptek.c
+++ b/drivers/input/tablet/aiptek.c
@@ -1199,9 +1199,9 @@ static ssize_t
 store_tabletXtilt(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
 {
 	struct aiptek *aiptek = dev_get_drvdata(dev);
-	long x;
+	int x;
 
-	if (strict_strtol(buf, 10, &x)) {
+	if (kstrtoint(buf, 10, &x)) {
 		size_t len = buf[count - 1] == '\n' ? count - 1 : count;
 
 		if (strncmp(buf, "disable", len))
@@ -1241,9 +1241,9 @@ static ssize_t
 store_tabletYtilt(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
 {
 	struct aiptek *aiptek = dev_get_drvdata(dev);
-	long y;
+	int y;
 
-	if (strict_strtol(buf, 10, &y)) {
+	if (kstrtoint(buf, 10, &y)) {
 		size_t len = buf[count - 1] == '\n' ? count - 1 : count;
 
 		if (strncmp(buf, "disable", len))
@@ -1278,12 +1278,11 @@ static ssize_t
 store_tabletJitterDelay(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
 {
 	struct aiptek *aiptek = dev_get_drvdata(dev);
-	long j;
+	int rv;
 
-	if (strict_strtol(buf, 10, &j))
-		return -EINVAL;
-
-	aiptek->newSetting.jitterDelay = (int)j;
+	rv = kstrtoint(buf, 10, &aiptek->newSetting.jitterDelay);
+	if (rv < 0)
+		return rv;
 	return count;
 }
 
@@ -1307,12 +1306,11 @@ static ssize_t
 store_tabletProgrammableDelay(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
 {
 	struct aiptek *aiptek = dev_get_drvdata(dev);
-	long d;
+	int rv;
 
-	if (strict_strtol(buf, 10, &d))
-		return -EINVAL;
-
-	aiptek->newSetting.programmableDelay = (int)d;
+	rv = kstrtoint(buf, 10, &aiptek->newSetting.programmableDelay);
+	if (rv < 0)
+		return rv;
 	return count;
 }
 
@@ -1558,11 +1556,11 @@ static ssize_t
 store_tabletWheel(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
 {
 	struct aiptek *aiptek = dev_get_drvdata(dev);
-	long w;
-
-	if (strict_strtol(buf, 10, &w)) return -EINVAL;
+	int rv;
 
-	aiptek->newSetting.wheel = (int)w;
+	rv = kstrtoint(buf, 10, &aiptek->newSetting.wheel);
+	if (rv < 0)
+		return rv;
 	return count;
 }
 
diff --git a/drivers/input/touchscreen/ad7877.c b/drivers/input/touchscreen/ad7877.c
index a1952fc..dac8711 100644
--- a/drivers/input/touchscreen/ad7877.c
+++ b/drivers/input/touchscreen/ad7877.c
@@ -489,8 +489,8 @@ static ssize_t ad7877_disable_store(struct device *dev,
 	unsigned long val;
 	int error;
 
-	error = strict_strtoul(buf, 10, &val);
-	if (error)
+	error = kstrtoul(buf, 10, &val);
+	if (error < 0)
 		return error;
 
 	if (val)
@@ -519,8 +519,8 @@ static ssize_t ad7877_dac_store(struct device *dev,
 	unsigned long val;
 	int error;
 
-	error = strict_strtoul(buf, 10, &val);
-	if (error)
+	error = kstrtoul(buf, 10, &val);
+	if (error < 0)
 		return error;
 
 	mutex_lock(&ts->mutex);
@@ -549,8 +549,8 @@ static ssize_t ad7877_gpio3_store(struct device *dev,
 	unsigned long val;
 	int error;
 
-	error = strict_strtoul(buf, 10, &val);
-	if (error)
+	error = kstrtoul(buf, 10, &val);
+	if (error < 0)
 		return error;
 
 	mutex_lock(&ts->mutex);
@@ -580,8 +580,8 @@ static ssize_t ad7877_gpio4_store(struct device *dev,
 	unsigned long val;
 	int error;
 
-	error = strict_strtoul(buf, 10, &val);
-	if (error)
+	error = kstrtoul(buf, 10, &val);
+	if (error < 0)
 		return error;
 
 	mutex_lock(&ts->mutex);
diff --git a/drivers/input/touchscreen/ad7879.c b/drivers/input/touchscreen/ad7879.c
index bc3b518..d3e0b9c 100644
--- a/drivers/input/touchscreen/ad7879.c
+++ b/drivers/input/touchscreen/ad7879.c
@@ -340,8 +340,8 @@ static ssize_t ad7879_disable_store(struct device *dev,
 	unsigned long val;
 	int error;
 
-	error = strict_strtoul(buf, 10, &val);
-	if (error)
+	error = kstrtoul(buf, 10, &val);
+	if (error < 0)
 		return error;
 
 	ad7879_toggle(ts, val);
diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c
index 14ea54b..3a02113 100644
--- a/drivers/input/touchscreen/ads7846.c
+++ b/drivers/input/touchscreen/ads7846.c
@@ -590,9 +590,11 @@ static ssize_t ads7846_disable_store(struct device *dev,
 {
 	struct ads7846 *ts = dev_get_drvdata(dev);
 	unsigned long i;
+	int rv;
 
-	if (strict_strtoul(buf, 10, &i))
-		return -EINVAL;
+	rv = kstrtoul(buf, 10, &i);
+	if (rv < 0)
+		return rv;
 
 	if (i)
 		ads7846_disable(ts);
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 24/52] kstrtox: convert drivers/isdn/
  2011-02-05 14:20 [PATCH 01/52] kstrtox: converting strings to integers done (hopefully) right Alexey Dobriyan
                   ` (21 preceding siblings ...)
  2011-02-05 14:20 ` [PATCH 23/52] kstrtox: convert drivers/input/ Alexey Dobriyan
@ 2011-02-05 14:20 ` Alexey Dobriyan
  2011-02-05 14:20 ` [PATCH 25/52] kstrtox: convert drivers/leds/ Alexey Dobriyan
                   ` (27 subsequent siblings)
  50 siblings, 0 replies; 58+ messages in thread
From: Alexey Dobriyan @ 2011-02-05 14:20 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, adobriyan


Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
 drivers/isdn/gigaset/ev-layer.c    |   25 +++++++++----------------
 drivers/isdn/hysdn/hysdn_proclog.c |   11 ++++-------
 2 files changed, 13 insertions(+), 23 deletions(-)

diff --git a/drivers/isdn/gigaset/ev-layer.c b/drivers/isdn/gigaset/ev-layer.c
index a141876..37f7347 100644
--- a/drivers/isdn/gigaset/ev-layer.c
+++ b/drivers/isdn/gigaset/ev-layer.c
@@ -390,12 +390,12 @@ static const struct zsau_resp_t {
  */
 static int cid_of_response(char *s)
 {
-	unsigned long cid;
+	unsigned int cid;
 	int rc;
 
 	if (s[-1] != ';')
 		return 0;	/* no CID separator */
-	rc = strict_strtoul(s, 10, &cid);
+	rc = kstrtouint(s, 10, &cid);
 	if (rc)
 		return 0;	/* CID not numeric */
 	if (cid < 1 || cid > 65535)
@@ -566,27 +566,20 @@ void gigaset_handle_modem_response(struct cardstate *cs)
 		case RT_ZCAU:
 			event->parameter = -1;
 			if (curarg + 1 < params) {
-				unsigned long type, value;
+				u8 type, value;
 
-				i = strict_strtoul(argv[curarg++], 16, &type);
-				j = strict_strtoul(argv[curarg++], 16, &value);
+				i = kstrtou8(argv[curarg++], 16, &type);
+				j = kstrtou8(argv[curarg++], 16, &value);
 
-				if (i == 0 && type < 256 &&
-				    j == 0 && value < 256)
+				if (i == 0 && j == 0)
 					event->parameter = (type << 8) | value;
 			} else
 				curarg = params - 1;
 			break;
 		case RT_NUMBER:
-			event->parameter = -1;
-			if (curarg < params) {
-				unsigned long res;
-				int rc;
-
-				rc = strict_strtoul(argv[curarg++], 10, &res);
-				if (rc == 0)
-					event->parameter = res;
-			}
+			if (curarg >= params ||
+			    kstrtoint(argv[curarg++], 10, &event->parameter))
+				event->parameter = -1;
 			gig_dbg(DEBUG_EVENT, "parameter==%d", event->parameter);
 			break;
 		}
diff --git a/drivers/isdn/hysdn/hysdn_proclog.c b/drivers/isdn/hysdn/hysdn_proclog.c
index 2ee93d0..236cc7d 100644
--- a/drivers/isdn/hysdn/hysdn_proclog.c
+++ b/drivers/isdn/hysdn/hysdn_proclog.c
@@ -155,7 +155,6 @@ put_log_buffer(hysdn_card * card, char *cp)
 static ssize_t
 hysdn_log_write(struct file *file, const char __user *buf, size_t count, loff_t * off)
 {
-	unsigned long u = 0;
 	int rc;
 	unsigned char valbuf[128];
 	hysdn_card *card = file->private_data;
@@ -167,12 +166,10 @@ hysdn_log_write(struct file *file, const char __user *buf, size_t count, loff_t
 
 	valbuf[count] = 0;	/* terminating 0 */
 
-	rc = strict_strtoul(valbuf, 0, &u);
-
-	if (rc == 0) {
-		card->debug_flags = u;	/* remember debug flags */
-		hysdn_addlog(card, "debug set to 0x%lx", card->debug_flags);
-	}
+	rc = kstrtoul(valbuf, 0, &card->debug_flags);
+	if (rc < 0)
+		return rc;
+	hysdn_addlog(card, "debug set to 0x%lx", card->debug_flags);
 	return (count);
 }				/* hysdn_log_write */
 
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 25/52] kstrtox: convert drivers/leds/
  2011-02-05 14:20 [PATCH 01/52] kstrtox: converting strings to integers done (hopefully) right Alexey Dobriyan
                   ` (22 preceding siblings ...)
  2011-02-05 14:20 ` [PATCH 24/52] kstrtox: convert drivers/isdn/ Alexey Dobriyan
@ 2011-02-05 14:20 ` Alexey Dobriyan
  2011-02-05 14:20 ` [PATCH 26/52] kstrtox: convert drivers/macintosh/ Alexey Dobriyan
                   ` (26 subsequent siblings)
  50 siblings, 0 replies; 58+ messages in thread
From: Alexey Dobriyan @ 2011-02-05 14:20 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, adobriyan


Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
 drivers/leds/leds-bd2802.c       |   10 +++++-----
 drivers/leds/leds-lp5521.c       |    9 +++++----
 drivers/leds/leds-lp5523.c       |   11 ++++++-----
 drivers/leds/leds-netxbig.c      |    2 +-
 drivers/leds/leds-ns2.c          |    2 +-
 drivers/leds/leds-ss4200.c       |    4 ++--
 drivers/leds/ledtrig-backlight.c |    2 +-
 drivers/leds/ledtrig-gpio.c      |    2 +-
 8 files changed, 22 insertions(+), 20 deletions(-)

diff --git a/drivers/leds/leds-bd2802.c b/drivers/leds/leds-bd2802.c
index 19dc4b6..4248173 100644
--- a/drivers/leds/leds-bd2802.c
+++ b/drivers/leds/leds-bd2802.c
@@ -338,15 +338,15 @@ static ssize_t bd2802_store_reg##reg_addr(struct device *dev,		\
 	struct device_attribute *attr, const char *buf, size_t count)	\
 {									\
 	struct bd2802_led *led = i2c_get_clientdata(to_i2c_client(dev));\
-	unsigned long val;						\
+	u8 val;						\
 	int ret;							\
 	if (!count)							\
 		return -EINVAL;						\
-	ret = strict_strtoul(buf, 16, &val);				\
+	ret = kstrtou8(buf, 16, &val);					\
 	if (ret)							\
 		return ret;						\
 	down_write(&led->rwsem);					\
-	bd2802_write_byte(led->client, reg_addr, (u8) val);		\
+	bd2802_write_byte(led->client, reg_addr, val);			\
 	up_write(&led->rwsem);						\
 	return count;							\
 }									\
@@ -502,11 +502,11 @@ static ssize_t bd2802_store_##attr_name(struct device *dev,		\
 	struct device_attribute *attr, const char *buf, size_t count)	\
 {									\
 	struct bd2802_led *led = i2c_get_clientdata(to_i2c_client(dev));\
-	unsigned long val;						\
+	unsigned int val;						\
 	int ret;							\
 	if (!count)							\
 		return -EINVAL;						\
-	ret = strict_strtoul(buf, 16, &val);				\
+	ret = kstrtouint(buf, 16, &val);				\
 	if (ret)							\
 		return ret;						\
 	down_write(&led->rwsem);					\
diff --git a/drivers/leds/leds-lp5521.c b/drivers/leds/leds-lp5521.c
index 80a3ae3..7af4441 100644
--- a/drivers/leds/leds-lp5521.c
+++ b/drivers/leds/leds-lp5521.c
@@ -498,11 +498,12 @@ static ssize_t store_current(struct device *dev,
 	struct led_classdev *led_cdev = dev_get_drvdata(dev);
 	struct lp5521_led *led = cdev_to_led(led_cdev);
 	struct lp5521_chip *chip = led_to_lp5521(led);
-	ssize_t ret;
-	unsigned long curr;
+	u8 curr;
+	int ret;
 
-	if (strict_strtoul(buf, 0, &curr))
-		return -EINVAL;
+	ret = kstrtou8(buf, 0, &curr);
+	if (ret < 0)
+		return ret;
 
 	if (curr > led->max_current)
 		return -EINVAL;
diff --git a/drivers/leds/leds-lp5523.c b/drivers/leds/leds-lp5523.c
index d0c4068..959e87b 100644
--- a/drivers/leds/leds-lp5523.c
+++ b/drivers/leds/leds-lp5523.c
@@ -689,11 +689,12 @@ static ssize_t store_current(struct device *dev,
 	struct led_classdev *led_cdev = dev_get_drvdata(dev);
 	struct lp5523_led *led = cdev_to_led(led_cdev);
 	struct lp5523_chip *chip = led_to_lp5523(led);
-	ssize_t ret;
-	unsigned long curr;
+	u8 curr;
+	int ret;
 
-	if (strict_strtoul(buf, 0, &curr))
-		return -EINVAL;
+	ret = kstrtou8(buf, 0, &curr);
+	if (ret < 0)
+		return ret;
 
 	if (curr > led->max_current)
 		return -EINVAL;
@@ -701,7 +702,7 @@ static ssize_t store_current(struct device *dev,
 	mutex_lock(&chip->lock);
 	ret = lp5523_write(chip->client,
 			LP5523_REG_LED_CURRENT_BASE + led->chan_nr,
-			(u8)curr);
+			curr);
 	mutex_unlock(&chip->lock);
 
 	if (ret < 0)
diff --git a/drivers/leds/leds-netxbig.c b/drivers/leds/leds-netxbig.c
index f2e51c1..b149f30 100644
--- a/drivers/leds/leds-netxbig.c
+++ b/drivers/leds/leds-netxbig.c
@@ -255,7 +255,7 @@ static ssize_t netxbig_led_sata_store(struct device *dev,
 	int mode_val;
 	int ret;
 
-	ret = strict_strtoul(buff, 10, &enable);
+	ret = kstrtoul(buff, 10, &enable);
 	if (ret < 0)
 		return ret;
 
diff --git a/drivers/leds/leds-ns2.c b/drivers/leds/leds-ns2.c
index f77d48d..4027583 100644
--- a/drivers/leds/leds-ns2.c
+++ b/drivers/leds/leds-ns2.c
@@ -148,7 +148,7 @@ static ssize_t ns2_led_sata_store(struct device *dev,
 	unsigned long enable;
 	enum ns2_led_modes mode;
 
-	ret = strict_strtoul(buff, 10, &enable);
+	ret = kstrtoul(buff, 10, &enable);
 	if (ret < 0)
 		return ret;
 
diff --git a/drivers/leds/leds-ss4200.c b/drivers/leds/leds-ss4200.c
index 614ebeb..56b3ab8 100644
--- a/drivers/leds/leds-ss4200.c
+++ b/drivers/leds/leds-ss4200.c
@@ -457,9 +457,9 @@ static ssize_t nas_led_blink_store(struct device *dev,
 {
 	int ret;
 	struct led_classdev *led = dev_get_drvdata(dev);
-	unsigned long blink_state;
+	u32 blink_state;
 
-	ret = strict_strtoul(buf, 10, &blink_state);
+	ret = kstrtou32(buf, 10, &blink_state);
 	if (ret)
 		return ret;
 
diff --git a/drivers/leds/ledtrig-backlight.c b/drivers/leds/ledtrig-backlight.c
index 2b513a2..9e376d6 100644
--- a/drivers/leds/ledtrig-backlight.c
+++ b/drivers/leds/ledtrig-backlight.c
@@ -76,7 +76,7 @@ static ssize_t bl_trig_invert_store(struct device *dev,
 	unsigned long invert;
 	int ret;
 
-	ret = strict_strtoul(buf, 10, &invert);
+	ret = kstrtoul(buf, 10, &invert);
 	if (ret < 0)
 		return ret;
 
diff --git a/drivers/leds/ledtrig-gpio.c b/drivers/leds/ledtrig-gpio.c
index ecc4bf3..fab7c3f 100644
--- a/drivers/leds/ledtrig-gpio.c
+++ b/drivers/leds/ledtrig-gpio.c
@@ -110,7 +110,7 @@ static ssize_t gpio_trig_inverted_store(struct device *dev,
 	unsigned long inverted;
 	int ret;
 
-	ret = strict_strtoul(buf, 10, &inverted);
+	ret = kstrtoul(buf, 10, &inverted);
 	if (ret < 0)
 		return ret;
 
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 26/52] kstrtox: convert drivers/macintosh/
  2011-02-05 14:20 [PATCH 01/52] kstrtox: converting strings to integers done (hopefully) right Alexey Dobriyan
                   ` (23 preceding siblings ...)
  2011-02-05 14:20 ` [PATCH 25/52] kstrtox: convert drivers/leds/ Alexey Dobriyan
@ 2011-02-05 14:20 ` Alexey Dobriyan
  2011-02-05 14:20 ` [PATCH 27/52] kstrtox: convert drivers/md/ Alexey Dobriyan
                   ` (25 subsequent siblings)
  50 siblings, 0 replies; 58+ messages in thread
From: Alexey Dobriyan @ 2011-02-05 14:20 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, adobriyan


Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
 drivers/macintosh/ams/ams-input.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/macintosh/ams/ams-input.c b/drivers/macintosh/ams/ams-input.c
index 8a71239..d4a6a64 100644
--- a/drivers/macintosh/ams/ams-input.c
+++ b/drivers/macintosh/ams/ams-input.c
@@ -116,10 +116,13 @@ static ssize_t ams_input_show_joystick(struct device *dev,
 static ssize_t ams_input_store_joystick(struct device *dev,
 	struct device_attribute *attr, const char *buf, size_t count)
 {
-	unsigned long enable;
-	int error = 0;
+	unsigned int enable;
+	int error;
 
-	if (strict_strtoul(buf, 0, &enable) || enable > 1)
+	error = kstrtouint(buf, 0, &enable);
+	if (error < 0)
+		return error;
+	if (enable > 1)
 		return -EINVAL;
 
 	mutex_lock(&ams_input_mutex);
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 27/52] kstrtox: convert drivers/md/
  2011-02-05 14:20 [PATCH 01/52] kstrtox: converting strings to integers done (hopefully) right Alexey Dobriyan
                   ` (24 preceding siblings ...)
  2011-02-05 14:20 ` [PATCH 26/52] kstrtox: convert drivers/macintosh/ Alexey Dobriyan
@ 2011-02-05 14:20 ` Alexey Dobriyan
  2011-02-05 14:20 ` [PATCH 28/52] kstrtox: convert drivers/mfd/ Alexey Dobriyan
                   ` (24 subsequent siblings)
  50 siblings, 0 replies; 58+ messages in thread
From: Alexey Dobriyan @ 2011-02-05 14:20 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, adobriyan


Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
 drivers/md/bitmap.c  |   14 ++++----
 drivers/md/dm-raid.c |   31 ++++++++++-------
 drivers/md/md.c      |   86 +++++++++++++++++++++++++++++++++----------------
 drivers/md/md.h      |    2 +-
 drivers/md/raid5.c   |   16 ++++++---
 5 files changed, 94 insertions(+), 55 deletions(-)

diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index 9a35320..68c5152 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -1885,10 +1885,8 @@ location_store(mddev_t *mddev, const char *buf, size_t len)
 			return -EINVAL;
 		} else {
 			int rv;
-			if (buf[0] == '+')
-				rv = strict_strtoll(buf+1, 10, &offset);
-			else
-				rv = strict_strtoll(buf, 10, &offset);
+
+			rv = kstrtoll(buf, 10, &offset);
 			if (rv)
 				return rv;
 			if (offset == 0)
@@ -1943,7 +1941,7 @@ timeout_store(mddev_t *mddev, const char *buf, size_t len)
 {
 	/* timeout can be set at any time */
 	unsigned long timeout;
-	int rv = strict_strtoul_scaled(buf, &timeout, 4);
+	int rv = kstrtoul_scaled(buf, &timeout, 4);
 	if (rv)
 		return rv;
 
@@ -1984,7 +1982,9 @@ static ssize_t
 backlog_store(mddev_t *mddev, const char *buf, size_t len)
 {
 	unsigned long backlog;
-	int rv = strict_strtoul(buf, 10, &backlog);
+	int rv;
+
+	rv = kstrtoul(buf, 10, &backlog);
 	if (rv)
 		return rv;
 	if (backlog > COUNTER_MAX)
@@ -2010,7 +2010,7 @@ chunksize_store(mddev_t *mddev, const char *buf, size_t len)
 	unsigned long csize;
 	if (mddev->bitmap)
 		return -EBUSY;
-	rv = strict_strtoul(buf, 10, &csize);
+	rv = kstrtoul(buf, 10, &csize);
 	if (rv)
 		return rv;
 	if (csize < 512 ||
diff --git a/drivers/md/dm-raid.c b/drivers/md/dm-raid.c
index b9e1e15..e889c24 100644
--- a/drivers/md/dm-raid.c
+++ b/drivers/md/dm-raid.c
@@ -254,12 +254,15 @@ static int parse_raid_params(struct raid_set *rs, char **argv,
 	unsigned i, rebuild_cnt = 0;
 	unsigned long value;
 	char *key;
+	int rv;
 
 	/*
 	 * First, parse the in-order required arguments
 	 */
-	if ((strict_strtoul(argv[0], 10, &value) < 0) ||
-	    !is_power_of_2(value) || (value < 8)) {
+	rv = kstrtoul(argv[0], 10, &value);
+	if (rv < 0)
+		return rv;
+	if (!is_power_of_2(value) || (value < 8)) {
 		rs->ti->error = "Bad chunk size";
 		return -EINVAL;
 	}
@@ -295,9 +298,10 @@ static int parse_raid_params(struct raid_set *rs, char **argv,
 		}
 
 		key = argv[i++];
-		if (strict_strtoul(argv[i], 10, &value) < 0) {
+		rv = kstrtoul(argv[i], 10, &value);
+		if (rv < 0) {
 			rs->ti->error = "Bad numerical argument given in raid params";
-			return -EINVAL;
+			return rv;
 		}
 
 		if (!strcmp(key, "rebuild")) {
@@ -410,10 +414,10 @@ static void raid_unplug(struct dm_target_callbacks *cb)
  */
 static int raid_ctr(struct dm_target *ti, unsigned argc, char **argv)
 {
-	int ret;
 	struct raid_type *rt;
-	unsigned long num_raid_params, num_raid_devs;
+	unsigned int num_raid_params, num_raid_devs;
 	struct raid_set *rs = NULL;
+	int ret;
 
 	/* Must have at least <raid_type> <#raid_params> */
 	if (argc < 2) {
@@ -431,9 +435,10 @@ static int raid_ctr(struct dm_target *ti, unsigned argc, char **argv)
 	argv++;
 
 	/* number of RAID parameters */
-	if (strict_strtoul(argv[0], 10, &num_raid_params) < 0) {
+	ret = kstrtouint(argv[0], 10, &num_raid_params);
+	if (ret < 0) {
 		ti->error = "Cannot understand number of RAID parameters";
-		return -EINVAL;
+		return ret;
 	}
 	argc--;
 	argv++;
@@ -444,17 +449,17 @@ static int raid_ctr(struct dm_target *ti, unsigned argc, char **argv)
 		return -EINVAL;
 	}
 
-	if ((strict_strtoul(argv[num_raid_params], 10, &num_raid_devs) < 0) ||
-	    (num_raid_devs >= INT_MAX)) {
+	ret = kstrtouint(argv[num_raid_params], 10, &num_raid_devs);
+	if (ret < 0) {
 		ti->error = "Cannot understand number of raid devices";
-		return -EINVAL;
+		return ret;
 	}
 
-	rs = context_alloc(ti, rt, (unsigned)num_raid_devs);
+	rs = context_alloc(ti, rt, num_raid_devs);
 	if (IS_ERR(rs))
 		return PTR_ERR(rs);
 
-	ret = parse_raid_params(rs, argv, (unsigned)num_raid_params);
+	ret = parse_raid_params(rs, argv, num_raid_params);
 	if (ret)
 		goto bad;
 
diff --git a/drivers/md/md.c b/drivers/md/md.c
index b76cfc8..de8e62a 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -2552,13 +2552,15 @@ static int overlaps(sector_t s1, sector_t l1, sector_t s2, sector_t l2)
 	return 1;
 }
 
-static int strict_blocks_to_sectors(const char *buf, sector_t *sectors)
+static int kstr_blocks_to_sector_t(const char *buf, sector_t *sectors)
 {
 	unsigned long long blocks;
 	sector_t new;
+	int rv;
 
-	if (strict_strtoull(buf, 10, &blocks) < 0)
-		return -EINVAL;
+	rv = kstrtoull(buf, 10, &blocks);
+	if (rv < 0)
+		return rv;
 
 	if (blocks & 1ULL << (8 * sizeof(blocks) - 1))
 		return -EINVAL; /* sector conversion overflow */
@@ -2571,15 +2573,31 @@ static int strict_blocks_to_sectors(const char *buf, sector_t *sectors)
 	return 0;
 }
 
+static int kstrto_sector_t(const char *buf, unsigned int base, sector_t *res)
+{
+	unsigned long long tmp;
+	int rv;
+
+	rv = kstrtoull(buf, base, &tmp);
+	if (rv < 0)
+		return rv;
+	if (tmp != (unsigned long long)(sector_t)tmp)
+		return -EINVAL;
+	*res = tmp;
+	return 0;
+}
+
 static ssize_t
 rdev_size_store(mdk_rdev_t *rdev, const char *buf, size_t len)
 {
 	mddev_t *my_mddev = rdev->mddev;
 	sector_t oldsectors = rdev->sectors;
 	sector_t sectors;
+	int rv;
 
-	if (strict_blocks_to_sectors(buf, &sectors) < 0)
-		return -EINVAL;
+	rv = kstr_blocks_to_sector_t(buf, &sectors);
+	if (rv < 0)
+		return rv;
 	if (my_mddev->pers && rdev->raid_disk >= 0) {
 		if (my_mddev->persistent) {
 			sectors = super_types[my_mddev->major_version].
@@ -2657,12 +2675,17 @@ static ssize_t recovery_start_show(mdk_rdev_t *rdev, char *page)
 
 static ssize_t recovery_start_store(mdk_rdev_t *rdev, const char *buf, size_t len)
 {
-	unsigned long long recovery_start;
+	sector_t recovery_start;
 
 	if (cmd_match(buf, "none"))
 		recovery_start = MaxSector;
-	else if (strict_strtoull(buf, 10, &recovery_start))
-		return -EINVAL;
+	else {
+		int rv;
+
+		rv = kstrto_sector_t(buf, 10, &recovery_start);
+		if (rv < 0)
+			return rv;
+	}
 
 	if (rdev->mddev->pers &&
 	    rdev->raid_disk >= 0)
@@ -2914,7 +2937,7 @@ static void analyze_sbs(mddev_t * mddev)
  * multiplying that number by 10^'scale'.
  * all without any floating-point arithmetic.
  */
-int strict_strtoul_scaled(const char *cp, unsigned long *res, int scale)
+int kstrtoul_scaled(const char *cp, unsigned long *res, int scale)
 {
 	unsigned long result = 0;
 	long decimals = -1;
@@ -2958,7 +2981,7 @@ safe_delay_store(mddev_t *mddev, const char *cbuf, size_t len)
 {
 	unsigned long msec;
 
-	if (strict_strtoul_scaled(cbuf, &msec, 3) < 0)
+	if (kstrtoul_scaled(cbuf, &msec, 3) < 0)
 		return -EINVAL;
 	if (msec == 0)
 		mddev->safemode_delay = 0;
@@ -2995,7 +3018,7 @@ level_store(mddev_t *mddev, const char *buf, size_t len)
 	char clevel[16];
 	ssize_t rv = len;
 	struct mdk_personality *pers;
-	long level;
+	int level;
 	void *priv;
 	mdk_rdev_t *rdev;
 
@@ -3032,11 +3055,8 @@ level_store(mddev_t *mddev, const char *buf, size_t len)
 	/* Now find the new personality */
 	if (len == 0 || len >= sizeof(clevel))
 		return -EINVAL;
-	strncpy(clevel, buf, len);
-	if (clevel[len-1] == '\n')
-		len--;
-	clevel[len] = 0;
-	if (strict_strtol(clevel, 10, &level))
+	strlcpy(clevel, buf, sizeof(clevel));
+	if (kstrtoint(clevel, 10, &level))
 		level = LEVEL_NONE;
 
 	if (request_module("md-%s", clevel) != 0)
@@ -3632,8 +3652,9 @@ size_store(mddev_t *mddev, const char *buf, size_t len)
 	 * If array is active, we can try an on-line resize
 	 */
 	sector_t sectors;
-	int err = strict_blocks_to_sectors(buf, &sectors);
+	int err;
 
+	err = kstr_blocks_to_sector_t(buf, &sectors);
 	if (err < 0)
 		return err;
 	if (mddev->pers) {
@@ -3877,11 +3898,12 @@ sync_force_parallel_show(mddev_t *mddev, char *page)
 static ssize_t
 sync_force_parallel_store(mddev_t *mddev, const char *buf, size_t len)
 {
-	long n;
-
-	if (strict_strtol(buf, 10, &n))
-		return -EINVAL;
+	int n;
+	int rv;
 
+	rv = kstrtoint(buf, 10, &n);
+	if (rv < 0)
+		return rv;
 	if (n != 0 && n != 1)
 		return -EINVAL;
 
@@ -3941,8 +3963,10 @@ min_sync_show(mddev_t *mddev, char *page)
 static ssize_t
 min_sync_store(mddev_t *mddev, const char *buf, size_t len)
 {
-	unsigned long long min;
-	if (strict_strtoull(buf, 10, &min))
+	sector_t min;
+	int rv;
+
+	rv = kstrto_sector_t(buf, 10, &min);
 		return -EINVAL;
 	if (min > mddev->resync_max)
 		return -EINVAL;
@@ -3978,9 +4002,12 @@ max_sync_store(mddev_t *mddev, const char *buf, size_t len)
 	if (strncmp(buf, "max", 3) == 0)
 		mddev->resync_max = MaxSector;
 	else {
-		unsigned long long max;
-		if (strict_strtoull(buf, 10, &max))
-			return -EINVAL;
+		sector_t max;
+		int rv;
+
+		rv = kstrto_sector_t(buf, 10, &max);
+		if (rv < 0)
+			return rv;
 		if (max < mddev->resync_min)
 			return -EINVAL;
 		if (max < mddev->resync_max &&
@@ -4124,8 +4151,11 @@ array_size_store(mddev_t *mddev, const char *buf, size_t len)
 
 		mddev->external_size = 0;
 	} else {
-		if (strict_blocks_to_sectors(buf, &sectors) < 0)
-			return -EINVAL;
+		int rv;
+
+		rv = kstr_blocks_to_sector_t(buf, &sectors);
+		if (rv < 0)
+			return rv;
 		if (mddev->pers && mddev->pers->size(mddev, 0, 0) < sectors)
 			return -E2BIG;
 
diff --git a/drivers/md/md.h b/drivers/md/md.h
index eec517c..9d145d4 100644
--- a/drivers/md/md.h
+++ b/drivers/md/md.h
@@ -514,7 +514,7 @@ extern void md_set_array_sectors(mddev_t *mddev, sector_t array_sectors);
 extern int md_check_no_bitmap(mddev_t *mddev);
 extern int md_integrity_register(mddev_t *mddev);
 extern void md_integrity_add_rdev(mdk_rdev_t *rdev, mddev_t *mddev);
-extern int strict_strtoul_scaled(const char *cp, unsigned long *res, int scale);
+extern int kstrtoul_scaled(const char *cp, unsigned long *res, int scale);
 extern void restore_bitmap_write_access(struct file *file);
 extern void md_unplug(mddev_t *mddev);
 
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 5044bab..34de5d0 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -4614,7 +4614,7 @@ static ssize_t
 raid5_store_stripe_cache_size(mddev_t *mddev, const char *page, size_t len)
 {
 	raid5_conf_t *conf = mddev->private;
-	unsigned long new;
+	unsigned int new;
 	int err;
 
 	if (len >= PAGE_SIZE)
@@ -4622,8 +4622,9 @@ raid5_store_stripe_cache_size(mddev_t *mddev, const char *page, size_t len)
 	if (!conf)
 		return -ENODEV;
 
-	if (strict_strtoul(page, 10, &new))
-		return -EINVAL;
+	err = kstrtouint(page, 10, &new);
+	if (err < 0)
+		return err;
 	err = raid5_set_cache_size(mddev, new);
 	if (err)
 		return err;
@@ -4649,14 +4650,17 @@ static ssize_t
 raid5_store_preread_threshold(mddev_t *mddev, const char *page, size_t len)
 {
 	raid5_conf_t *conf = mddev->private;
-	unsigned long new;
+	unsigned int new;
+	int rv;
+
 	if (len >= PAGE_SIZE)
 		return -EINVAL;
 	if (!conf)
 		return -ENODEV;
 
-	if (strict_strtoul(page, 10, &new))
-		return -EINVAL;
+	rv = kstrtouint(page, 10, &new);
+	if (rv < 0)
+		return rv;
 	if (new > conf->max_nr_stripes)
 		return -EINVAL;
 	conf->bypass_threshold = new;
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 28/52] kstrtox: convert drivers/mfd/
  2011-02-05 14:20 [PATCH 01/52] kstrtox: converting strings to integers done (hopefully) right Alexey Dobriyan
                   ` (25 preceding siblings ...)
  2011-02-05 14:20 ` [PATCH 27/52] kstrtox: convert drivers/md/ Alexey Dobriyan
@ 2011-02-05 14:20 ` Alexey Dobriyan
  2011-02-05 14:20 ` [PATCH 29/52] kstrtox: convert drivers/misc/ Alexey Dobriyan
                   ` (23 subsequent siblings)
  50 siblings, 0 replies; 58+ messages in thread
From: Alexey Dobriyan @ 2011-02-05 14:20 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, adobriyan


Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
 drivers/mfd/ab3100-core.c    |   16 +++----------
 drivers/mfd/ab3550-core.c    |   48 +++++++++++++++--------------------------
 drivers/mfd/ab8500-debugfs.c |   31 ++++++++------------------
 3 files changed, 32 insertions(+), 63 deletions(-)

diff --git a/drivers/mfd/ab3100-core.c b/drivers/mfd/ab3100-core.c
index 4193af5..5b1c8ac 100644
--- a/drivers/mfd/ab3100-core.c
+++ b/drivers/mfd/ab3100-core.c
@@ -497,7 +497,7 @@ static ssize_t ab3100_get_set_reg(struct file *file,
 	char buf[32];
 	ssize_t buf_size;
 	int regp;
-	unsigned long user_reg;
+	u8 reg;
 	int err;
 	int i = 0;
 
@@ -520,22 +520,19 @@ static ssize_t ab3100_get_set_reg(struct file *file,
 	/*
 	 * Advance pointer to end of string then terminate
 	 * the register string. This is needed to satisfy
-	 * the strict_strtoul() function.
+	 * the kstrtou8() function.
 	 */
 	while ((i < buf_size) && (buf[i] != ' '))
 		i++;
 	buf[i] = '\0';
 
-	err = strict_strtoul(&buf[regp], 16, &user_reg);
+	err = kstrtou8(&buf[regp], 16, &reg);
 	if (err)
 		return err;
-	if (user_reg > 0xff)
-		return -EINVAL;
 
 	/* Either we read or we write a register here */
 	if (!priv->mode) {
 		/* Reading */
-		u8 reg = (u8) user_reg;
 		u8 regvalue;
 
 		ab3100_get_register_interruptible(ab3100, reg, &regvalue);
@@ -545,8 +542,6 @@ static ssize_t ab3100_get_set_reg(struct file *file,
 			 reg, regvalue);
 	} else {
 		int valp;
-		unsigned long user_value;
-		u8 reg = (u8) user_reg;
 		u8 value;
 		u8 regvalue;
 
@@ -563,13 +558,10 @@ static ssize_t ab3100_get_set_reg(struct file *file,
 			i++;
 		buf[i] = '\0';
 
-		err = strict_strtoul(&buf[valp], 16, &user_value);
+		err = kstrtou8(&buf[valp], 16, &value);
 		if (err)
 			return err;
-		if (user_reg > 0xff)
-			return -EINVAL;
 
-		value = (u8) user_value;
 		ab3100_set_register_interruptible(ab3100, reg, value);
 		ab3100_get_register_interruptible(ab3100, reg, &regvalue);
 
diff --git a/drivers/mfd/ab3550-core.c b/drivers/mfd/ab3550-core.c
index 5fbca34..55d74c5 100644
--- a/drivers/mfd/ab3550-core.c
+++ b/drivers/mfd/ab3550-core.c
@@ -73,8 +73,8 @@ struct ab3550 {
 	u8 startup_events[AB3550_NUM_EVENT_REG];
 	bool startup_events_read;
 #ifdef CONFIG_DEBUG_FS
-	unsigned int debug_bank;
-	unsigned int debug_address;
+	u8 debug_bank;
+	u8 debug_address;
 #endif
 };
 
@@ -865,7 +865,7 @@ static int ab3550_bank_print(struct seq_file *s, void *p)
 {
 	struct ab3550 *ab = s->private;
 
-	seq_printf(s, "%d\n", ab->debug_bank);
+	seq_printf(s, "%hhu\n", ab->debug_bank);
 	return 0;
 }
 
@@ -881,7 +881,7 @@ static ssize_t ab3550_bank_write(struct file *file,
 	struct ab3550 *ab = ((struct seq_file *)(file->private_data))->private;
 	char buf[32];
 	int buf_size;
-	unsigned long user_bank;
+	u8 user_bank;
 	int err;
 
 	/* Get userspace string and assure termination */
@@ -890,7 +890,7 @@ static ssize_t ab3550_bank_write(struct file *file,
 		return -EFAULT;
 	buf[buf_size] = 0;
 
-	err = strict_strtoul(buf, 0, &user_bank);
+	err = kstrtou8(buf, 0, &user_bank);
 	if (err)
 		return -EINVAL;
 
@@ -925,7 +925,6 @@ static ssize_t ab3550_address_write(struct file *file,
 	struct ab3550 *ab = ((struct seq_file *)(file->private_data))->private;
 	char buf[32];
 	int buf_size;
-	unsigned long user_address;
 	int err;
 
 	/* Get userspace string and assure termination */
@@ -934,15 +933,9 @@ static ssize_t ab3550_address_write(struct file *file,
 		return -EFAULT;
 	buf[buf_size] = 0;
 
-	err = strict_strtoul(buf, 0, &user_address);
-	if (err)
-		return -EINVAL;
-	if (user_address > 0xff) {
-		dev_err(&ab->i2c_client[0]->dev,
-			"debugfs error input > 0xff\n");
-		return -EINVAL;
-	}
-	ab->debug_address = user_address;
+	err = kstrtou8(buf, 0, &ab->debug_address);
+	if (err < 0)
+		return err;
 	return buf_size;
 }
 
@@ -952,8 +945,8 @@ static int ab3550_val_print(struct seq_file *s, void *p)
 	int err;
 	u8 regvalue;
 
-	err = get_register_interruptible(ab, (u8)ab->debug_bank,
-		(u8)ab->debug_address, &regvalue);
+	err = get_register_interruptible(ab, ab->debug_bank,
+		ab->debug_address, &regvalue);
 	if (err)
 		return -EINVAL;
 	seq_printf(s, "0x%02X\n", regvalue);
@@ -973,7 +966,7 @@ static ssize_t ab3550_val_write(struct file *file,
 	struct ab3550 *ab = ((struct seq_file *)(file->private_data))->private;
 	char buf[32];
 	int buf_size;
-	unsigned long user_val;
+	u8 user_val;
 	int err;
 	u8 regvalue;
 
@@ -983,22 +976,17 @@ static ssize_t ab3550_val_write(struct file *file,
 		return -EFAULT;
 	buf[buf_size] = 0;
 
-	err = strict_strtoul(buf, 0, &user_val);
-	if (err)
-		return -EINVAL;
-	if (user_val > 0xff) {
-		dev_err(&ab->i2c_client[0]->dev,
-			"debugfs error input > 0xff\n");
-		return -EINVAL;
-	}
+	err = kstrtou8(buf, 0, &user_val);
+	if (err < 0)
+		return err;
 	err = mask_and_set_register_interruptible(
-		ab, (u8)ab->debug_bank,
-		(u8)ab->debug_address, 0xFF, (u8)user_val);
+		ab, ab->debug_bank,
+		ab->debug_address, 0xFF, user_val);
 	if (err)
 		return -EINVAL;
 
-	get_register_interruptible(ab, (u8)ab->debug_bank,
-		(u8)ab->debug_address, &regvalue);
+	get_register_interruptible(ab, ab->debug_bank,
+		ab->debug_address, &regvalue);
 	if (err)
 		return -EINVAL;
 
diff --git a/drivers/mfd/ab8500-debugfs.c b/drivers/mfd/ab8500-debugfs.c
index 3c1541a..2a9e80d 100644
--- a/drivers/mfd/ab8500-debugfs.c
+++ b/drivers/mfd/ab8500-debugfs.c
@@ -14,8 +14,8 @@
 #include <linux/mfd/abx500.h>
 #include <linux/mfd/ab8500.h>
 
-static u32 debug_bank;
-static u32 debug_address;
+static u8 debug_bank;
+static u8 debug_address;
 
 /**
  * struct ab8500_reg_range
@@ -430,9 +430,9 @@ static ssize_t ab8500_bank_write(struct file *file,
 		return -EFAULT;
 	buf[buf_size] = 0;
 
-	err = strict_strtoul(buf, 0, &user_bank);
+	err = kstrtoul(buf, 0, &user_bank);
 	if (err)
-		return -EINVAL;
+		return err;
 
 	if (user_bank >= AB8500_NUM_BANKS) {
 		dev_err(dev, "debugfs error input > number of banks\n");
@@ -458,10 +458,8 @@ static ssize_t ab8500_address_write(struct file *file,
 	const char __user *user_buf,
 	size_t count, loff_t *ppos)
 {
-	struct device *dev = ((struct seq_file *)(file->private_data))->private;
 	char buf[32];
 	int buf_size;
-	unsigned long user_address;
 	int err;
 
 	/* Get userspace string and assure termination */
@@ -470,14 +468,9 @@ static ssize_t ab8500_address_write(struct file *file,
 		return -EFAULT;
 	buf[buf_size] = 0;
 
-	err = strict_strtoul(buf, 0, &user_address);
+	err = kstrtou8(buf, 0, &debug_address);
 	if (err)
-		return -EINVAL;
-	if (user_address > 0xff) {
-		dev_err(dev, "debugfs error input > 0xff\n");
-		return -EINVAL;
-	}
-	debug_address = user_address;
+		return err;
 	return buf_size;
 }
 
@@ -511,7 +504,7 @@ static ssize_t ab8500_val_write(struct file *file,
 	struct device *dev = ((struct seq_file *)(file->private_data))->private;
 	char buf[32];
 	int buf_size;
-	unsigned long user_val;
+	u8 user_val;
 	int err;
 
 	/* Get userspace string and assure termination */
@@ -520,15 +513,11 @@ static ssize_t ab8500_val_write(struct file *file,
 		return -EFAULT;
 	buf[buf_size] = 0;
 
-	err = strict_strtoul(buf, 0, &user_val);
+	err = kstrtou8(buf, 0, &user_val);
 	if (err)
-		return -EINVAL;
-	if (user_val > 0xff) {
-		dev_err(dev, "debugfs error input > 0xff\n");
-		return -EINVAL;
-	}
+		return err;
 	err = abx500_set_register_interruptible(dev,
-		(u8)debug_bank, debug_address, (u8)user_val);
+		(u8)debug_bank, debug_address, user_val);
 	if (err < 0) {
 		printk(KERN_ERR "abx500_set_reg failed %d, %d", err, __LINE__);
 		return -EINVAL;
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 29/52] kstrtox: convert drivers/misc/
  2011-02-05 14:20 [PATCH 01/52] kstrtox: converting strings to integers done (hopefully) right Alexey Dobriyan
                   ` (26 preceding siblings ...)
  2011-02-05 14:20 ` [PATCH 28/52] kstrtox: convert drivers/mfd/ Alexey Dobriyan
@ 2011-02-05 14:20 ` Alexey Dobriyan
  2011-02-05 14:20 ` [PATCH 30/52] kstrtox: convert drivers/mmc/ Alexey Dobriyan
                   ` (22 subsequent siblings)
  50 siblings, 0 replies; 58+ messages in thread
From: Alexey Dobriyan @ 2011-02-05 14:20 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, adobriyan


Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
 drivers/misc/ad525x_dpot.c       |    2 +-
 drivers/misc/apds9802als.c       |    7 ++-
 drivers/misc/apds990x.c          |   45 +++++++++++++---------
 drivers/misc/bh1770glc.c         |   72 ++++++++++++++++++++++--------------
 drivers/misc/bh1780gli.c         |    4 +-
 drivers/misc/bmp085.c            |   31 ++++++---------
 drivers/misc/ep93xx_pwm.c        |   33 ++++++++--------
 drivers/misc/hmc6352.c           |    7 ++-
 drivers/misc/isl29003.c          |   28 ++++++++++----
 drivers/misc/isl29020.c          |    7 ++-
 drivers/misc/iwmc3200top/log.c   |   76 ++++++++++++++++----------------------
 drivers/misc/sgi-gru/gruprocfs.c |    7 ++-
 drivers/misc/ti_dac7512.c        |   10 +++--
 13 files changed, 175 insertions(+), 154 deletions(-)

diff --git a/drivers/misc/ad525x_dpot.c b/drivers/misc/ad525x_dpot.c
index 7cb9110..d0de26a 100644
--- a/drivers/misc/ad525x_dpot.c
+++ b/drivers/misc/ad525x_dpot.c
@@ -472,7 +472,7 @@ static ssize_t sysfs_set_reg(struct device *dev,
 		!test_bit(DPOT_RDAC_MASK & reg, data->otp_en_mask))
 		return -EPERM;
 
-	err = strict_strtoul(buf, 10, &value);
+	err = kstrtoul(buf, 10, &value);
 	if (err)
 		return err;
 
diff --git a/drivers/misc/apds9802als.c b/drivers/misc/apds9802als.c
index 644d4cd..e6d0ebc 100644
--- a/drivers/misc/apds9802als.c
+++ b/drivers/misc/apds9802als.c
@@ -123,11 +123,12 @@ static ssize_t als_sensing_range_store(struct device *dev,
 {
 	struct i2c_client *client = to_i2c_client(dev);
 	struct als_data *data = i2c_get_clientdata(client);
+	unsigned int val;
 	int ret_val;
-	unsigned long val;
 
-	if (strict_strtoul(buf, 10, &val))
-		return -EINVAL;
+	ret_val = kstrtouint(buf, 10, &val);
+	if (ret_val < 0)
+		return ret_val;
 
 	if (val < 4096)
 		val = 1;
diff --git a/drivers/misc/apds990x.c b/drivers/misc/apds990x.c
index 200311f..411ab79 100644
--- a/drivers/misc/apds990x.c
+++ b/drivers/misc/apds990x.c
@@ -694,11 +694,12 @@ static ssize_t apds990x_lux_calib_store(struct device *dev,
 {
 	struct apds990x_chip *chip = dev_get_drvdata(dev);
 	unsigned long value;
+	int rv;
 
-	if (strict_strtoul(buf, 0, &value))
-		return -EINVAL;
-
-	if (chip->lux_calib > APDS_RANGE)
+	rv = kstrtoul(buf, 0, &value);
+	if (rv < 0)
+		return rv;
+	if (value > APDS_RANGE)
 		return -EINVAL;
 
 	chip->lux_calib = value;
@@ -757,11 +758,12 @@ static ssize_t apds990x_rate_store(struct device *dev,
 				  const char *buf, size_t len)
 {
 	struct apds990x_chip *chip =  dev_get_drvdata(dev);
-	unsigned long value;
+	unsigned int value;
 	int ret;
 
-	if (strict_strtoul(buf, 0, &value))
-		return -EINVAL;
+	ret = kstrtouint(buf, 0, &value);
+	if (ret < 0)
+		return ret;
 
 	mutex_lock(&chip->mutex);
 	ret = apds990x_set_arate(chip, value);
@@ -814,9 +816,11 @@ static ssize_t apds990x_prox_enable_store(struct device *dev,
 {
 	struct apds990x_chip *chip =  dev_get_drvdata(dev);
 	unsigned long value;
+	int rv;
 
-	if (strict_strtoul(buf, 0, &value))
-		return -EINVAL;
+	rv = kstrtoul(buf, 0, &value);
+	if (rv < 0)
+		return rv;
 
 	mutex_lock(&chip->mutex);
 
@@ -893,12 +897,12 @@ static ssize_t apds990x_lux_thresh_below_show(struct device *dev,
 static ssize_t apds990x_set_lux_thresh(struct apds990x_chip *chip, u32 *target,
 				const char *buf)
 {
-	int ret = 0;
 	unsigned long thresh;
+	int ret;
 
-	if (strict_strtoul(buf, 0, &thresh))
-		return -EINVAL;
-
+	ret = kstrtoul(buf, 0, &thresh);
+	if (ret < 0)
+		return ret;
 	if (thresh > APDS_RANGE)
 		return -EINVAL;
 
@@ -957,11 +961,12 @@ static ssize_t apds990x_prox_threshold_store(struct device *dev,
 				  const char *buf, size_t len)
 {
 	struct apds990x_chip *chip =  dev_get_drvdata(dev);
-	unsigned long value;
-
-	if (strict_strtoul(buf, 0, &value))
-		return -EINVAL;
+	unsigned int value;
+	int rv;
 
+	rv = kstrtouint(buf, 0, &value);
+	if (rv < 0)
+		return rv;
 	if ((value > APDS_RANGE) || (value == 0) ||
 		(value < APDS_PROX_HYSTERESIS))
 		return -EINVAL;
@@ -991,9 +996,11 @@ static ssize_t apds990x_power_state_store(struct device *dev,
 {
 	struct apds990x_chip *chip =  dev_get_drvdata(dev);
 	unsigned long value;
+	int rv;
 
-	if (strict_strtoul(buf, 0, &value))
-		return -EINVAL;
+	rv = kstrtoul(buf, 0, &value);
+	if (rv < 0)
+		return rv;
 	if (value) {
 		pm_runtime_get_sync(dev);
 		mutex_lock(&chip->mutex);
diff --git a/drivers/misc/bh1770glc.c b/drivers/misc/bh1770glc.c
index d79a972..e9bd722 100644
--- a/drivers/misc/bh1770glc.c
+++ b/drivers/misc/bh1770glc.c
@@ -649,10 +649,11 @@ static ssize_t bh1770_power_state_store(struct device *dev,
 {
 	struct bh1770_chip *chip =  dev_get_drvdata(dev);
 	unsigned long value;
-	ssize_t ret;
+	int ret;
 
-	if (strict_strtoul(buf, 0, &value))
-		return -EINVAL;
+	ret = kstrtoul(buf, 0, &value);
+	if (ret < 0)
+		return ret;
 
 	mutex_lock(&chip->mutex);
 	if (value) {
@@ -726,9 +727,11 @@ static ssize_t bh1770_prox_enable_store(struct device *dev,
 {
 	struct bh1770_chip *chip =  dev_get_drvdata(dev);
 	unsigned long value;
+	int rv;
 
-	if (strict_strtoul(buf, 0, &value))
-		return -EINVAL;
+	rv = kstrtoul(buf, 0, &value);
+	if (rv < 0)
+		return rv;
 
 	mutex_lock(&chip->mutex);
 	/* Assume no proximity. Sensor will tell real state soon */
@@ -823,10 +826,12 @@ static ssize_t bh1770_set_prox_rate_above(struct device *dev,
 					const char *buf, size_t count)
 {
 	struct bh1770_chip *chip =  dev_get_drvdata(dev);
-	unsigned long value;
+	int value;
+	int rv;
 
-	if (strict_strtoul(buf, 0, &value))
-		return -EINVAL;
+	rv = kstrtoint(buf, 0, &value);
+	if (rv < 0)
+		return rv;
 
 	mutex_lock(&chip->mutex);
 	chip->prox_rate_threshold = bh1770_prox_rate_validate(value);
@@ -839,10 +844,12 @@ static ssize_t bh1770_set_prox_rate_below(struct device *dev,
 					const char *buf, size_t count)
 {
 	struct bh1770_chip *chip =  dev_get_drvdata(dev);
-	unsigned long value;
+	int value;
+	int rv;
 
-	if (strict_strtoul(buf, 0, &value))
-		return -EINVAL;
+	rv = kstrtoint(buf, 0, &value);
+	if (rv < 0)
+		return rv;
 
 	mutex_lock(&chip->mutex);
 	chip->prox_rate = bh1770_prox_rate_validate(value);
@@ -862,11 +869,12 @@ static ssize_t bh1770_set_prox_thres(struct device *dev,
 				      const char *buf, size_t count)
 {
 	struct bh1770_chip *chip =  dev_get_drvdata(dev);
-	unsigned long value;
+	unsigned int value;
 	int ret;
 
-	if (strict_strtoul(buf, 0, &value))
-		return -EINVAL;
+	ret = kstrtouint(buf, 0, &value);
+	if (ret < 0)
+		return ret;
 	if (value > BH1770_PROX_RANGE)
 		return -EINVAL;
 
@@ -892,10 +900,12 @@ static ssize_t bh1770_prox_persistence_store(struct device *dev,
 				const char *buf, size_t len)
 {
 	struct bh1770_chip *chip = dev_get_drvdata(dev);
-	unsigned long value;
+	unsigned int value;
+	int rv;
 
-	if (strict_strtoul(buf, 0, &value))
-		return -EINVAL;
+	rv = kstrtouint(buf, 0, &value);
+	if (rv < 0)
+		return rv;
 
 	if (value > BH1770_PROX_MAX_PERSISTENCE)
 		return -EINVAL;
@@ -917,10 +927,12 @@ static ssize_t bh1770_prox_abs_thres_store(struct device *dev,
 				const char *buf, size_t len)
 {
 	struct bh1770_chip *chip = dev_get_drvdata(dev);
-	unsigned long value;
+	unsigned int value;
+	int rv;
 
-	if (strict_strtoul(buf, 0, &value))
-		return -EINVAL;
+	rv = kstrtouint(buf, 0, &value);
+	if (rv < 0)
+		return rv;
 
 	if (value > BH1770_PROX_RANGE)
 		return -EINVAL;
@@ -960,12 +972,14 @@ static ssize_t bh1770_lux_calib_store(struct device *dev,
 				  const char *buf, size_t len)
 {
 	struct bh1770_chip *chip = dev_get_drvdata(dev);
-	unsigned long value;
+	u32 value;
 	u32 old_calib;
 	u32 new_corr;
+	int rv;
 
-	if (strict_strtoul(buf, 0, &value))
-		return -EINVAL;
+	rv = kstrtou32(buf, 0, &value);
+	if (rv < 0)
+		return rv;
 
 	mutex_lock(&chip->mutex);
 	old_calib = chip->lux_calib;
@@ -1012,8 +1026,9 @@ static ssize_t bh1770_set_lux_rate(struct device *dev,
 	unsigned long rate_hz;
 	int ret, i;
 
-	if (strict_strtoul(buf, 0, &rate_hz))
-		return -EINVAL;
+	ret = kstrtoul(buf, 0, &rate_hz);
+	if (ret < 0)
+		return ret;
 
 	for (i = 0; i < ARRAY_SIZE(lux_rates_hz) - 1; i++)
 		if (rate_hz >= lux_rates_hz[i])
@@ -1047,11 +1062,12 @@ static ssize_t bh1770_get_lux_thresh_below(struct device *dev,
 static ssize_t bh1770_set_lux_thresh(struct bh1770_chip *chip, u16 *target,
 				const char *buf)
 {
-	int ret = 0;
 	unsigned long thresh;
+	int ret;
 
-	if (strict_strtoul(buf, 0, &thresh))
-		return -EINVAL;
+	ret = kstrtoul(buf, 0, &thresh);
+	if (ret < 0)
+		return ret;
 
 	if (thresh > BH1770_LUX_RANGE)
 		return -EINVAL;
diff --git a/drivers/misc/bh1780gli.c b/drivers/misc/bh1780gli.c
index d5f3a3f..5faca8e 100644
--- a/drivers/misc/bh1780gli.c
+++ b/drivers/misc/bh1780gli.c
@@ -103,10 +103,10 @@ static ssize_t bh1780_store_power_state(struct device *dev,
 {
 	struct platform_device *pdev = to_platform_device(dev);
 	struct bh1780_data *ddata = platform_get_drvdata(pdev);
-	unsigned long val;
+	int val;
 	int error;
 
-	error = strict_strtoul(buf, 0, &val);
+	error = kstrtoint(buf, 0, &val);
 	if (error)
 		return error;
 
diff --git a/drivers/misc/bmp085.c b/drivers/misc/bmp085.c
index 63ee4c1..b656c36 100644
--- a/drivers/misc/bmp085.c
+++ b/drivers/misc/bmp085.c
@@ -86,7 +86,7 @@ struct bmp085_data {
 	struct bmp085_calibration_data calibration;
 	u32 raw_temperature;
 	u32 raw_pressure;
-	unsigned char oversampling_setting;
+	u8 oversampling_setting; /* [0, 3] */
 	u32 last_temp_measurement;
 	s32 b6; /* calculated temperature correction coefficient */
 };
@@ -284,22 +284,13 @@ exit:
  * increase both. The datasheet gives on overview on how measurement time,
  * accuracy and noise correlate.
  */
-static void bmp085_set_oversampling(struct bmp085_data *data,
-						unsigned char oversampling)
+static void bmp085_set_oversampling(struct bmp085_data *data, u8 oversampling)
 {
 	if (oversampling > 3)
 		oversampling = 3;
 	data->oversampling_setting = oversampling;
 }
 
-/*
- * Returns the currently selected oversampling. Range: 0..3
- */
-static unsigned char bmp085_get_oversampling(struct bmp085_data *data)
-{
-	return data->oversampling_setting;
-}
-
 /* sysfs callbacks */
 static ssize_t set_oversampling(struct device *dev,
 				struct device_attribute *attr,
@@ -307,13 +298,14 @@ static ssize_t set_oversampling(struct device *dev,
 {
 	struct i2c_client *client = to_i2c_client(dev);
 	struct bmp085_data *data = i2c_get_clientdata(client);
-	unsigned long oversampling;
-	int success = strict_strtoul(buf, 10, &oversampling);
-	if (success == 0) {
-		bmp085_set_oversampling(data, oversampling);
-		return count;
-	}
-	return success;
+	u8 oversampling;
+	int rv;
+
+	rv = kstrtou8(buf, 10, &oversampling);
+	if (rv < 0)
+		return rv;
+	bmp085_set_oversampling(data, oversampling);
+	return count;
 }
 
 static ssize_t show_oversampling(struct device *dev,
@@ -321,7 +313,8 @@ static ssize_t show_oversampling(struct device *dev,
 {
 	struct i2c_client *client = to_i2c_client(dev);
 	struct bmp085_data *data = i2c_get_clientdata(client);
-	return sprintf(buf, "%u\n", bmp085_get_oversampling(data));
+
+	return sprintf(buf, "%hhu\n", data->oversampling_setting);
 }
 static DEVICE_ATTR(oversampling, S_IWUSR | S_IRUGO,
 					show_oversampling, set_oversampling);
diff --git a/drivers/misc/ep93xx_pwm.c b/drivers/misc/ep93xx_pwm.c
index 46b3439..b7a653e 100644
--- a/drivers/misc/ep93xx_pwm.c
+++ b/drivers/misc/ep93xx_pwm.c
@@ -149,9 +149,9 @@ static ssize_t ep93xx_pwm_set_freq(struct device *dev,
 	long val;
 	int err;
 
-	err = strict_strtol(buf, 10, &val);
+	err = kstrtol(buf, 10, &val);
 	if (err)
-		return -EINVAL;
+		return err;
 
 	if (val == 0) {
 		ep93xx_pwm_disable(pwm);
@@ -191,7 +191,7 @@ static ssize_t ep93xx_pwm_get_duty_percent(struct device *dev,
 	struct platform_device *pdev = to_platform_device(dev);
 	struct ep93xx_pwm *pwm = platform_get_drvdata(pdev);
 
-	return sprintf(buf, "%d\n", pwm->duty_percent);
+	return sprintf(buf, "%u\n", pwm->duty_percent);
 }
 
 static ssize_t ep93xx_pwm_set_duty_percent(struct device *dev,
@@ -199,21 +199,20 @@ static ssize_t ep93xx_pwm_set_duty_percent(struct device *dev,
 {
 	struct platform_device *pdev = to_platform_device(dev);
 	struct ep93xx_pwm *pwm = platform_get_drvdata(pdev);
-	long val;
+	u32 term;
+	unsigned int val;
 	int err;
 
-	err = strict_strtol(buf, 10, &val);
-	if (err)
+	err = kstrtouint(buf, 10, &val);
+	if (err < 0)
+		return err;
+	if (val >= 100)
 		return -EINVAL;
 
-	if (val > 0 && val < 100) {
-		u32 term = ep93xx_pwm_read_tc(pwm);
-		ep93xx_pwm_write_dc(pwm, ((term + 1) * val / 100) - 1);
-		pwm->duty_percent = val;
-		return count;
-	}
-
-	return -EINVAL;
+	term = ep93xx_pwm_read_tc(pwm);
+	ep93xx_pwm_write_dc(pwm, ((term + 1) * val / 100) - 1);
+	pwm->duty_percent = val;
+	return count;
 }
 
 static ssize_t ep93xx_pwm_get_invert(struct device *dev,
@@ -230,12 +229,12 @@ static ssize_t ep93xx_pwm_set_invert(struct device *dev,
 {
 	struct platform_device *pdev = to_platform_device(dev);
 	struct ep93xx_pwm *pwm = platform_get_drvdata(pdev);
-	long val;
+	int val;
 	int err;
 
-	err = strict_strtol(buf, 10, &val);
+	err = kstrtoint(buf, 10, &val);
 	if (err)
-		return -EINVAL;
+		return err;
 
 	if (val == 0)
 		ep93xx_pwm_normal(pwm);
diff --git a/drivers/misc/hmc6352.c b/drivers/misc/hmc6352.c
index 234bfca..8503368 100644
--- a/drivers/misc/hmc6352.c
+++ b/drivers/misc/hmc6352.c
@@ -43,11 +43,12 @@ static int compass_store(struct device *dev, const char *buf, size_t count,
 			const char *map)
 {
 	struct i2c_client *c = to_i2c_client(dev);
+	unsigned int val;
 	int ret;
-	unsigned long val;
 
-	if (strict_strtoul(buf, 10, &val))
-		return -EINVAL;
+	ret = kstrtouint(buf, 10, &val);
+	if (ret < 0)
+		return ret;
 	if (val >= strlen(map))
 		return -EINVAL;
 	mutex_lock(&compass_mutex);
diff --git a/drivers/misc/isl29003.c b/drivers/misc/isl29003.c
index a71e245..f66cda4 100644
--- a/drivers/misc/isl29003.c
+++ b/drivers/misc/isl29003.c
@@ -205,10 +205,13 @@ static ssize_t isl29003_store_range(struct device *dev,
 				    const char *buf, size_t count)
 {
 	struct i2c_client *client = to_i2c_client(dev);
-	unsigned long val;
+	unsigned int val;
 	int ret;
 
-	if ((strict_strtoul(buf, 10, &val) < 0) || (val > 3))
+	ret = kstrtouint(buf, 10, &val);
+	if (ret < 0)
+		return ret;
+	if (val > 3)
 		return -EINVAL;
 
 	ret = isl29003_set_range(client, val);
@@ -236,10 +239,13 @@ static ssize_t isl29003_store_resolution(struct device *dev,
 					 const char *buf, size_t count)
 {
 	struct i2c_client *client = to_i2c_client(dev);
-	unsigned long val;
+	unsigned int val;
 	int ret;
 
-	if ((strict_strtoul(buf, 10, &val) < 0) || (val > 3))
+	ret = kstrtouint(buf, 10, &val);
+	if (ret < 0)
+		return ret;
+	if (val > 3)
 		return -EINVAL;
 
 	ret = isl29003_set_resolution(client, val);
@@ -264,10 +270,13 @@ static ssize_t isl29003_store_mode(struct device *dev,
 		struct device_attribute *attr, const char *buf, size_t count)
 {
 	struct i2c_client *client = to_i2c_client(dev);
-	unsigned long val;
+	unsigned int val;
 	int ret;
 
-	if ((strict_strtoul(buf, 10, &val) < 0) || (val > 2))
+	ret = kstrtouint(buf, 10, &val);
+	if (ret < 0)
+		return ret;
+	if (val > 2)
 		return -EINVAL;
 
 	ret = isl29003_set_mode(client, val);
@@ -295,10 +304,13 @@ static ssize_t isl29003_store_power_state(struct device *dev,
 					  const char *buf, size_t count)
 {
 	struct i2c_client *client = to_i2c_client(dev);
-	unsigned long val;
+	unsigned int val;
 	int ret;
 
-	if ((strict_strtoul(buf, 10, &val) < 0) || (val > 1))
+	ret = kstrtouint(buf, 10, &val);
+	if (ret < 0)
+		return ret;
+	if (val > 1)
 		return -EINVAL;
 
 	ret = isl29003_set_power_state(client, val);
diff --git a/drivers/misc/isl29020.c b/drivers/misc/isl29020.c
index 307aada..4d63b37 100644
--- a/drivers/misc/isl29020.c
+++ b/drivers/misc/isl29020.c
@@ -87,11 +87,12 @@ static ssize_t als_sensing_range_store(struct device *dev,
 		struct device_attribute *attr, const  char *buf, size_t count)
 {
 	struct i2c_client *client = to_i2c_client(dev);
+	unsigned int val;
 	int ret_val;
-	unsigned long val;
 
-	if (strict_strtoul(buf, 10, &val))
-		return -EINVAL;
+	ret_val = kstrtouint(buf, 10, &val);
+	if (ret_val < 0)
+		return ret_val;
 	if (val < 1 || val > 64000)
 		return -EINVAL;
 
diff --git a/drivers/misc/iwmc3200top/log.c b/drivers/misc/iwmc3200top/log.c
index a36a55a..9df9391 100644
--- a/drivers/misc/iwmc3200top/log.c
+++ b/drivers/misc/iwmc3200top/log.c
@@ -169,7 +169,6 @@ int log_get_fw_filter_str(char *buf, int size)
 	return _log_get_filter_str(iwmct_fw_logdefs, FW_LOG_SRC_MAX, buf, size);
 }
 
-#define HEXADECIMAL_RADIX	16
 #define LOG_SRC_FORMAT		7 /* log level is in format of "0xXXXX," */
 
 ssize_t show_iwmct_log_level(struct device *d,
@@ -206,40 +205,34 @@ ssize_t store_iwmct_log_level(struct device *d,
 			const char *buf, size_t count)
 {
 	struct iwmct_priv *priv = dev_get_drvdata(d);
-	char *token, *str_buf = NULL;
-	long val;
-	ssize_t ret = count;
-	u8 src, mask;
+	char *token, *str_buf, *p;
+	int ret;
 
 	if (!count)
-		goto exit;
+		return -EINVAL;
 
-	str_buf = kzalloc(count, GFP_KERNEL);
+	p = str_buf = kstrdup(buf, GFP_KERNEL);
 	if (!str_buf) {
 		LOG_ERROR(priv, DEBUGFS,
 			"failed to allocate %zd bytes\n", count);
-		ret = -ENOMEM;
-		goto exit;
+		return -ENOMEM;
 	}
 
-	memcpy(str_buf, buf, count);
+	while ((token = strsep(&p, ",")) != NULL) {
+		u16 val;
 
-	while ((token = strsep(&str_buf, ",")) != NULL) {
 		while (isspace(*token))
 			++token;
-		if (strict_strtol(token, HEXADECIMAL_RADIX, &val)) {
+		ret = kstrtou16(token, 16, &val);
+		if (ret < 0) {
 			LOG_ERROR(priv, DEBUGFS,
-				  "failed to convert string to long %s\n",
+				  "invalid integer \"%s\"\n",
 				  token);
-			ret = -EINVAL;
 			goto exit;
 		}
-
-		mask  = val & 0xFF;
-		src = (val & 0XFF00) >> 8;
-		iwmct_log_set_filter(src, mask);
+		iwmct_log_set_filter(val >> 8, val & 0xFF);
 	}
-
+	ret = count;
 exit:
 	kfree(str_buf);
 	return ret;
@@ -281,51 +274,50 @@ ssize_t store_iwmct_log_level_fw(struct device *d,
 {
 	struct iwmct_priv *priv = dev_get_drvdata(d);
 	struct top_msg cmd;
-	char *token, *str_buf = NULL;
-	ssize_t ret = count;
+	char *token, *str_buf, *p;
 	u16 cmdlen = 0;
 	int i;
-	long val;
-	u8 src, mask;
+	int ret;
 
 	if (!count)
-		goto exit;
+		return -EINVAL;
 
-	str_buf = kzalloc(count, GFP_KERNEL);
+	p = str_buf = kstrdup(buf, GFP_KERNEL);
 	if (!str_buf) {
 		LOG_ERROR(priv, DEBUGFS,
 			"failed to allocate %zd bytes\n", count);
-		ret = -ENOMEM;
-		goto exit;
+		return -ENOMEM;
 	}
 
-	memcpy(str_buf, buf, count);
-
 	cmd.hdr.type = COMM_TYPE_H2D;
 	cmd.hdr.category = COMM_CATEGORY_DEBUG;
 	cmd.hdr.opcode = CMD_DBG_LOG_LEVEL;
 
-	for (i = 0; ((token = strsep(&str_buf, ",")) != NULL) &&
+	for (i = 0; ((token = strsep(&p, ",")) != NULL) &&
 		     (i < FW_LOG_SRC_MAX); i++) {
+		u16 val;
+		u8 src, mask;
 
 		while (isspace(*token))
 			++token;
 
-		if (strict_strtol(token, HEXADECIMAL_RADIX, &val)) {
+		ret = kstrtou16(token, 16, &val);
+		if (ret < 0) {
 			LOG_ERROR(priv, DEBUGFS,
 				  "failed to convert string to long %s\n",
 				  token);
-			ret = -EINVAL;
-			goto exit;
+			kfree(str_buf);
+			return ret;
 		}
+		src = val >> 8;
+		mask = val & 0xFF;
 
-		mask  = val & 0xFF; /* LSB */
-		src = (val & 0XFF00) >> 8; /* 2nd least significant byte. */
 		iwmct_log_set_fw_filter(src, mask);
 
 		cmd.u.logdefs[i].logsource = src;
 		cmd.u.logdefs[i].sevmask = mask;
 	}
+	kfree(str_buf);
 
 	cmd.hdr.length = cpu_to_le16(i * sizeof(cmd.u.logdefs[0]));
 	cmdlen = (i * sizeof(cmd.u.logdefs[0]) + sizeof(cmd.hdr));
@@ -333,16 +325,12 @@ ssize_t store_iwmct_log_level_fw(struct device *d,
 	ret = iwmct_send_hcmd(priv, (u8 *)&cmd, cmdlen);
 	if (ret) {
 		LOG_ERROR(priv, DEBUGFS,
-			  "Failed to send %d bytes of fwcmd, ret=%zd\n",
+			  "Failed to send %d bytes of fwcmd, ret=%d\n",
 			  cmdlen, ret);
-		goto exit;
-	} else
-		LOG_INFO(priv, DEBUGFS, "fwcmd sent (%d bytes)\n", cmdlen);
-
-	ret = count;
+		return ret;
+	}
+	LOG_INFO(priv, DEBUGFS, "fwcmd sent (%d bytes)\n", cmdlen);
 
-exit:
-	kfree(str_buf);
-	return ret;
+	return count;
 }
 
diff --git a/drivers/misc/sgi-gru/gruprocfs.c b/drivers/misc/sgi-gru/gruprocfs.c
index 7768b87..c29500c 100644
--- a/drivers/misc/sgi-gru/gruprocfs.c
+++ b/drivers/misc/sgi-gru/gruprocfs.c
@@ -161,15 +161,16 @@ static ssize_t options_write(struct file *file, const char __user *userbuf,
 			     size_t count, loff_t *data)
 {
 	char buf[20];
+	int rv;
 
 	if (count >= sizeof(buf))
 		return -EINVAL;
 	if (copy_from_user(buf, userbuf, count))
 		return -EFAULT;
 	buf[count] = '\0';
-	if (strict_strtoul(buf, 0, &gru_options))
-		return -EINVAL;
-
+	rv = kstrtoul(buf, 0, &gru_options);
+	if (rv < 0)
+		return rv;
 	return count;
 }
 
diff --git a/drivers/misc/ti_dac7512.c b/drivers/misc/ti_dac7512.c
index d3f229a..ef9fd33 100644
--- a/drivers/misc/ti_dac7512.c
+++ b/drivers/misc/ti_dac7512.c
@@ -31,11 +31,13 @@ static ssize_t dac7512_store_val(struct device *dev,
 				 const char *buf, size_t count)
 {
 	struct spi_device *spi = to_spi_device(dev);
-	unsigned char tmp[2];
-	unsigned long val;
+	u8 tmp[2];
+	u16 val;
+	int rv;
 
-	if (strict_strtoul(buf, 10, &val) < 0)
-		return -EINVAL;
+	rv = kstrtou16(buf, 10, &val);
+	if (rv < 0)
+		return rv;
 
 	tmp[0] = val >> 8;
 	tmp[1] = val & 0xff;
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 30/52] kstrtox: convert drivers/mmc/
  2011-02-05 14:20 [PATCH 01/52] kstrtox: converting strings to integers done (hopefully) right Alexey Dobriyan
                   ` (27 preceding siblings ...)
  2011-02-05 14:20 ` [PATCH 29/52] kstrtox: convert drivers/misc/ Alexey Dobriyan
@ 2011-02-05 14:20 ` Alexey Dobriyan
  2011-02-05 14:20 ` [PATCH 31/52] kstrtox: convert drivers/net/ Alexey Dobriyan
                   ` (21 subsequent siblings)
  50 siblings, 0 replies; 58+ messages in thread
From: Alexey Dobriyan @ 2011-02-05 14:20 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, adobriyan


Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
 drivers/mmc/card/mmc_test.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/card/mmc_test.c b/drivers/mmc/card/mmc_test.c
index 21adc27..108b72c 100644
--- a/drivers/mmc/card/mmc_test.c
+++ b/drivers/mmc/card/mmc_test.c
@@ -2173,7 +2173,7 @@ static ssize_t mtf_test_write(struct file *file, const char __user *buf,
 	struct mmc_card *card = (struct mmc_card *)sf->private;
 	struct mmc_test_card *test;
 	char lbuf[12];
-	long testcase;
+	int testcase;
 
 	if (count >= sizeof(lbuf))
 		return -EINVAL;
@@ -2182,7 +2182,7 @@ static ssize_t mtf_test_write(struct file *file, const char __user *buf,
 		return -EFAULT;
 	lbuf[count] = '\0';
 
-	if (strict_strtol(lbuf, 10, &testcase))
+	if (kstrtoint(lbuf, 10, &testcase))
 		return -EINVAL;
 
 	test = kzalloc(sizeof(struct mmc_test_card), GFP_KERNEL);
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 31/52] kstrtox: convert drivers/net/
  2011-02-05 14:20 [PATCH 01/52] kstrtox: converting strings to integers done (hopefully) right Alexey Dobriyan
                   ` (28 preceding siblings ...)
  2011-02-05 14:20 ` [PATCH 30/52] kstrtox: convert drivers/mmc/ Alexey Dobriyan
@ 2011-02-05 14:20 ` Alexey Dobriyan
  2011-02-05 14:20 ` [PATCH 32/52] kstrtox: convert drivers/net/wireless/ Alexey Dobriyan
                   ` (20 subsequent siblings)
  50 siblings, 0 replies; 58+ messages in thread
From: Alexey Dobriyan @ 2011-02-05 14:20 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, adobriyan


Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
 drivers/net/can/at91_can.c             |    9 +++------
 drivers/net/can/janz-ican3.c           |    5 +++--
 drivers/net/can/slcan.c                |    5 +----
 drivers/net/can/softing/softing_main.c |    2 +-
 drivers/net/netxen/netxen_nic_main.c   |    4 ++--
 drivers/net/qlcnic/qlcnic_main.c       |    4 ++--
 drivers/net/stmmac/stmmac_main.c       |   29 ++++++++++++++++-------------
 7 files changed, 28 insertions(+), 30 deletions(-)

diff --git a/drivers/net/can/at91_can.c b/drivers/net/can/at91_can.c
index 57d2ffb..5c71310 100644
--- a/drivers/net/can/at91_can.c
+++ b/drivers/net/can/at91_can.c
@@ -1079,9 +1079,8 @@ static ssize_t at91_sysfs_set_mb0_id(struct device *dev,
 {
 	struct net_device *ndev = to_net_dev(dev);
 	struct at91_priv *priv = netdev_priv(ndev);
-	unsigned long can_id;
+	u32 can_id;
 	ssize_t ret;
-	int err;
 
 	rtnl_lock();
 
@@ -1090,11 +1089,9 @@ static ssize_t at91_sysfs_set_mb0_id(struct device *dev,
 		goto out;
 	}
 
-	err = strict_strtoul(buf, 0, &can_id);
-	if (err) {
-		ret = err;
+	ret = kstrtou32(buf, 0, &can_id);
+	if (ret < 0)
 		goto out;
-	}
 
 	if (can_id & CAN_EFF_FLAG)
 		can_id &= CAN_EFF_MASK | CAN_EFF_FLAG;
diff --git a/drivers/net/can/janz-ican3.c b/drivers/net/can/janz-ican3.c
index 366f5cc..eb70a1c 100644
--- a/drivers/net/can/janz-ican3.c
+++ b/drivers/net/can/janz-ican3.c
@@ -1608,8 +1608,9 @@ static ssize_t ican3_sysfs_set_term(struct device *dev,
 	unsigned long enable;
 	int ret;
 
-	if (strict_strtoul(buf, 0, &enable))
-		return -EINVAL;
+	ret = kstrtoul(buf, 0, &enable);
+	if (ret < 0)
+		return ret;
 
 	ret = ican3_set_termination(mod, enable);
 	if (ret)
diff --git a/drivers/net/can/slcan.c b/drivers/net/can/slcan.c
index b423965..624059d 100644
--- a/drivers/net/can/slcan.c
+++ b/drivers/net/can/slcan.c
@@ -163,7 +163,6 @@ static void slc_bump(struct slcan *sl)
 	struct sk_buff *skb;
 	struct can_frame cf;
 	int i, dlc_pos, tmp;
-	unsigned long ultmp;
 	char cmd = sl->rbuff[0];
 
 	if ((cmd != 't') && (cmd != 'T') && (cmd != 'r') && (cmd != 'R'))
@@ -181,11 +180,9 @@ static void slc_bump(struct slcan *sl)
 
 	sl->rbuff[dlc_pos] = 0; /* terminate can_id string */
 
-	if (strict_strtoul(sl->rbuff+1, 16, &ultmp))
+	if (kstrtou32(sl->rbuff+1, 16, &cf.can_id))
 		return;
 
-	cf.can_id = ultmp;
-
 	if (!(cmd & 0x20)) /* NO tiny chars => extended frame format */
 		cf.can_id |= CAN_EFF_FLAG;
 
diff --git a/drivers/net/can/softing/softing_main.c b/drivers/net/can/softing/softing_main.c
index 5157e15..ef6ff7a 100644
--- a/drivers/net/can/softing/softing_main.c
+++ b/drivers/net/can/softing/softing_main.c
@@ -594,7 +594,7 @@ static ssize_t store_output(struct device *dev, struct device_attribute *attr,
 	unsigned long val;
 	int ret;
 
-	ret = strict_strtoul(buf, 0, &val);
+	ret = kstrtoul(buf, 0, &val);
 	if (ret < 0)
 		return ret;
 	val &= 0xFF;
diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c
index 33fac32..585f701 100644
--- a/drivers/net/netxen/netxen_nic_main.c
+++ b/drivers/net/netxen/netxen_nic_main.c
@@ -2503,7 +2503,7 @@ netxen_store_bridged_mode(struct device *dev,
 	if (adapter->is_up != NETXEN_ADAPTER_UP_MAGIC)
 		goto err_out;
 
-	if (strict_strtoul(buf, 2, &new))
+	if (kstrtoul(buf, 2, &new))
 		goto err_out;
 
 	if (!netxen_config_bridged_mode(adapter, !!new))
@@ -2542,7 +2542,7 @@ netxen_store_diag_mode(struct device *dev,
 	struct netxen_adapter *adapter = dev_get_drvdata(dev);
 	unsigned long new;
 
-	if (strict_strtoul(buf, 2, &new))
+	if (kstrtoul(buf, 2, &new))
 		return -EINVAL;
 
 	if (!!new != !!(adapter->flags & NETXEN_NIC_DIAG_ENABLED))
diff --git a/drivers/net/qlcnic/qlcnic_main.c b/drivers/net/qlcnic/qlcnic_main.c
index 37c04b4..f511c33 100644
--- a/drivers/net/qlcnic/qlcnic_main.c
+++ b/drivers/net/qlcnic/qlcnic_main.c
@@ -3192,7 +3192,7 @@ qlcnic_store_bridged_mode(struct device *dev,
 	if (!test_bit(__QLCNIC_DEV_UP, &adapter->state))
 		goto err_out;
 
-	if (strict_strtoul(buf, 2, &new))
+	if (kstrtoul(buf, 2, &new))
 		goto err_out;
 
 	if (!adapter->nic_ops->config_bridged_mode(adapter, !!new))
@@ -3228,7 +3228,7 @@ qlcnic_store_diag_mode(struct device *dev,
 	struct qlcnic_adapter *adapter = dev_get_drvdata(dev);
 	unsigned long new;
 
-	if (strict_strtoul(buf, 2, &new))
+	if (kstrtoul(buf, 2, &new))
 		return -EINVAL;
 
 	if (!!new != !!(adapter->flags & QLCNIC_DIAG_ENABLED))
diff --git a/drivers/net/stmmac/stmmac_main.c b/drivers/net/stmmac/stmmac_main.c
index 34a0af3..cb449f7 100644
--- a/drivers/net/stmmac/stmmac_main.c
+++ b/drivers/net/stmmac/stmmac_main.c
@@ -1955,31 +1955,34 @@ static int __init stmmac_cmdline_opt(char *str)
 	if (!str || !*str)
 		return -EINVAL;
 	while ((opt = strsep(&str, ",")) != NULL) {
+		int rv;
+
 		if (!strncmp(opt, "debug:", 6))
-			strict_strtoul(opt + 6, 0, (unsigned long *)&debug);
+			rv = kstrtoint(opt + 6, 0, &debug);
 		else if (!strncmp(opt, "phyaddr:", 8))
-			strict_strtoul(opt + 8, 0, (unsigned long *)&phyaddr);
+			rv = kstrtoint(opt + 8, 0, &phyaddr);
 		else if (!strncmp(opt, "dma_txsize:", 11))
-			strict_strtoul(opt + 11, 0,
-				       (unsigned long *)&dma_txsize);
+			rv = kstrtoint(opt + 11, 0, &dma_txsize);
 		else if (!strncmp(opt, "dma_rxsize:", 11))
-			strict_strtoul(opt + 11, 0,
-				       (unsigned long *)&dma_rxsize);
+			rv = kstrtoint(opt + 11, 0, &dma_rxsize);
 		else if (!strncmp(opt, "buf_sz:", 7))
-			strict_strtoul(opt + 7, 0, (unsigned long *)&buf_sz);
+			rv = kstrtoint(opt + 7, 0, &buf_sz);
 		else if (!strncmp(opt, "tc:", 3))
-			strict_strtoul(opt + 3, 0, (unsigned long *)&tc);
+			rv = kstrtoint(opt + 3, 0, &tc);
 		else if (!strncmp(opt, "watchdog:", 9))
-			strict_strtoul(opt + 9, 0, (unsigned long *)&watchdog);
+			rv = kstrtoint(opt + 9, 0, &watchdog);
 		else if (!strncmp(opt, "flow_ctrl:", 10))
-			strict_strtoul(opt + 10, 0,
-				       (unsigned long *)&flow_ctrl);
+			rv = kstrtoint(opt + 10, 0, &flow_ctrl);
 		else if (!strncmp(opt, "pause:", 6))
-			strict_strtoul(opt + 6, 0, (unsigned long *)&pause);
+			rv = kstrtoint(opt + 6, 0, &pause);
 #ifdef CONFIG_STMMAC_TIMER
 		else if (!strncmp(opt, "tmrate:", 7))
-			strict_strtoul(opt + 7, 0, (unsigned long *)&tmrate);
+			rv = kstrtoint(opt + 7, 0, &tmrate);
 #endif
+		else
+			rv = -EINVAL;
+		if (rv < 0)
+			return rv;
 	}
 	return 0;
 }
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 32/52] kstrtox: convert drivers/net/wireless/
  2011-02-05 14:20 [PATCH 01/52] kstrtox: converting strings to integers done (hopefully) right Alexey Dobriyan
                   ` (29 preceding siblings ...)
  2011-02-05 14:20 ` [PATCH 31/52] kstrtox: convert drivers/net/ Alexey Dobriyan
@ 2011-02-05 14:20 ` Alexey Dobriyan
  2011-02-05 14:20 ` [PATCH 33/52] kstrtox: convert drivers/pci/ Alexey Dobriyan
                   ` (19 subsequent siblings)
  50 siblings, 0 replies; 58+ messages in thread
From: Alexey Dobriyan @ 2011-02-05 14:20 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, adobriyan


Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
 drivers/net/wireless/ath/ath9k/debug.c      |   22 ++++++----------
 drivers/net/wireless/iwlwifi/iwl-agn.c      |   36 ++++++++++++---------------
 drivers/net/wireless/iwlwifi/iwl3945-base.c |   15 ++++------
 drivers/net/wireless/libertas/mesh.c        |    7 +++--
 drivers/net/wireless/rtlwifi/base.c         |   15 +++-------
 drivers/net/wireless/wl12xx/debugfs.c       |   15 +++-------
 drivers/net/wireless/wl12xx/main.c          |    6 +---
 7 files changed, 46 insertions(+), 70 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/debug.c b/drivers/net/wireless/ath/ath9k/debug.c
index 3586c43..f061561 100644
--- a/drivers/net/wireless/ath/ath9k/debug.c
+++ b/drivers/net/wireless/ath/ath9k/debug.c
@@ -49,7 +49,6 @@ static ssize_t write_file_debug(struct file *file, const char __user *user_buf,
 {
 	struct ath_softc *sc = file->private_data;
 	struct ath_common *common = ath9k_hw_common(sc->sc_ah);
-	unsigned long mask;
 	char buf[32];
 	ssize_t len;
 
@@ -58,10 +57,8 @@ static ssize_t write_file_debug(struct file *file, const char __user *user_buf,
 		return -EFAULT;
 
 	buf[len] = '\0';
-	if (strict_strtoul(buf, 0, &mask))
+	if (kstrtoint(buf, 0, &common->debug_mask))
 		return -EINVAL;
-
-	common->debug_mask = mask;
 	return count;
 }
 
@@ -94,7 +91,7 @@ static ssize_t write_file_tx_chainmask(struct file *file, const char __user *use
 {
 	struct ath_softc *sc = file->private_data;
 	struct ath_common *common = ath9k_hw_common(sc->sc_ah);
-	unsigned long mask;
+	u8 mask;
 	char buf[32];
 	ssize_t len;
 
@@ -103,7 +100,7 @@ static ssize_t write_file_tx_chainmask(struct file *file, const char __user *use
 		return -EFAULT;
 
 	buf[len] = '\0';
-	if (strict_strtoul(buf, 0, &mask))
+	if (kstrtou8(buf, 0, &mask))
 		return -EINVAL;
 
 	common->tx_chainmask = mask;
@@ -137,7 +134,7 @@ static ssize_t write_file_rx_chainmask(struct file *file, const char __user *use
 {
 	struct ath_softc *sc = file->private_data;
 	struct ath_common *common = ath9k_hw_common(sc->sc_ah);
-	unsigned long mask;
+	u8 mask;
 	char buf[32];
 	ssize_t len;
 
@@ -146,7 +143,7 @@ static ssize_t write_file_rx_chainmask(struct file *file, const char __user *use
 		return -EFAULT;
 
 	buf[len] = '\0';
-	if (strict_strtoul(buf, 0, &mask))
+	if (kstrtou8(buf, 0, &mask))
 		return -EINVAL;
 
 	common->rx_chainmask = mask;
@@ -804,7 +801,6 @@ static ssize_t write_file_regidx(struct file *file, const char __user *user_buf,
 			     size_t count, loff_t *ppos)
 {
 	struct ath_softc *sc = file->private_data;
-	unsigned long regidx;
 	char buf[32];
 	ssize_t len;
 
@@ -813,10 +809,8 @@ static ssize_t write_file_regidx(struct file *file, const char __user *user_buf,
 		return -EFAULT;
 
 	buf[len] = '\0';
-	if (strict_strtoul(buf, 0, &regidx))
+	if (kstrtou32(buf, 0, &sc->debug.regidx))
 		return -EINVAL;
-
-	sc->debug.regidx = regidx;
 	return count;
 }
 
@@ -847,7 +841,7 @@ static ssize_t write_file_regval(struct file *file, const char __user *user_buf,
 {
 	struct ath_softc *sc = file->private_data;
 	struct ath_hw *ah = sc->sc_ah;
-	unsigned long regval;
+	u32 regval;
 	char buf[32];
 	ssize_t len;
 
@@ -856,7 +850,7 @@ static ssize_t write_file_regval(struct file *file, const char __user *user_buf,
 		return -EFAULT;
 
 	buf[len] = '\0';
-	if (strict_strtoul(buf, 0, &regval))
+	if (kstrtou32(buf, 0, &regval))
 		return -EINVAL;
 
 	REG_WRITE_D(ah, sc->debug.regidx, regval);
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c
index 36335b1..1d80cb8 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.c
@@ -1463,19 +1463,16 @@ static ssize_t store_debug_level(struct device *d,
 				 const char *buf, size_t count)
 {
 	struct iwl_priv *priv = dev_get_drvdata(d);
-	unsigned long val;
 	int ret;
 
-	ret = strict_strtoul(buf, 0, &val);
-	if (ret)
+	ret = kstrtou32(buf, 0, &priv->debug_level);
+	if (ret) {
 		IWL_ERR(priv, "%s is not in hex or decimal form.\n", buf);
-	else {
-		priv->debug_level = val;
-		if (iwl_alloc_traffic_mem(priv))
-			IWL_ERR(priv,
-				"Not enough memory to generate traffic log\n");
+		return ret;
 	}
-	return strnlen(buf, count);
+	if (iwl_alloc_traffic_mem(priv))
+		IWL_ERR(priv, "Not enough memory to generate traffic log\n");
+	return count;
 }
 
 static DEVICE_ATTR(debug_level, S_IWUSR | S_IRUGO,
@@ -1514,21 +1511,20 @@ static ssize_t store_tx_power(struct device *d,
 			      const char *buf, size_t count)
 {
 	struct iwl_priv *priv = dev_get_drvdata(d);
-	unsigned long val;
+	u8 val;
 	int ret;
 
-	ret = strict_strtoul(buf, 10, &val);
-	if (ret)
+	ret = kstrtou8(buf, 10, &val);
+	if (ret) {
 		IWL_INFO(priv, "%s is not in decimal form.\n", buf);
-	else {
-		ret = iwl_set_tx_power(priv, val, false);
-		if (ret)
-			IWL_ERR(priv, "failed setting tx power (0x%d).\n",
-				ret);
-		else
-			ret = count;
+		return ret;
 	}
-	return ret;
+	ret = iwl_set_tx_power(priv, val, false);
+	if (ret) {
+		IWL_ERR(priv, "failed setting tx power (0x%d).\n", ret);
+		return ret;
+	}
+	return count;
 }
 
 static DEVICE_ATTR(tx_power, S_IWUSR | S_IRUGO, show_tx_power, store_tx_power);
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c
index 371abbf..85a58e6 100644
--- a/drivers/net/wireless/iwlwifi/iwl3945-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c
@@ -3444,19 +3444,16 @@ static ssize_t store_debug_level(struct device *d,
 				 const char *buf, size_t count)
 {
 	struct iwl_priv *priv = dev_get_drvdata(d);
-	unsigned long val;
 	int ret;
 
-	ret = strict_strtoul(buf, 0, &val);
-	if (ret)
+	ret = kstrtou32(buf, 0, &priv->debug_level);
+	if (ret) {
 		IWL_INFO(priv, "%s is not in hex or decimal form.\n", buf);
-	else {
-		priv->debug_level = val;
-		if (iwl_alloc_traffic_mem(priv))
-			IWL_ERR(priv,
-				"Not enough memory to generate traffic log\n");
+		return ret;
 	}
-	return strnlen(buf, count);
+	if (iwl_alloc_traffic_mem(priv))
+		IWL_ERR(priv, "Not enough memory to generate traffic log\n");
+	return count;
 }
 
 static DEVICE_ATTR(debug_level, S_IWUSR | S_IRUGO,
diff --git a/drivers/net/wireless/libertas/mesh.c b/drivers/net/wireless/libertas/mesh.c
index acf3bf6..0b61551 100644
--- a/drivers/net/wireless/libertas/mesh.c
+++ b/drivers/net/wireless/libertas/mesh.c
@@ -92,14 +92,15 @@ static ssize_t lbs_prb_rsp_limit_set(struct device *dev,
 {
 	struct lbs_private *priv = to_net_dev(dev)->ml_priv;
 	struct cmd_ds_mesh_access mesh_access;
+	u32 retry_limit;
 	int ret;
-	unsigned long retry_limit;
 
 	memset(&mesh_access, 0, sizeof(mesh_access));
 	mesh_access.data[0] = cpu_to_le32(CMD_ACT_SET);
 
-	if (!strict_strtoul(buf, 10, &retry_limit))
-		return -ENOTSUPP;
+	ret = kstrtou32(buf, 10, &retry_limit);
+	if (ret < 0)
+		return ret;
 	if (retry_limit > 15)
 		return -ENOTSUPP;
 
diff --git a/drivers/net/wireless/rtlwifi/base.c b/drivers/net/wireless/rtlwifi/base.c
index cf0b73e..5ddbd34 100644
--- a/drivers/net/wireless/rtlwifi/base.c
+++ b/drivers/net/wireless/rtlwifi/base.c
@@ -901,19 +901,14 @@ static ssize_t rtl_store_debug_level(struct device *d,
 {
 	struct ieee80211_hw *hw = dev_get_drvdata(d);
 	struct rtl_priv *rtlpriv = rtl_priv(hw);
-	unsigned long val;
 	int ret;
 
-	ret = strict_strtoul(buf, 0, &val);
-	if (ret) {
-		printk(KERN_DEBUG "%s is not in hex or decimal form.\n", buf);
-	} else {
-		rtlpriv->dbg.global_debuglevel = val;
-		printk(KERN_DEBUG "debuglevel:%x\n",
+	ret = kstrtou32(buf, 0, &rtlpriv->dbg.global_debuglevel);
+	if (ret < 0)
+		return ret;
+	printk(KERN_DEBUG "debuglevel:%x\n",
 		       rtlpriv->dbg.global_debuglevel);
-	}
-
-	return strnlen(buf, count);
+	return count;
 }
 
 static DEVICE_ATTR(debug_level, S_IWUSR | S_IRUGO,
diff --git a/drivers/net/wireless/wl12xx/debugfs.c b/drivers/net/wireless/wl12xx/debugfs.c
index ec60777..450d2bf 100644
--- a/drivers/net/wireless/wl12xx/debugfs.c
+++ b/drivers/net/wireless/wl12xx/debugfs.c
@@ -261,27 +261,22 @@ static ssize_t gpio_power_write(struct file *file,
 	unsigned long value;
 	int ret;
 
-	mutex_lock(&wl->mutex);
-
 	len = min(count, sizeof(buf) - 1);
-	if (copy_from_user(buf, user_buf, len)) {
-		ret = -EFAULT;
-		goto out;
-	}
+	if (copy_from_user(buf, user_buf, len))
+		return -EFAULT;
 	buf[len] = '\0';
 
-	ret = strict_strtoul(buf, 0, &value);
+	ret = kstrtoul(buf, 0, &value);
 	if (ret < 0) {
 		wl1271_warning("illegal value in gpio_power");
-		goto out;
+		return ret;
 	}
 
+	mutex_lock(&wl->mutex);
 	if (value)
 		wl1271_power_on(wl);
 	else
 		wl1271_power_off(wl);
-
-out:
 	mutex_unlock(&wl->mutex);
 	return count;
 }
diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c
index 062247e..2588871 100644
--- a/drivers/net/wireless/wl12xx/main.c
+++ b/drivers/net/wireless/wl12xx/main.c
@@ -2543,17 +2543,15 @@ static ssize_t wl1271_sysfs_store_bt_coex_state(struct device *dev,
 	unsigned long res;
 	int ret;
 
-	ret = strict_strtoul(buf, 10, &res);
-
+	ret = kstrtoul(buf, 10, &res);
 	if (ret < 0) {
 		wl1271_warning("incorrect value written to bt_coex_mode");
 		return count;
 	}
+	res = !!res;
 
 	mutex_lock(&wl->mutex);
 
-	res = !!res;
-
 	if (res == wl->sg_enabled)
 		goto out;
 
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 33/52] kstrtox: convert drivers/pci/
  2011-02-05 14:20 [PATCH 01/52] kstrtox: converting strings to integers done (hopefully) right Alexey Dobriyan
                   ` (30 preceding siblings ...)
  2011-02-05 14:20 ` [PATCH 32/52] kstrtox: convert drivers/net/wireless/ Alexey Dobriyan
@ 2011-02-05 14:20 ` Alexey Dobriyan
  2011-02-05 14:20 ` [PATCH 34/52] kstrtox: convert drivers/power/ Alexey Dobriyan
                   ` (18 subsequent siblings)
  50 siblings, 0 replies; 58+ messages in thread
From: Alexey Dobriyan @ 2011-02-05 14:20 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, adobriyan


Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
 drivers/pci/hotplug/fakephp.c |    2 +-
 drivers/pci/pci-sysfs.c       |   45 ++++++++++++++++++++++------------------
 2 files changed, 26 insertions(+), 21 deletions(-)

diff --git a/drivers/pci/hotplug/fakephp.c b/drivers/pci/hotplug/fakephp.c
index 17d10e2..aaf2529 100644
--- a/drivers/pci/hotplug/fakephp.c
+++ b/drivers/pci/hotplug/fakephp.c
@@ -49,7 +49,7 @@ static ssize_t legacy_store(struct kobject *kobj, struct attribute *attr,
 	struct legacy_slot *slot = container_of(kobj, typeof(*slot), kobj);
 	unsigned long val;
 
-	if (strict_strtoul(buf, 0, &val) < 0)
+	if (kstrtoul(buf, 0, &val) < 0)
 		return -EINVAL;
 
 	if (val)
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index 8ecaac9..00d48b9 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -61,9 +61,11 @@ static ssize_t broken_parity_status_store(struct device *dev,
 {
 	struct pci_dev *pdev = to_pci_dev(dev);
 	unsigned long val;
+	int rv;
 
-	if (strict_strtoul(buf, 0, &val) < 0)
-		return -EINVAL;
+	rv = kstrtoul(buf, 0, &val);
+	if (rv < 0)
+		return rv;
 
 	pdev->broken_parity_status = !!val;
 
@@ -150,15 +152,16 @@ static ssize_t is_enabled_store(struct device *dev,
 {
 	struct pci_dev *pdev = to_pci_dev(dev);
 	unsigned long val;
-	ssize_t result = strict_strtoul(buf, 0, &val);
-
-	if (result < 0)
-		return result;
+	int result;
 
 	/* this can crash the machine when done on the "wrong" device */
 	if (!capable(CAP_SYS_ADMIN))
 		return -EPERM;
 
+	result = kstrtoul(buf, 0, &val);
+	if (result < 0)
+		return result;
+
 	if (!val) {
 		if (pci_is_enabled(pdev))
 			pci_disable_device(pdev);
@@ -221,14 +224,14 @@ msi_bus_store(struct device *dev, struct device_attribute *attr,
 	struct pci_dev *pdev = to_pci_dev(dev);
 	unsigned long val;
 
-	if (strict_strtoul(buf, 0, &val) < 0)
-		return -EINVAL;
-
 	/* bad things may happen if the no_msi flag is changed
 	 * while some drivers are loaded */
 	if (!capable(CAP_SYS_ADMIN))
 		return -EPERM;
 
+	if (kstrtoul(buf, 0, &val) < 0)
+		return -EINVAL;
+
 	/* Maybe pci devices without subordinate busses shouldn't even have this
 	 * attribute in the first place?  */
 	if (!pdev->subordinate)
@@ -254,7 +257,7 @@ static ssize_t bus_rescan_store(struct bus_type *bus, const char *buf,
 	unsigned long val;
 	struct pci_bus *b = NULL;
 
-	if (strict_strtoul(buf, 0, &val) < 0)
+	if (kstrtoul(buf, 0, &val) < 0)
 		return -EINVAL;
 
 	if (val) {
@@ -278,7 +281,7 @@ dev_rescan_store(struct device *dev, struct device_attribute *attr,
 	unsigned long val;
 	struct pci_dev *pdev = to_pci_dev(dev);
 
-	if (strict_strtoul(buf, 0, &val) < 0)
+	if (kstrtoul(buf, 0, &val) < 0)
 		return -EINVAL;
 
 	if (val) {
@@ -302,19 +305,21 @@ static ssize_t
 remove_store(struct device *dev, struct device_attribute *dummy,
 	     const char *buf, size_t count)
 {
-	int ret = 0;
 	unsigned long val;
+	int ret;
 
-	if (strict_strtoul(buf, 0, &val) < 0)
-		return -EINVAL;
+	ret = kstrtoul(buf, 0, &val);
+	if (ret < 0)
+		return ret;
 
 	/* An attribute cannot be unregistered by one of its own methods,
 	 * so we have to use this roundabout approach.
 	 */
-	if (val)
+	if (val) {
 		ret = device_schedule_callback(dev, remove_callback);
-	if (ret)
-		count = ret;
+		if (ret < 0)
+			return ret;
+	}
 	return count;
 }
 #endif
@@ -1050,12 +1055,12 @@ static ssize_t reset_store(struct device *dev,
 			   size_t count)
 {
 	struct pci_dev *pdev = to_pci_dev(dev);
-	unsigned long val;
-	ssize_t result = strict_strtoul(buf, 0, &val);
+	int val;
+	int result;
 
+	result = kstrtoint(buf, 0, &val);
 	if (result < 0)
 		return result;
-
 	if (val != 1)
 		return -EINVAL;
 
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 34/52] kstrtox: convert drivers/power/
  2011-02-05 14:20 [PATCH 01/52] kstrtox: converting strings to integers done (hopefully) right Alexey Dobriyan
                   ` (31 preceding siblings ...)
  2011-02-05 14:20 ` [PATCH 33/52] kstrtox: convert drivers/pci/ Alexey Dobriyan
@ 2011-02-05 14:20 ` Alexey Dobriyan
  2011-02-05 14:20 ` [PATCH 35/52] kstrtox: convert drivers/regulator/ Alexey Dobriyan
                   ` (17 subsequent siblings)
  50 siblings, 0 replies; 58+ messages in thread
From: Alexey Dobriyan @ 2011-02-05 14:20 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, adobriyan


Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
 drivers/power/pcf50633-charger.c   |    4 ++--
 drivers/power/power_supply_sysfs.c |    6 +-----
 2 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/power/pcf50633-charger.c b/drivers/power/pcf50633-charger.c
index 4fa52e1..b6d9281 100644
--- a/drivers/power/pcf50633-charger.c
+++ b/drivers/power/pcf50633-charger.c
@@ -191,7 +191,7 @@ static ssize_t set_usblim(struct device *dev,
 	unsigned long ma;
 	int ret;
 
-	ret = strict_strtoul(buf, 10, &ma);
+	ret = kstrtoul(buf, 10, &ma);
 	if (ret)
 		return -EINVAL;
 
@@ -228,7 +228,7 @@ static ssize_t set_chglim(struct device *dev,
 	if (!mbc->pcf->pdata->charger_reference_current_ma)
 		return -ENODEV;
 
-	ret = strict_strtoul(buf, 10, &ma);
+	ret = kstrtoul(buf, 10, &ma);
 	if (ret)
 		return -EINVAL;
 
diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c
index cd1f907..15d2d4a 100644
--- a/drivers/power/power_supply_sysfs.c
+++ b/drivers/power/power_supply_sysfs.c
@@ -107,15 +107,11 @@ static ssize_t power_supply_store_property(struct device *dev,
 	struct power_supply *psy = dev_get_drvdata(dev);
 	const ptrdiff_t off = attr - power_supply_attrs;
 	union power_supply_propval value;
-	long long_val;
 
 	/* TODO: support other types than int */
-	ret = strict_strtol(buf, 10, &long_val);
+	ret = kstrtoint(buf, 10, &value.intval);
 	if (ret < 0)
 		return ret;
-
-	value.intval = long_val;
-
 	ret = psy->set_property(psy, off, &value);
 	if (ret < 0)
 		return ret;
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 35/52] kstrtox: convert drivers/regulator/
  2011-02-05 14:20 [PATCH 01/52] kstrtox: converting strings to integers done (hopefully) right Alexey Dobriyan
                   ` (32 preceding siblings ...)
  2011-02-05 14:20 ` [PATCH 34/52] kstrtox: convert drivers/power/ Alexey Dobriyan
@ 2011-02-05 14:20 ` Alexey Dobriyan
  2011-02-05 14:20 ` [PATCH 36/52] kstrtox: convert drivers/rtc/ Alexey Dobriyan
                   ` (16 subsequent siblings)
  50 siblings, 0 replies; 58+ messages in thread
From: Alexey Dobriyan @ 2011-02-05 14:20 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, adobriyan


Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
 drivers/regulator/virtual.c |   32 ++++++++++++++++++++------------
 1 files changed, 20 insertions(+), 12 deletions(-)

diff --git a/drivers/regulator/virtual.c b/drivers/regulator/virtual.c
index 69e550f..6e3eee2 100644
--- a/drivers/regulator/virtual.c
+++ b/drivers/regulator/virtual.c
@@ -118,10 +118,12 @@ static ssize_t set_min_uV(struct device *dev, struct device_attribute *attr,
 			  const char *buf, size_t count)
 {
 	struct virtual_consumer_data *data = dev_get_drvdata(dev);
-	long val;
+	int val;
+	int rv;
 
-	if (strict_strtol(buf, 10, &val) != 0)
-		return count;
+	rv = kstrtoint(buf, 10, &val);
+	if (rv < 0)
+		return rv;
 
 	mutex_lock(&data->lock);
 
@@ -144,10 +146,12 @@ static ssize_t set_max_uV(struct device *dev, struct device_attribute *attr,
 			  const char *buf, size_t count)
 {
 	struct virtual_consumer_data *data = dev_get_drvdata(dev);
-	long val;
+	int val;
+	int rv;
 
-	if (strict_strtol(buf, 10, &val) != 0)
-		return count;
+	rv = kstrtoint(buf, 10, &val);
+	if (rv < 0)
+		return rv;
 
 	mutex_lock(&data->lock);
 
@@ -170,10 +174,12 @@ static ssize_t set_min_uA(struct device *dev, struct device_attribute *attr,
 			  const char *buf, size_t count)
 {
 	struct virtual_consumer_data *data = dev_get_drvdata(dev);
-	long val;
+	int val;
+	int rv;
 
-	if (strict_strtol(buf, 10, &val) != 0)
-		return count;
+	rv = kstrtoint(buf, 10, &val);
+	if (rv < 0)
+		return rv;
 
 	mutex_lock(&data->lock);
 
@@ -196,10 +202,12 @@ static ssize_t set_max_uA(struct device *dev, struct device_attribute *attr,
 			  const char *buf, size_t count)
 {
 	struct virtual_consumer_data *data = dev_get_drvdata(dev);
-	long val;
+	int val;
+	int rv;
 
-	if (strict_strtol(buf, 10, &val) != 0)
-		return count;
+	rv = kstrtoint(buf, 10, &val);
+	if (rv < 0)
+		return rv;
 
 	mutex_lock(&data->lock);
 
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 36/52] kstrtox: convert drivers/rtc/
  2011-02-05 14:20 [PATCH 01/52] kstrtox: converting strings to integers done (hopefully) right Alexey Dobriyan
                   ` (33 preceding siblings ...)
  2011-02-05 14:20 ` [PATCH 35/52] kstrtox: convert drivers/regulator/ Alexey Dobriyan
@ 2011-02-05 14:20 ` Alexey Dobriyan
  2011-02-05 14:20 ` [PATCH 37/52] kstrtox: convert drivers/scsi/ Alexey Dobriyan
                   ` (15 subsequent siblings)
  50 siblings, 0 replies; 58+ messages in thread
From: Alexey Dobriyan @ 2011-02-05 14:20 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, adobriyan


Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
 drivers/rtc/rtc-pcf2123.c |   23 +++++++++++------------
 1 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/drivers/rtc/rtc-pcf2123.c b/drivers/rtc/rtc-pcf2123.c
index 71bab0e..9e08179 100644
--- a/drivers/rtc/rtc-pcf2123.c
+++ b/drivers/rtc/rtc-pcf2123.c
@@ -87,13 +87,14 @@ static ssize_t pcf2123_show(struct device *dev, struct device_attribute *attr,
 	struct spi_device *spi = to_spi_device(dev);
 	struct pcf2123_sysfs_reg *r;
 	u8 txbuf[1], rxbuf[1];
-	unsigned long reg;
+	u8 reg;
 	int ret;
 
 	r = container_of(attr, struct pcf2123_sysfs_reg, attr);
 
-	if (strict_strtoul(r->name, 16, &reg))
-		return -EINVAL;
+	ret = kstrtou8(r->name, 16, &reg);
+	if (ret < 0)
+		return ret;
 
 	txbuf[0] = PCF2123_READ | reg;
 	ret = spi_write_then_read(spi, txbuf, 1, rxbuf, 1);
@@ -108,19 +109,17 @@ static ssize_t pcf2123_store(struct device *dev, struct device_attribute *attr,
 	struct spi_device *spi = to_spi_device(dev);
 	struct pcf2123_sysfs_reg *r;
 	u8 txbuf[2];
-	unsigned long reg;
-	unsigned long val;
-
 	int ret;
 
 	r = container_of(attr, struct pcf2123_sysfs_reg, attr);
 
-	if (strict_strtoul(r->name, 16, &reg)
-		|| strict_strtoul(buffer, 10, &val))
-		return -EINVAL;
-
-	txbuf[0] = PCF2123_WRITE | reg;
-	txbuf[1] = val;
+	ret = kstrtou8(r->name, 16, &txbuf[0]);
+	if (ret < 0)
+		return ret;
+	txbuf[0] |= PCF2123_WRITE;
+	ret = kstrtou8(buffer, 10, &txbuf[1]);
+	if (ret < 0)
+		return ret;
 	ret = spi_write(spi, txbuf, sizeof(txbuf));
 	if (ret < 0)
 		return -EIO;
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 37/52] kstrtox: convert drivers/scsi/
  2011-02-05 14:20 [PATCH 01/52] kstrtox: converting strings to integers done (hopefully) right Alexey Dobriyan
                   ` (34 preceding siblings ...)
  2011-02-05 14:20 ` [PATCH 36/52] kstrtox: convert drivers/rtc/ Alexey Dobriyan
@ 2011-02-05 14:20 ` Alexey Dobriyan
  2011-02-05 14:20 ` [PATCH 38/52] kstrtox: convert drivers/ssb/ Alexey Dobriyan
                   ` (14 subsequent siblings)
  50 siblings, 0 replies; 58+ messages in thread
From: Alexey Dobriyan @ 2011-02-05 14:20 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, adobriyan


Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
 drivers/scsi/pmcraid.c    |    2 +-
 drivers/scsi/scsi_sysfs.c |    9 +++++----
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
index 321cf3a..504022a 100644
--- a/drivers/scsi/pmcraid.c
+++ b/drivers/scsi/pmcraid.c
@@ -4213,7 +4213,7 @@ static ssize_t pmcraid_store_log_level(
 	struct pmcraid_instance *pinstance;
 	unsigned long val;
 
-	if (strict_strtoul(buf, 10, &val))
+	if (kstrtoul(buf, 10, &val))
 		return -EINVAL;
 	/* log-level should be from 0 to 2 */
 	if (val > 2)
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index 490ce21..f929326 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -757,11 +757,12 @@ sdev_store_queue_ramp_up_period(struct device *dev,
 				const char *buf, size_t count)
 {
 	struct scsi_device *sdev = to_scsi_device(dev);
-	unsigned long period;
-
-	if (strict_strtoul(buf, 10, &period))
-		return -EINVAL;
+	unsigned int period;
+	int rv;
 
+	rv = kstrtouint(buf, 10, &period);
+	if (rv < 0)
+		return rv;
 	sdev->queue_ramp_up_period = msecs_to_jiffies(period);
 	return period;
 }
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 38/52] kstrtox: convert drivers/ssb/
  2011-02-05 14:20 [PATCH 01/52] kstrtox: converting strings to integers done (hopefully) right Alexey Dobriyan
                   ` (35 preceding siblings ...)
  2011-02-05 14:20 ` [PATCH 37/52] kstrtox: convert drivers/scsi/ Alexey Dobriyan
@ 2011-02-05 14:20 ` Alexey Dobriyan
  2011-02-05 14:20 ` [PATCH 39/52] kstrtox: convert drivers/target/ Alexey Dobriyan
                   ` (13 subsequent siblings)
  50 siblings, 0 replies; 58+ messages in thread
From: Alexey Dobriyan @ 2011-02-05 14:20 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, adobriyan


Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
 drivers/ssb/sprom.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/ssb/sprom.c b/drivers/ssb/sprom.c
index 4f7cc8d..fea2ac4 100644
--- a/drivers/ssb/sprom.c
+++ b/drivers/ssb/sprom.c
@@ -38,7 +38,6 @@ static int hex2sprom(u16 *sprom, const char *dump, size_t len,
 {
 	char c, tmp[5] = { 0 };
 	int err, cnt = 0;
-	unsigned long parsed;
 
 	/* Strip whitespace at the end. */
 	while (len) {
@@ -52,12 +51,14 @@ static int hex2sprom(u16 *sprom, const char *dump, size_t len,
 		return -EINVAL;
 
 	while (cnt < sprom_size_words) {
+		u16 parsed;
+
 		memcpy(tmp, dump, 4);
 		dump += 4;
-		err = strict_strtoul(tmp, 16, &parsed);
+		err = kstrtou16(tmp, 16, &parsed);
 		if (err)
 			return err;
-		sprom[cnt++] = swab16((u16)parsed);
+		sprom[cnt++] = swab16(parsed);
 	}
 
 	return 0;
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 39/52] kstrtox: convert drivers/target/
  2011-02-05 14:20 [PATCH 01/52] kstrtox: converting strings to integers done (hopefully) right Alexey Dobriyan
                   ` (36 preceding siblings ...)
  2011-02-05 14:20 ` [PATCH 38/52] kstrtox: convert drivers/ssb/ Alexey Dobriyan
@ 2011-02-05 14:20 ` Alexey Dobriyan
  2011-02-05 14:20 ` [PATCH 40/52] kstrtox: convert drivers/usb/ Alexey Dobriyan
                   ` (12 subsequent siblings)
  50 siblings, 0 replies; 58+ messages in thread
From: Alexey Dobriyan @ 2011-02-05 14:20 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, adobriyan


Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
 drivers/target/target_core_alua.c            |   28 ++++----
 drivers/target/target_core_configfs.c        |  102 ++++++++------------------
 drivers/target/target_core_fabric_configfs.c |   13 ++--
 drivers/target/target_core_file.c            |    7 +-
 4 files changed, 53 insertions(+), 97 deletions(-)

diff --git a/drivers/target/target_core_alua.c b/drivers/target/target_core_alua.c
index 2c5fcfe..27096da8 100644
--- a/drivers/target/target_core_alua.c
+++ b/drivers/target/target_core_alua.c
@@ -1714,10 +1714,10 @@ ssize_t core_alua_store_access_type(
 	unsigned long tmp;
 	int ret;
 
-	ret = strict_strtoul(page, 0, &tmp);
+	ret = kstrtoul(page, 0, &tmp);
 	if (ret < 0) {
 		printk(KERN_ERR "Unable to extract alua_access_type\n");
-		return -EINVAL;
+		return ret;
 	}
 	if ((tmp != 0) && (tmp != 1) && (tmp != 2) && (tmp != 3)) {
 		printk(KERN_ERR "Illegal value for alua_access_type:"
@@ -1752,10 +1752,10 @@ ssize_t core_alua_store_nonop_delay_msecs(
 	unsigned long tmp;
 	int ret;
 
-	ret = strict_strtoul(page, 0, &tmp);
+	ret = kstrtoul(page, 0, &tmp);
 	if (ret < 0) {
 		printk(KERN_ERR "Unable to extract nonop_delay_msecs\n");
-		return -EINVAL;
+		return ret;
 	}
 	if (tmp > ALUA_MAX_NONOP_DELAY_MSECS) {
 		printk(KERN_ERR "Passed nonop_delay_msecs: %lu, exceeds"
@@ -1783,10 +1783,10 @@ ssize_t core_alua_store_trans_delay_msecs(
 	unsigned long tmp;
 	int ret;
 
-	ret = strict_strtoul(page, 0, &tmp);
+	ret = kstrtoul(page, 0, &tmp);
 	if (ret < 0) {
 		printk(KERN_ERR "Unable to extract trans_delay_msecs\n");
-		return -EINVAL;
+		return ret;
 	}
 	if (tmp > ALUA_MAX_TRANS_DELAY_MSECS) {
 		printk(KERN_ERR "Passed trans_delay_msecs: %lu, exceeds"
@@ -1814,10 +1814,10 @@ ssize_t core_alua_store_preferred_bit(
 	unsigned long tmp;
 	int ret;
 
-	ret = strict_strtoul(page, 0, &tmp);
+	ret = kstrtoul(page, 0, &tmp);
 	if (ret < 0) {
 		printk(KERN_ERR "Unable to extract preferred ALUA value\n");
-		return -EINVAL;
+		return ret;
 	}
 	if ((tmp != 0) && (tmp != 1)) {
 		printk(KERN_ERR "Illegal value for preferred ALUA: %lu\n", tmp);
@@ -1849,10 +1849,10 @@ ssize_t core_alua_store_offline_bit(
 	if (!(lun->lun_sep))
 		return -ENODEV;
 
-	ret = strict_strtoul(page, 0, &tmp);
+	ret = kstrtoul(page, 0, &tmp);
 	if (ret < 0) {
 		printk(KERN_ERR "Unable to extract alua_tg_pt_offline value\n");
-		return -EINVAL;
+		return ret;
 	}
 	if ((tmp != 0) && (tmp != 1)) {
 		printk(KERN_ERR "Illegal value for alua_tg_pt_offline: %lu\n",
@@ -1888,10 +1888,10 @@ ssize_t core_alua_store_secondary_status(
 	unsigned long tmp;
 	int ret;
 
-	ret = strict_strtoul(page, 0, &tmp);
+	ret = kstrtoul(page, 0, &tmp);
 	if (ret < 0) {
 		printk(KERN_ERR "Unable to extract alua_tg_pt_status\n");
-		return -EINVAL;
+		return ret;
 	}
 	if ((tmp != ALUA_STATUS_NONE) &&
 	    (tmp != ALUA_STATUS_ALTERED_BY_EXPLICT_STPG) &&
@@ -1921,10 +1921,10 @@ ssize_t core_alua_store_secondary_write_metadata(
 	unsigned long tmp;
 	int ret;
 
-	ret = strict_strtoul(page, 0, &tmp);
+	ret = kstrtoul(page, 0, &tmp);
 	if (ret < 0) {
 		printk(KERN_ERR "Unable to extract alua_tg_pt_write_md\n");
-		return -EINVAL;
+		return ret;
 	}
 	if ((tmp != 0) && (tmp != 1)) {
 		printk(KERN_ERR "Illegal value for alua_tg_pt_write_md:"
diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c
index 2764510..c659a7c 100644
--- a/drivers/target/target_core_configfs.c
+++ b/drivers/target/target_core_configfs.c
@@ -649,23 +649,19 @@ static ssize_t target_core_dev_store_attr_##_name(			\
 {									\
 	struct se_device *dev;						\
 	struct se_subsystem_dev *se_dev = da->da_sub_dev;			\
-	unsigned long val;						\
+	u32 val;							\
 	int ret;							\
 									\
+	ret = kstrtou32(page, 0, &val);					\
+	if (ret < 0)							\
+		return ret;						\
 	spin_lock(&se_dev->se_dev_lock);				\
 	dev = se_dev->se_dev_ptr;					\
 	if (!(dev)) {							\
 		spin_unlock(&se_dev->se_dev_lock);			\
 		return -ENODEV;						\
 	}								\
-	ret = strict_strtoul(page, 0, &val);				\
-	if (ret < 0) {							\
-		spin_unlock(&se_dev->se_dev_lock);                      \
-		printk(KERN_ERR "strict_strtoul() failed with"		\
-			" ret: %d\n", ret);				\
-		return -EINVAL;						\
-	}								\
-	ret = se_dev_set_##_name(dev, (u32)val);			\
+	ret = se_dev_set_##_name(dev, val);				\
 	spin_unlock(&se_dev->se_dev_lock);				\
 									\
 	return (!ret) ? count : -EINVAL;				\
@@ -1456,7 +1452,6 @@ static ssize_t target_core_dev_pr_store_attr_res_aptpl_metadata(
 	unsigned char *isid = NULL;
 	char *orig, *ptr, *arg_p, *opts;
 	substring_t args[MAX_OPT_ARGS];
-	unsigned long long tmp_ll;
 	u64 sa_res_key = 0;
 	u32 mapped_lun = 0, target_lun = 0;
 	int ret = -1, res_holder = 0, all_tg_pt = 0, arg, token;
@@ -1512,13 +1507,9 @@ static ssize_t target_core_dev_pr_store_attr_res_aptpl_metadata(
 			break;
 		case Opt_sa_res_key:
 			arg_p = match_strdup(&args[0]);
-			ret = strict_strtoull(arg_p, 0, &tmp_ll);
-			if (ret < 0) {
-				printk(KERN_ERR "strict_strtoull() failed for"
-					" sa_res_key=\n");
+			ret = kstrtou64(arg_p, 0, &sa_res_key);
+			if (ret < 0)
 				goto out;
-			}
-			sa_res_key = (u64)tmp_ll;
 			break;
 		/*
 		 * PR APTPL Metadata for Reservation
@@ -2061,22 +2052,14 @@ static ssize_t target_core_alua_lu_gp_store_attr_lu_gp_id(
 	size_t count)
 {
 	struct config_group *alua_lu_gp_cg = &lu_gp->lu_gp_group;
-	unsigned long lu_gp_id;
+	u16 lu_gp_id;
 	int ret;
 
-	ret = strict_strtoul(page, 0, &lu_gp_id);
-	if (ret < 0) {
-		printk(KERN_ERR "strict_strtoul() returned %d for"
-			" lu_gp_id\n", ret);
-		return -EINVAL;
-	}
-	if (lu_gp_id > 0x0000ffff) {
-		printk(KERN_ERR "ALUA lu_gp_id: %lu exceeds maximum:"
-			" 0x0000ffff\n", lu_gp_id);
-		return -EINVAL;
-	}
+	ret = kstrtou16(page, 0, &lu_gp_id);
+	if (ret < 0)
+		return ret;
 
-	ret = core_alua_set_lu_gp_id(lu_gp, (u16)lu_gp_id);
+	ret = core_alua_set_lu_gp_id(lu_gp, lu_gp_id);
 	if (ret < 0)
 		return -EINVAL;
 
@@ -2242,7 +2225,6 @@ static ssize_t target_core_alua_tg_pt_gp_store_attr_alua_access_state(
 	size_t count)
 {
 	struct se_subsystem_dev *su_dev = tg_pt_gp->tg_pt_gp_su_dev;
-	unsigned long tmp;
 	int new_state, ret;
 
 	if (!(tg_pt_gp->tg_pt_gp_valid_id)) {
@@ -2251,13 +2233,9 @@ static ssize_t target_core_alua_tg_pt_gp_store_attr_alua_access_state(
 		return -EINVAL;
 	}
 
-	ret = strict_strtoul(page, 0, &tmp);
-	if (ret < 0) {
-		printk("Unable to extract new ALUA access state from"
-				" %s\n", page);
-		return -EINVAL;
-	}
-	new_state = (int)tmp;
+	ret = kstrtoint(page, 0, &new_state);
+	if (ret < 0)
+		return ret;
 
 	if (!(tg_pt_gp->tg_pt_gp_alua_access_type & TPGS_IMPLICT_ALUA)) {
 		printk(KERN_ERR "Unable to process implict configfs ALUA"
@@ -2288,7 +2266,6 @@ static ssize_t target_core_alua_tg_pt_gp_store_attr_alua_access_status(
 	const char *page,
 	size_t count)
 {
-	unsigned long tmp;
 	int new_status, ret;
 
 	if (!(tg_pt_gp->tg_pt_gp_valid_id)) {
@@ -2298,13 +2275,9 @@ static ssize_t target_core_alua_tg_pt_gp_store_attr_alua_access_status(
 		return -EINVAL;
 	}
 
-	ret = strict_strtoul(page, 0, &tmp);
-	if (ret < 0) {
-		printk(KERN_ERR "Unable to extract new ALUA access status"
-				" from %s\n", page);
-		return -EINVAL;
-	}
-	new_status = (int)tmp;
+	ret = kstrtoint(page, 0, &new_status);
+	if (ret < 0)
+		return ret;
 
 	if ((new_status != ALUA_STATUS_NONE) &&
 	    (new_status != ALUA_STATUS_ALTERED_BY_EXPLICT_STPG) &&
@@ -2358,7 +2331,7 @@ static ssize_t target_core_alua_tg_pt_gp_store_attr_alua_write_metadata(
 	unsigned long tmp;
 	int ret;
 
-	ret = strict_strtoul(page, 0, &tmp);
+	ret = kstrtoul(page, 0, &tmp);
 	if (ret < 0) {
 		printk(KERN_ERR "Unable to extract alua_write_metadata\n");
 		return -EINVAL;
@@ -2459,22 +2432,14 @@ static ssize_t target_core_alua_tg_pt_gp_store_attr_tg_pt_gp_id(
 	size_t count)
 {
 	struct config_group *alua_tg_pt_gp_cg = &tg_pt_gp->tg_pt_gp_group;
-	unsigned long tg_pt_gp_id;
+	u16 tg_pt_gp_id;
 	int ret;
 
-	ret = strict_strtoul(page, 0, &tg_pt_gp_id);
-	if (ret < 0) {
-		printk(KERN_ERR "strict_strtoul() returned %d for"
-			" tg_pt_gp_id\n", ret);
-		return -EINVAL;
-	}
-	if (tg_pt_gp_id > 0x0000ffff) {
-		printk(KERN_ERR "ALUA tg_pt_gp_id: %lu exceeds maximum:"
-			" 0x0000ffff\n", tg_pt_gp_id);
-		return -EINVAL;
-	}
+	ret = kstrtou16(page, 0, &tg_pt_gp_id);
+	if (ret < 0)
+		return ret;
 
-	ret = core_alua_set_tg_pt_gp_id(tg_pt_gp, (u16)tg_pt_gp_id);
+	ret = core_alua_set_tg_pt_gp_id(tg_pt_gp, tg_pt_gp_id);
 	if (ret < 0)
 		return -EINVAL;
 
@@ -2885,11 +2850,9 @@ static ssize_t target_core_hba_store_attr_hba_mode(struct se_hba *hba,
 	if (transport->pmode_enable_hba == NULL)
 		return -EINVAL;
 
-	ret = strict_strtoul(page, 0, &mode_flag);
-	if (ret < 0) {
-		printk(KERN_ERR "Unable to extract hba mode flag: %d\n", ret);
-		return -EINVAL;
-	}
+	ret = kstrtoul(page, 0, &mode_flag);
+	if (ret < 0)
+		return ret;
 
 	spin_lock(&hba->device_lock);
 	if (!(list_empty(&hba->hba_dev_list))) {
@@ -2939,7 +2902,7 @@ static struct config_group *target_core_call_addhbatotarget(
 	char *se_plugin_str, *str, *str2;
 	struct se_hba *hba;
 	char buf[TARGET_CORE_NAME_MAX_LEN];
-	unsigned long plugin_dep_id = 0;
+	u32 plugin_dep_id;
 	int ret;
 
 	memset(buf, 0, TARGET_CORE_NAME_MAX_LEN);
@@ -2971,12 +2934,9 @@ static struct config_group *target_core_call_addhbatotarget(
 		str++; /* Skip to start of plugin dependent ID */
 	}
 
-	ret = strict_strtoul(str, 0, &plugin_dep_id);
-	if (ret < 0) {
-		printk(KERN_ERR "strict_strtoul() returned %d for"
-				" plugin_dep_id\n", ret);
-		return ERR_PTR(-EINVAL);
-	}
+	ret = kstrtou32(str, 0, &plugin_dep_id);
+	if (ret < 0)
+		return ERR_PTR(ret);
 	/*
 	 * Load up TCM subsystem plugins if they have not already been loaded.
 	 */
diff --git a/drivers/target/target_core_fabric_configfs.c b/drivers/target/target_core_fabric_configfs.c
index 32b148d..5c6c43c 100644
--- a/drivers/target/target_core_fabric_configfs.c
+++ b/drivers/target/target_core_fabric_configfs.c
@@ -190,7 +190,7 @@ static ssize_t target_fabric_mappedlun_store_write_protect(
 	struct se_portal_group *se_tpg = se_nacl->se_tpg;
 	unsigned long op;
 
-	if (strict_strtoul(page, 0, &op))
+	if (kstrtoul(page, 0, &op))
 		return -EINVAL;
 
 	if ((op != 1) && (op != 0))
@@ -285,7 +285,7 @@ static struct config_group *target_fabric_make_mappedlun(
 	struct se_lun_acl *lacl;
 	struct config_item *acl_ci;
 	char *buf;
-	unsigned long mapped_lun;
+	unsigned int mapped_lun;
 	int ret = 0;
 
 	acl_ci = &group->cg_item;
@@ -313,10 +313,9 @@ static struct config_group *target_fabric_make_mappedlun(
 	 * Determine the Mapped LUN value.  This is what the SCSI Initiator
 	 * Port will actually see.
 	 */
-	if (strict_strtoul(buf + 4, 0, &mapped_lun) || mapped_lun > UINT_MAX) {
-		ret = -EINVAL;
+	ret = kstrtouint(buf + 4, 0, &mapped_lun);
+	if (ret < 0)
 		goto out;
-	}
 
 	lacl = core_dev_init_initiator_node_lun_acl(se_tpg, mapped_lun,
 			config_item_name(acl_ci), &ret);
@@ -746,14 +745,14 @@ static struct config_group *target_fabric_make_lun(
 	struct se_portal_group *se_tpg = container_of(group,
 			struct se_portal_group, tpg_lun_group);
 	struct target_fabric_configfs *tf = se_tpg->se_tpg_wwn->wwn_tf;
-	unsigned long unpacked_lun;
+	u32 unpacked_lun;
 
 	if (strstr(name, "lun_") != name) {
 		printk(KERN_ERR "Unable to locate \'_\" in"
 				" \"lun_$LUN_NUMBER\"\n");
 		return ERR_PTR(-EINVAL);
 	}
-	if (strict_strtoul(name + 4, 0, &unpacked_lun) || unpacked_lun > UINT_MAX)
+	if (kstrtou32(name + 4, 0, &unpacked_lun))
 		return ERR_PTR(-EINVAL);
 
 	lun = core_get_lun_from_tpg(se_tpg, unpacked_lun);
diff --git a/drivers/target/target_core_file.c b/drivers/target/target_core_file.c
index 0aaca88..7203eb1 100644
--- a/drivers/target/target_core_file.c
+++ b/drivers/target/target_core_file.c
@@ -545,12 +545,9 @@ static ssize_t fd_set_configfs_dev_params(
 			break;
 		case Opt_fd_dev_size:
 			arg_p = match_strdup(&args[0]);
-			ret = strict_strtoull(arg_p, 0, &fd_dev->fd_dev_size);
-			if (ret < 0) {
-				printk(KERN_ERR "strict_strtoull() failed for"
-						" fd_dev_size=\n");
+			ret = kstrtoull(arg_p, 0, &fd_dev->fd_dev_size);
+			if (ret < 0)
 				goto out;
-			}
 			printk(KERN_INFO "FILEIO: Referencing Size: %llu"
 					" bytes\n", fd_dev->fd_dev_size);
 			fd_dev->fbd_flags |= FBDF_HAS_SIZE;
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 40/52] kstrtox: convert drivers/usb/
  2011-02-05 14:20 [PATCH 01/52] kstrtox: converting strings to integers done (hopefully) right Alexey Dobriyan
                   ` (37 preceding siblings ...)
  2011-02-05 14:20 ` [PATCH 39/52] kstrtox: convert drivers/target/ Alexey Dobriyan
@ 2011-02-05 14:20 ` Alexey Dobriyan
  2011-04-14 10:31   ` [40/52] " Michal Nazarewicz
  2011-02-05 14:20 ` [PATCH 41/52] kstrtox: convert drivers/video/ Alexey Dobriyan
                   ` (11 subsequent siblings)
  50 siblings, 1 reply; 58+ messages in thread
From: Alexey Dobriyan @ 2011-02-05 14:20 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, adobriyan


Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
 drivers/usb/gadget/storage_common.c |    7 ++++---
 drivers/usb/host/ehci-dbg.c         |    6 +++---
 drivers/usb/serial/iuu_phoenix.c    |   27 ++++++++++-----------------
 3 files changed, 17 insertions(+), 23 deletions(-)

diff --git a/drivers/usb/gadget/storage_common.c b/drivers/usb/gadget/storage_common.c
index b015561..ed81718 100644
--- a/drivers/usb/gadget/storage_common.c
+++ b/drivers/usb/gadget/storage_common.c
@@ -713,8 +713,9 @@ static ssize_t fsg_store_ro(struct device *dev, struct device_attribute *attr,
 	struct rw_semaphore	*filesem = dev_get_drvdata(dev);
 	unsigned long	ro;
 
-	if (strict_strtoul(buf, 2, &ro))
-		return -EINVAL;
+	rc = kstrtoul(buf, 2, &ro);
+	if (rc < 0)
+		return rc;
 
 	/*
 	 * Allow the write-enable status to change only while the
@@ -740,7 +741,7 @@ static ssize_t fsg_store_nofua(struct device *dev,
 	struct fsg_lun	*curlun = fsg_lun_from_dev(dev);
 	unsigned long	nofua;
 
-	if (strict_strtoul(buf, 2, &nofua))
+	if (kstrtoul(buf, 2, &nofua))
 		return -EINVAL;
 
 	/* Sync data when switching from async mode to sync */
diff --git a/drivers/usb/host/ehci-dbg.c b/drivers/usb/host/ehci-dbg.c
index 3be238a..e4d02d3 100644
--- a/drivers/usb/host/ehci-dbg.c
+++ b/drivers/usb/host/ehci-dbg.c
@@ -1000,7 +1000,7 @@ static ssize_t debug_lpm_write(struct file *file, const char __user *user_buf,
 		buf[len - 1] = '\0';
 
 	if (strncmp(buf, "enable", 5) == 0) {
-		if (strict_strtoul(buf + 7, 10, &port))
+		if (kstrtoul(buf + 7, 10, &port))
 			return -EINVAL;
 		params = ehci_readl(ehci, &ehci->caps->hcs_params);
 		if (port > HCS_N_PORTS(params)) {
@@ -1018,7 +1018,7 @@ static ssize_t debug_lpm_write(struct file *file, const char __user *user_buf,
 		printk(KERN_INFO "force enable LPM for port %lu\n", port);
 	} else if (strncmp(buf, "hird=", 5) == 0) {
 		unsigned long hird;
-		if (strict_strtoul(buf + 5, 16, &hird))
+		if (kstrtoul(buf + 5, 16, &hird))
 			return -EINVAL;
 		printk(KERN_INFO "setting hird %s %lu\n", buf + 6, hird);
 		temp = ehci_readl(ehci, &ehci->regs->command);
@@ -1026,7 +1026,7 @@ static ssize_t debug_lpm_write(struct file *file, const char __user *user_buf,
 		temp |= hird << 24;
 		ehci_writel(ehci, temp, &ehci->regs->command);
 	} else if (strncmp(buf, "disable", 7) == 0) {
-		if (strict_strtoul(buf + 8, 10, &port))
+		if (kstrtoul(buf + 8, 10, &port))
 			return -EINVAL;
 		params = ehci_readl(ehci, &ehci->caps->hcs_params);
 		if (port > HCS_N_PORTS(params)) {
diff --git a/drivers/usb/serial/iuu_phoenix.c b/drivers/usb/serial/iuu_phoenix.c
index 99b97c0..cd49577 100644
--- a/drivers/usb/serial/iuu_phoenix.c
+++ b/drivers/usb/serial/iuu_phoenix.c
@@ -1227,23 +1227,16 @@ static ssize_t store_vcc_mode(struct device *dev,
 {
 	struct usb_serial_port *port = to_usb_serial_port(dev);
 	struct iuu_private *priv = usb_get_serial_port_data(port);
-	unsigned long v;
-
-	if (strict_strtoul(buf, 10, &v)) {
-		dev_err(dev, "%s - vcc_mode: %s is not a unsigned long\n",
-				__func__, buf);
-		goto fail_store_vcc_mode;
-	}
-
-	dbg("%s: setting vcc_mode = %ld", __func__, v);
-
-	if ((v != 3) && (v != 5)) {
-		dev_err(dev, "%s - vcc_mode %ld is invalid\n", __func__, v);
-	} else {
-		iuu_vcc_set(port, v);
-		priv->vcc = v;
-	}
-fail_store_vcc_mode:
+	int v;
+	int rv;
+
+	rv = kstrtoint(buf, 10, &v);
+	if (rv < 0)
+		return rv;
+	if (v != 3 && v != 5)
+		return -EINVAL;
+	iuu_vcc_set(port, v);
+	priv->vcc = v;
 	return count;
 }
 
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 41/52] kstrtox: convert drivers/video/
  2011-02-05 14:20 [PATCH 01/52] kstrtox: converting strings to integers done (hopefully) right Alexey Dobriyan
                   ` (38 preceding siblings ...)
  2011-02-05 14:20 ` [PATCH 40/52] kstrtox: convert drivers/usb/ Alexey Dobriyan
@ 2011-02-05 14:20 ` Alexey Dobriyan
  2011-02-05 14:20 ` [PATCH 42/52] kstrtox: convert drivers/w1/ Alexey Dobriyan
                   ` (10 subsequent siblings)
  50 siblings, 0 replies; 58+ messages in thread
From: Alexey Dobriyan @ 2011-02-05 14:20 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, adobriyan


Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
 drivers/video/backlight/adp5520_bl.c               |   13 +-
 drivers/video/backlight/adp8860_bl.c               |   12 +-
 drivers/video/backlight/backlight.c                |    4 +-
 drivers/video/backlight/s6e63m0.c                  |    2 +-
 drivers/video/fsl-diu-fb.c                         |   36 +++--
 .../video/omap2/displays/panel-tpo-td043mtea1.c    |   10 +-
 drivers/video/omap2/dss/display.c                  |   16 +-
 drivers/video/via/viafbdev.c                       |  155 ++++++++++++--------
 drivers/video/wm8505fb.c                           |    2 +-
 9 files changed, 152 insertions(+), 98 deletions(-)

diff --git a/drivers/video/backlight/adp5520_bl.c b/drivers/video/backlight/adp5520_bl.c
index 9f436e0..497d0a7 100644
--- a/drivers/video/backlight/adp5520_bl.c
+++ b/drivers/video/backlight/adp5520_bl.c
@@ -18,7 +18,7 @@ struct adp5520_bl {
 	struct device *master;
 	struct adp5520_backlight_platform_data *pdata;
 	struct mutex lock;
-	unsigned long cached_daylight_max;
+	u8 cached_daylight_max;
 	int id;
 	int current_brightness;
 };
@@ -156,11 +156,11 @@ static ssize_t adp5520_store(struct device *dev, const char *buf,
 			 size_t count, int reg)
 {
 	struct adp5520_bl *data = dev_get_drvdata(dev);
-	unsigned long val;
+	u8 val;
 	int ret;
 
-	ret = strict_strtoul(buf, 10, &val);
-	if (ret)
+	ret = kstrtou8(buf, 10, &val);
+	if (ret < 0)
 		return ret;
 
 	mutex_lock(&data->lock);
@@ -211,8 +211,11 @@ static ssize_t adp5520_bl_daylight_max_store(struct device *dev,
 			const char *buf, size_t count)
 {
 	struct adp5520_bl *data = dev_get_drvdata(dev);
+	int rv;
 
-	strict_strtoul(buf, 10, &data->cached_daylight_max);
+	rv = kstrtou8(buf, 10, &data->cached_daylight_max);
+	if (rv < 0)
+		return rv;
 	return adp5520_store(dev, buf, count, ADP5520_DAYLIGHT_MAX);
 }
 static DEVICE_ATTR(daylight_max, 0664, adp5520_bl_daylight_max_show,
diff --git a/drivers/video/backlight/adp8860_bl.c b/drivers/video/backlight/adp8860_bl.c
index 734c650..6cfbb5f 100644
--- a/drivers/video/backlight/adp8860_bl.c
+++ b/drivers/video/backlight/adp8860_bl.c
@@ -110,7 +110,7 @@ struct adp8860_bl {
 	struct adp8860_led *led;
 	struct adp8860_backlight_platform_data *pdata;
 	struct mutex lock;
-	unsigned long cached_daylight_max;
+	u8 cached_daylight_max;
 	int id;
 	int revid;
 	int current_brightness;
@@ -449,10 +449,10 @@ static ssize_t adp8860_store(struct device *dev, const char *buf,
 			 size_t count, int reg)
 {
 	struct adp8860_bl *data = dev_get_drvdata(dev);
-	unsigned long val;
+	u8 val;
 	int ret;
 
-	ret = strict_strtoul(buf, 10, &val);
+	ret = kstrtou8(buf, 10, &val);
 	if (ret)
 		return ret;
 
@@ -502,7 +502,9 @@ static ssize_t adp8860_bl_l1_daylight_max_store(struct device *dev,
 		struct device_attribute *attr, const char *buf, size_t count)
 {
 	struct adp8860_bl *data = dev_get_drvdata(dev);
-	int ret = strict_strtoul(buf, 10, &data->cached_daylight_max);
+	int ret;
+
+	ret = kstrtou8(buf, 10, &data->cached_daylight_max);
 	if (ret)
 		return ret;
 
@@ -609,7 +611,7 @@ static ssize_t adp8860_bl_ambient_light_zone_store(struct device *dev,
 	uint8_t reg_val;
 	int ret;
 
-	ret = strict_strtoul(buf, 10, &val);
+	ret = kstrtoul(buf, 10, &val);
 	if (ret)
 		return ret;
 
diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c
index 0870329..e6cd673 100644
--- a/drivers/video/backlight/backlight.c
+++ b/drivers/video/backlight/backlight.c
@@ -110,7 +110,7 @@ static ssize_t backlight_store_power(struct device *dev,
 	struct backlight_device *bd = to_backlight_device(dev);
 	unsigned long power;
 
-	rc = strict_strtoul(buf, 0, &power);
+	rc = kstrtoul(buf, 0, &power);
 	if (rc)
 		return rc;
 
@@ -144,7 +144,7 @@ static ssize_t backlight_store_brightness(struct device *dev,
 	struct backlight_device *bd = to_backlight_device(dev);
 	unsigned long brightness;
 
-	rc = strict_strtoul(buf, 0, &brightness);
+	rc = kstrtoul(buf, 0, &brightness);
 	if (rc)
 		return rc;
 
diff --git a/drivers/video/backlight/s6e63m0.c b/drivers/video/backlight/s6e63m0.c
index 5927db0..8bbbc4a 100644
--- a/drivers/video/backlight/s6e63m0.c
+++ b/drivers/video/backlight/s6e63m0.c
@@ -689,7 +689,7 @@ static ssize_t s6e63m0_sysfs_store_gamma_mode(struct device *dev,
 	struct backlight_device *bd = NULL;
 	int brightness, rc;
 
-	rc = strict_strtoul(buf, 0, (unsigned long *)&lcd->gamma_mode);
+	rc = kstrtouint(buf, 0, &lcd->gamma_mode);
 	if (rc < 0)
 		return rc;
 
diff --git a/drivers/video/fsl-diu-fb.c b/drivers/video/fsl-diu-fb.c
index 8bbbf08..88ffbac 100644
--- a/drivers/video/fsl-diu-fb.c
+++ b/drivers/video/fsl-diu-fb.c
@@ -182,7 +182,7 @@ static struct fb_videomode __devinitdata fsl_diu_mode_db[] = {
 };
 
 static char *fb_mode = "1024x768-32@60";
-static unsigned long default_bpp = 32;
+static unsigned int default_bpp = 32;
 static int monitor_port;
 
 #if defined(CONFIG_NOT_COHERENT_CACHE)
@@ -1455,13 +1455,15 @@ static void free_buf(struct device *dev, struct diu_addr *buf, u32 size,
 static ssize_t store_monitor(struct device *device,
 	struct device_attribute *attr, const char *buf, size_t count)
 {
-	int old_monitor_port;
-	unsigned long val;
 	struct fsl_diu_data *machine_data =
 		container_of(attr, struct fsl_diu_data, dev_attr);
+	int old_monitor_port;
+	int val;
+	int rv;
 
-	if (strict_strtoul(buf, 10, &val))
-		return 0;
+	rv = kstrtoint(buf, 10, &val);
+	if (rv < 0)
+		return rv;
 
 	old_monitor_port = machine_data->monitor_port;
 	machine_data->monitor_port = diu_ops.set_sysfs_monitor_port(val);
@@ -1700,20 +1702,28 @@ static int fsl_diu_remove(struct platform_device *ofdev)
 static int __init fsl_diu_setup(char *options)
 {
 	char *opt;
-	unsigned long val;
 
 	if (!options || !*options)
 		return 0;
 
 	while ((opt = strsep(&options, ",")) != NULL) {
+		int rv;
+
 		if (!*opt)
 			continue;
 		if (!strncmp(opt, "monitor=", 8)) {
-			if (!strict_strtoul(opt + 8, 10, &val) && (val <= 2))
-				monitor_port = val;
+			int val;
+
+			rv = kstrtoint(opt + 8, 10, &val);
+			if (rv < 0)
+				return rv;
+			if (val < 0 || val > 2)
+				return -EINVAL;
+			monitor_port = val;
 		} else if (!strncmp(opt, "bpp=", 4)) {
-			if (!strict_strtoul(opt + 4, 10, &val))
-				default_bpp = val;
+			rv = kstrtouint(opt + 4, 10, &default_bpp);
+			if (rv < 0)
+				return rv;
 		} else
 			fb_mode = opt;
 	}
@@ -1762,7 +1772,9 @@ static int __init fsl_diu_init(void)
 	 */
 	if (fb_get_options("fslfb", &option))
 		return -ENODEV;
-	fsl_diu_setup(option);
+	ret = fsl_diu_setup(option);
+	if (ret < 0)
+		return ret;
 #endif
 	printk(KERN_INFO "Freescale DIU driver\n");
 
@@ -1827,7 +1839,7 @@ MODULE_LICENSE("GPL");
 module_param_named(mode, fb_mode, charp, 0);
 MODULE_PARM_DESC(mode,
 	"Specify resolution as \"<xres>x<yres>[-<bpp>][@<refresh>]\" ");
-module_param_named(bpp, default_bpp, ulong, 0);
+module_param_named(bpp, default_bpp, uint, 0);
 MODULE_PARM_DESC(bpp, "Specify bit-per-pixel if not specified mode");
 module_param_named(monitor, monitor_port, int, 0);
 MODULE_PARM_DESC(monitor,
diff --git a/drivers/video/omap2/displays/panel-tpo-td043mtea1.c b/drivers/video/omap2/displays/panel-tpo-td043mtea1.c
index dbe9d43..77a363b 100644
--- a/drivers/video/omap2/displays/panel-tpo-td043mtea1.c
+++ b/drivers/video/omap2/displays/panel-tpo-td043mtea1.c
@@ -147,7 +147,7 @@ static ssize_t tpo_td043_vmirror_store(struct device *dev,
 	long val;
 	int ret;
 
-	ret = strict_strtol(buf, 0, &val);
+	ret = kstrtol(buf, 0, &val);
 	if (ret < 0)
 		return ret;
 
@@ -172,11 +172,13 @@ static ssize_t tpo_td043_mode_store(struct device *dev,
 	struct device_attribute *attr, const char *buf, size_t count)
 {
 	struct tpo_td043_device *tpo_td043 = dev_get_drvdata(dev);
-	long val;
+	u8 val;
 	int ret;
 
-	ret = strict_strtol(buf, 0, &val);
-	if (ret != 0 || val & ~7)
+	ret = kstrtou8(buf, 0, &val);
+	if (ret < 0)
+		return ret;
+	if (val & ~7)
 		return -EINVAL;
 
 	tpo_td043->mode = val;
diff --git a/drivers/video/omap2/dss/display.c b/drivers/video/omap2/dss/display.c
index 22dd7a4..413b618 100644
--- a/drivers/video/omap2/dss/display.c
+++ b/drivers/video/omap2/dss/display.c
@@ -262,21 +262,21 @@ static ssize_t display_wss_store(struct device *dev,
 		struct device_attribute *attr, const char *buf, size_t size)
 {
 	struct omap_dss_device *dssdev = to_dss_device(dev);
-	unsigned long wss;
-	int r;
+	u32 wss;
+	int rv;
 
 	if (!dssdev->driver->get_wss || !dssdev->driver->set_wss)
 		return -ENOENT;
 
-	if (strict_strtoul(buf, 0, &wss))
-		return -EINVAL;
-
+	rv = kstrtou32(buf, 0, &wss);
+	if (rv < 0)
+		return rv;
 	if (wss > 0xfffff)
 		return -EINVAL;
 
-	r = dssdev->driver->set_wss(dssdev, wss);
-	if (r)
-		return r;
+	rv = dssdev->driver->set_wss(dssdev, wss);
+	if (rv)
+		return rv;
 
 	return size;
 }
diff --git a/drivers/video/via/viafbdev.c b/drivers/video/via/viafbdev.c
index 4e66349..58a3765 100644
--- a/drivers/video/via/viafbdev.c
+++ b/drivers/video/via/viafbdev.c
@@ -1129,7 +1129,6 @@ static ssize_t viafb_dvp0_proc_write(struct file *file,
 	const char __user *buffer, size_t count, loff_t *pos)
 {
 	char buf[20], *value, *pbuf;
-	u8 reg_val = 0;
 	unsigned long length, i;
 	if (count < 1)
 		return -EINVAL;
@@ -1141,7 +1140,12 @@ static ssize_t viafb_dvp0_proc_write(struct file *file,
 	for (i = 0; i < 3; i++) {
 		value = strsep(&pbuf, " ");
 		if (value != NULL) {
-			strict_strtoul(value, 0, (unsigned long *)&reg_val);
+			u8 reg_val;
+			int rv;
+
+			rv = kstrtou8(value, 0, &reg_val);
+			if (rv < 0)
+				return rv;
 			DEBUG_MSG(KERN_INFO "DVP0:reg_val[%l]=:%x\n", i,
 				  reg_val);
 			switch (i) {
@@ -1199,7 +1203,6 @@ static ssize_t viafb_dvp1_proc_write(struct file *file,
 	const char __user *buffer, size_t count, loff_t *pos)
 {
 	char buf[20], *value, *pbuf;
-	u8 reg_val = 0;
 	unsigned long length, i;
 	if (count < 1)
 		return -EINVAL;
@@ -1211,7 +1214,10 @@ static ssize_t viafb_dvp1_proc_write(struct file *file,
 	for (i = 0; i < 3; i++) {
 		value = strsep(&pbuf, " ");
 		if (value != NULL) {
-			strict_strtoul(value, 0, (unsigned long *)&reg_val);
+			u8 reg_val;
+			int rv;
+
+			rv = kstrtou8(value, 0, &reg_val);
 			switch (i) {
 			case 0:
 				viafb_write_reg_mask(CR9B, VIACR,
@@ -1261,15 +1267,19 @@ static ssize_t viafb_dfph_proc_write(struct file *file,
 	const char __user *buffer, size_t count, loff_t *pos)
 {
 	char buf[20];
-	u8 reg_val = 0;
+	u8 reg_val;
 	unsigned long length;
+	int rv;
+
 	if (count < 1)
 		return -EINVAL;
 	length = count > 20 ? 20 : count;
 	if (copy_from_user(&buf[0], buffer, length))
 		return -EFAULT;
 	buf[length - 1] = '\0';	/*Ensure end string */
-	strict_strtoul(&buf[0], 0, (unsigned long *)&reg_val);
+	rv = kstrtou8(&buf[0], 0, &reg_val);
+	if (rv < 0)
+		return rv;
 	viafb_write_reg_mask(CR97, VIACR, reg_val, 0x0f);
 	return count;
 }
@@ -1300,15 +1310,19 @@ static ssize_t viafb_dfpl_proc_write(struct file *file,
 	const char __user *buffer, size_t count, loff_t *pos)
 {
 	char buf[20];
-	u8 reg_val = 0;
+	u8 reg_val;
 	unsigned long length;
+	int rv;
+
 	if (count < 1)
 		return -EINVAL;
 	length = count > 20 ? 20 : count;
 	if (copy_from_user(&buf[0], buffer, length))
 		return -EFAULT;
 	buf[length - 1] = '\0';	/*Ensure end string */
-	strict_strtoul(&buf[0], 0, (unsigned long *)&reg_val);
+	rv = kstrtou8(&buf[0], 0, &reg_val);
+	if (rv < 0)
+		return rv;
 	viafb_write_reg_mask(CR99, VIACR, reg_val, 0x0f);
 	return count;
 }
@@ -1365,6 +1379,8 @@ static ssize_t viafb_vt1636_proc_write(struct file *file,
 	char buf[30], *value, *pbuf;
 	struct IODATA reg_val;
 	unsigned long length, i;
+	int rv;
+
 	if (count < 1)
 		return -EINVAL;
 	length = count > 30 ? 30 : count;
@@ -1377,8 +1393,9 @@ static ssize_t viafb_vt1636_proc_write(struct file *file,
 		for (i = 0; i < 2; i++) {
 			value = strsep(&pbuf, " ");
 			if (value != NULL) {
-				strict_strtoul(value, 0,
-					(unsigned long *)&reg_val.Data);
+				rv = kstrtou8(value, 0, &reg_val.Data);
+				if (rv < 0)
+					return rv;
 				switch (i) {
 				case 0:
 					reg_val.Index = 0x08;
@@ -1414,8 +1431,9 @@ static ssize_t viafb_vt1636_proc_write(struct file *file,
 		for (i = 0; i < 2; i++) {
 			value = strsep(&pbuf, " ");
 			if (value != NULL) {
-				strict_strtoul(value, 0,
-					(unsigned long *)&reg_val.Data);
+				rv = kstrtou8(value, 0, &reg_val.Data);
+				if (rv < 0)
+					return rv;
 				switch (i) {
 				case 0:
 					reg_val.Index = 0x08;
@@ -1936,6 +1954,8 @@ static int __init viafb_setup(char *options)
 		return 0;
 
 	while ((this_opt = strsep(&options, ",")) != NULL) {
+		int rv;
+
 		if (!*this_opt)
 			continue;
 
@@ -1943,54 +1963,65 @@ static int __init viafb_setup(char *options)
 			viafb_mode1 = kstrdup(this_opt + 12, GFP_KERNEL);
 		else if (!strncmp(this_opt, "viafb_mode=", 11))
 			viafb_mode = kstrdup(this_opt + 11, GFP_KERNEL);
-		else if (!strncmp(this_opt, "viafb_bpp1=", 11))
-			strict_strtoul(this_opt + 11, 0,
-				(unsigned long *)&viafb_bpp1);
-		else if (!strncmp(this_opt, "viafb_bpp=", 10))
-			strict_strtoul(this_opt + 10, 0,
-				(unsigned long *)&viafb_bpp);
-		else if (!strncmp(this_opt, "viafb_refresh1=", 15))
-			strict_strtoul(this_opt + 15, 0,
-				(unsigned long *)&viafb_refresh1);
-		else if (!strncmp(this_opt, "viafb_refresh=", 14))
-			strict_strtoul(this_opt + 14, 0,
-				(unsigned long *)&viafb_refresh);
-		else if (!strncmp(this_opt, "viafb_lcd_dsp_method=", 21))
-			strict_strtoul(this_opt + 21, 0,
-				(unsigned long *)&viafb_lcd_dsp_method);
-		else if (!strncmp(this_opt, "viafb_lcd_panel_id=", 19))
-			strict_strtoul(this_opt + 19, 0,
-				(unsigned long *)&viafb_lcd_panel_id);
-		else if (!strncmp(this_opt, "viafb_accel=", 12))
-			strict_strtoul(this_opt + 12, 0,
-				(unsigned long *)&viafb_accel);
-		else if (!strncmp(this_opt, "viafb_SAMM_ON=", 14))
-			strict_strtoul(this_opt + 14, 0,
-				(unsigned long *)&viafb_SAMM_ON);
-		else if (!strncmp(this_opt, "viafb_active_dev=", 17))
+		else if (!strncmp(this_opt, "viafb_bpp1=", 11)) {
+			rv = kstrtoint(this_opt + 11, 0, &viafb_bpp1);
+			if (rv < 0)
+				return rv;
+		} else if (!strncmp(this_opt, "viafb_bpp=", 10)) {
+			rv = kstrtoint(this_opt + 10, 0, &viafb_bpp);
+			if (rv < 0)
+				return rv;
+		} else if (!strncmp(this_opt, "viafb_refresh1=", 15)) {
+			rv = kstrtoint(this_opt + 15, 0, &viafb_refresh1);
+			if (rv < 0)
+				return rv;
+		} else if (!strncmp(this_opt, "viafb_refresh=", 14)) {
+			rv = kstrtoint(this_opt + 14, 0, &viafb_refresh);
+			if (rv < 0)
+				return rv;
+		} else if (!strncmp(this_opt, "viafb_lcd_dsp_method=", 21)) {
+			rv = kstrtoint(this_opt + 21, 0, &viafb_lcd_dsp_method);
+			if (rv < 0)
+				return rv;
+		} else if (!strncmp(this_opt, "viafb_lcd_panel_id=", 19)) {
+			rv = kstrtoint(this_opt + 19, 0, &viafb_lcd_panel_id);
+			if (rv < 0)
+				return rv;
+		} else if (!strncmp(this_opt, "viafb_accel=", 12)) {
+			rv = kstrtoint(this_opt + 12, 0, &viafb_accel);
+			if (rv < 0)
+				return rv;
+		} else if (!strncmp(this_opt, "viafb_SAMM_ON=", 14)) {
+			rv = kstrtoint(this_opt + 14, 0, &viafb_SAMM_ON);
+			if (rv < 0)
+				return rv;
+		} else if (!strncmp(this_opt, "viafb_active_dev=", 17))
 			viafb_active_dev = kstrdup(this_opt + 17, GFP_KERNEL);
-		else if (!strncmp(this_opt,
-			"viafb_display_hardware_layout=", 30))
-			strict_strtoul(this_opt + 30, 0,
-			(unsigned long *)&viafb_display_hardware_layout);
-		else if (!strncmp(this_opt, "viafb_second_size=", 18))
-			strict_strtoul(this_opt + 18, 0,
-				(unsigned long *)&viafb_second_size);
-		else if (!strncmp(this_opt,
-			"viafb_platform_epia_dvi=", 24))
-			strict_strtoul(this_opt + 24, 0,
-				(unsigned long *)&viafb_platform_epia_dvi);
-		else if (!strncmp(this_opt,
-			"viafb_device_lcd_dualedge=", 26))
-			strict_strtoul(this_opt + 26, 0,
-				(unsigned long *)&viafb_device_lcd_dualedge);
-		else if (!strncmp(this_opt, "viafb_bus_width=", 16))
-			strict_strtoul(this_opt + 16, 0,
-				(unsigned long *)&viafb_bus_width);
-		else if (!strncmp(this_opt, "viafb_lcd_mode=", 15))
-			strict_strtoul(this_opt + 15, 0,
-				(unsigned long *)&viafb_lcd_mode);
-		else if (!strncmp(this_opt, "viafb_lcd_port=", 15))
+		else if (!strncmp(this_opt, "viafb_display_hardware_layout=", 30)) {
+			rv = kstrtoint(this_opt + 30, 0, &viafb_display_hardware_layout);
+			if (rv < 0)
+				return rv;
+		} else if (!strncmp(this_opt, "viafb_second_size=", 18)) {
+			rv = kstrtoint(this_opt + 18, 0, &viafb_second_size);
+			if (rv < 0)
+				return rv;
+		} else if (!strncmp(this_opt, "viafb_platform_epia_dvi=", 24)) {
+			rv = kstrtoint(this_opt + 24, 0, &viafb_platform_epia_dvi);
+			if (rv < 0)
+				return rv;
+		} else if (!strncmp(this_opt, "viafb_device_lcd_dualedge=", 26)) {
+			rv = kstrtoint(this_opt + 26, 0, &viafb_device_lcd_dualedge);
+			if (rv < 0)
+				return rv;
+		} else if (!strncmp(this_opt, "viafb_bus_width=", 16)) {
+			rv = kstrtoint(this_opt + 16, 0, &viafb_bus_width);
+			if (rv < 0)
+				return rv;
+		} else if (!strncmp(this_opt, "viafb_lcd_mode=", 15)) {
+			rv = kstrtoint(this_opt + 15, 0, &viafb_lcd_mode);
+			if (rv < 0)
+				return rv;
+		} else if (!strncmp(this_opt, "viafb_lcd_port=", 15))
 			viafb_lcd_port = kstrdup(this_opt + 15, GFP_KERNEL);
 		else if (!strncmp(this_opt, "viafb_dvi_port=", 15))
 			viafb_dvi_port = kstrdup(this_opt + 15, GFP_KERNEL);
@@ -2007,9 +2038,13 @@ int __init viafb_init(void)
 	u32 dummy;
 #ifndef MODULE
 	char *option = NULL;
+	int rv;
+
 	if (fb_get_options("viafb", &option))
 		return -ENODEV;
-	viafb_setup(option);
+	rv = viafb_setup(option);
+	if (rv < 0)
+		return rv;
 #endif
 	if (parse_mode(viafb_mode, &dummy, &dummy)
 		|| parse_mode(viafb_mode1, &dummy, &dummy)
diff --git a/drivers/video/wm8505fb.c b/drivers/video/wm8505fb.c
index 96e34a5..09f95ec 100644
--- a/drivers/video/wm8505fb.c
+++ b/drivers/video/wm8505fb.c
@@ -154,7 +154,7 @@ static ssize_t contrast_store(struct device *dev,
 	struct wm8505fb_info *fbi = to_wm8505fb_info(info);
 	unsigned long tmp;
 
-	if (strict_strtoul(buf, 10, &tmp) || (tmp > 0xff))
+	if (kstrtoul(buf, 10, &tmp) || (tmp > 0xff))
 		return -EINVAL;
 	fbi->contrast = tmp;
 
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 42/52] kstrtox: convert drivers/w1/
  2011-02-05 14:20 [PATCH 01/52] kstrtox: converting strings to integers done (hopefully) right Alexey Dobriyan
                   ` (39 preceding siblings ...)
  2011-02-05 14:20 ` [PATCH 41/52] kstrtox: convert drivers/video/ Alexey Dobriyan
@ 2011-02-05 14:20 ` Alexey Dobriyan
  2011-02-05 14:20 ` [PATCH 43/52] kstrtox: convert sound/ Alexey Dobriyan
                   ` (9 subsequent siblings)
  50 siblings, 0 replies; 58+ messages in thread
From: Alexey Dobriyan @ 2011-02-05 14:20 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, adobriyan


Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
 drivers/w1/w1.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index b7b5014..cd3d308 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -233,10 +233,10 @@ static ssize_t w1_master_attribute_store_search(struct device * dev,
 						struct device_attribute *attr,
 						const char * buf, size_t count)
 {
-	long tmp;
 	struct w1_master *md = dev_to_w1_master(dev);
+	int tmp;
 
-	if (strict_strtol(buf, 0, &tmp) == -EINVAL)
+	if (kstrtoint(buf, 0, &tmp) < 0)
 		return -EINVAL;
 
 	mutex_lock(&md->mutex);
@@ -265,10 +265,10 @@ static ssize_t w1_master_attribute_store_pullup(struct device *dev,
 						struct device_attribute *attr,
 						const char *buf, size_t count)
 {
-	long tmp;
 	struct w1_master *md = dev_to_w1_master(dev);
+	int tmp;
 
-	if (strict_strtol(buf, 0, &tmp) == -EINVAL)
+	if (kstrtoint(buf, 0, &tmp) < 0)
 		return -EINVAL;
 
 	mutex_lock(&md->mutex);
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 43/52] kstrtox: convert sound/
  2011-02-05 14:20 [PATCH 01/52] kstrtox: converting strings to integers done (hopefully) right Alexey Dobriyan
                   ` (40 preceding siblings ...)
  2011-02-05 14:20 ` [PATCH 42/52] kstrtox: convert drivers/w1/ Alexey Dobriyan
@ 2011-02-05 14:20 ` Alexey Dobriyan
  2011-02-05 14:20 ` [PATCH 44/52] kstrtox: convert net/ Alexey Dobriyan
                   ` (8 subsequent siblings)
  50 siblings, 0 replies; 58+ messages in thread
From: Alexey Dobriyan @ 2011-02-05 14:20 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, adobriyan


Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
 sound/drivers/dummy.c          |    2 +-
 sound/pci/hda/hda_hwdep.c      |   10 ++++------
 sound/pci/hda/patch_sigmatel.c |    7 ++-----
 sound/soc/codecs/wm8962.c      |    4 ++--
 sound/soc/soc-core.c           |    6 +++---
 5 files changed, 12 insertions(+), 17 deletions(-)

diff --git a/sound/drivers/dummy.c b/sound/drivers/dummy.c
index 7f41990..d3b1a02 100644
--- a/sound/drivers/dummy.c
+++ b/sound/drivers/dummy.c
@@ -953,7 +953,7 @@ static void dummy_proc_write(struct snd_info_entry *entry,
 		if (i >= ARRAY_SIZE(fields))
 			continue;
 		snd_info_get_str(item, ptr, sizeof(item));
-		if (strict_strtoull(item, 0, &val))
+		if (kstrtoull(item, 0, &val))
 			continue;
 		if (fields[i].size == sizeof(int))
 			*get_dummy_int_ptr(dummy, fields[i].offset) = val;
diff --git a/sound/pci/hda/hda_hwdep.c b/sound/pci/hda/hda_hwdep.c
index bf3ced5..ecc7edb 100644
--- a/sound/pci/hda/hda_hwdep.c
+++ b/sound/pci/hda/hda_hwdep.c
@@ -293,11 +293,11 @@ static ssize_t type##_store(struct device *dev,			\
 {								\
 	struct snd_hwdep *hwdep = dev_get_drvdata(dev);		\
 	struct hda_codec *codec = hwdep->private_data;		\
-	unsigned long val;					\
-	int err = strict_strtoul(buf, 0, &val);			\
+	int err;						\
+								\
+	err = kstrtou32(buf, 0, &codec->type);			\
 	if (err < 0)						\
 		return err;					\
-	codec->type = val;					\
 	return count;						\
 }
 
@@ -699,9 +699,7 @@ static void parse_chip_name_mode(char *buf, struct hda_bus *bus,
 static void parse_##name##_mode(char *buf, struct hda_bus *bus, \
 				 struct hda_codec **codecp) \
 { \
-	unsigned long val; \
-	if (!strict_strtoul(buf, 0, &val)) \
-		(*codecp)->name = val; \
+	kstrtou32(buf, 0, &(*codecp)->name); \
 }
 
 DEFINE_PARSE_ID_MODE(vendor_id);
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
index 9ea48b4..4ebbe64 100644
--- a/sound/pci/hda/patch_sigmatel.c
+++ b/sound/pci/hda/patch_sigmatel.c
@@ -4194,16 +4194,13 @@ static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
 				  int enable);
 
 static inline int get_int_hint(struct hda_codec *codec, const char *key,
-			       int *valp)
+			       unsigned int *val)
 {
 	const char *p;
 	p = snd_hda_get_hint(codec, key);
 	if (p) {
-		unsigned long val;
-		if (!strict_strtoul(p, 0, &val)) {
-			*valp = val;
+		if (kstrtouint(p, 0, val) == 0)
 			return 1;
-		}
 	}
 	return 0;
 }
diff --git a/sound/soc/codecs/wm8962.c b/sound/soc/codecs/wm8962.c
index b9cb1fc..996676f 100644
--- a/sound/soc/codecs/wm8962.c
+++ b/sound/soc/codecs/wm8962.c
@@ -3501,10 +3501,10 @@ static ssize_t wm8962_beep_set(struct device *dev,
 			       const char *buf, size_t count)
 {
 	struct wm8962_priv *wm8962 = dev_get_drvdata(dev);
-	long int time;
+	int time;
 	int ret;
 
-	ret = strict_strtol(buf, 10, &time);
+	ret = kstrtoint(buf, 10, &time);
 	if (ret != 0)
 		return ret;
 
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index bac7291..75f278d 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -151,7 +151,7 @@ static ssize_t pmdown_time_set(struct device *dev,
 			container_of(dev, struct snd_soc_pcm_runtime, dev);
 	int ret;
 
-	ret = strict_strtol(buf, 10, &rtd->pmdown_time);
+	ret = kstrtol(buf, 10, &rtd->pmdown_time);
 	if (ret)
 		return ret;
 
@@ -188,7 +188,7 @@ static ssize_t codec_reg_write_file(struct file *file,
 	char buf[32];
 	int buf_size;
 	char *start = buf;
-	unsigned long reg, value;
+	u32 reg, value;
 	int step = 1;
 	struct snd_soc_codec *codec = file->private_data;
 
@@ -207,7 +207,7 @@ static ssize_t codec_reg_write_file(struct file *file,
 		return -EINVAL;
 	while (*start == ' ')
 		start++;
-	if (strict_strtoul(start, 16, &value))
+	if (kstrtou32(start, 16, &value))
 		return -EINVAL;
 	snd_soc_write(codec, reg, value);
 	return buf_size;
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 44/52] kstrtox: convert net/
  2011-02-05 14:20 [PATCH 01/52] kstrtox: converting strings to integers done (hopefully) right Alexey Dobriyan
                   ` (41 preceding siblings ...)
  2011-02-05 14:20 ` [PATCH 43/52] kstrtox: convert sound/ Alexey Dobriyan
@ 2011-02-05 14:20 ` Alexey Dobriyan
  2011-02-05 14:20 ` [PATCH 45/52] kstrtox: convert arm Alexey Dobriyan
                   ` (7 subsequent siblings)
  50 siblings, 0 replies; 58+ messages in thread
From: Alexey Dobriyan @ 2011-02-05 14:20 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, adobriyan


Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
 net/batman-adv/bat_sysfs.c      |   69 ++++++++++++++++++++-------------------
 net/batman-adv/gateway_common.c |    4 +-
 net/bluetooth/hci_sysfs.c       |   16 ++++----
 net/dns_resolver/dns_key.c      |    5 ++-
 net/mac80211/debugfs.c          |   10 ++---
 net/rfkill/core.c               |   11 +++---
 net/sunrpc/addr.c               |   18 ++++------
 net/sunrpc/auth.c               |    6 ++--
 net/sunrpc/xprtsock.c           |    8 +++--
 9 files changed, 72 insertions(+), 75 deletions(-)

diff --git a/net/batman-adv/bat_sysfs.c b/net/batman-adv/bat_sysfs.c
index cd7bb51..12c8f8d 100644
--- a/net/batman-adv/bat_sysfs.c
+++ b/net/batman-adv/bat_sysfs.c
@@ -150,36 +150,36 @@ static int store_uint_attr(char *buff, size_t count,
 			   struct net_device *net_dev, char *attr_name,
 			   unsigned int min, unsigned int max, atomic_t *attr)
 {
-	unsigned long uint_val;
+	unsigned int val;
 	int ret;
 
-	ret = strict_strtoul(buff, 10, &uint_val);
-	if (ret) {
+	ret = kstrtouint(buff, 10, &val);
+	if (ret < 0) {
 		bat_info(net_dev,
 			 "%s: Invalid parameter received: %s\n",
 			 attr_name, buff);
-		return -EINVAL;
+		return ret;
 	}
 
-	if (uint_val < min) {
-		bat_info(net_dev, "%s: Value is too small: %lu min: %u\n",
-			 attr_name, uint_val, min);
+	if (val < min) {
+		bat_info(net_dev, "%s: Value is too small: %u min: %u\n",
+			 attr_name, val, min);
 		return -EINVAL;
 	}
 
-	if (uint_val > max) {
-		bat_info(net_dev, "%s: Value is too big: %lu max: %u\n",
-			 attr_name, uint_val, max);
+	if (val > max) {
+		bat_info(net_dev, "%s: Value is too big: %u max: %u\n",
+			 attr_name, val, max);
 		return -EINVAL;
 	}
 
-	if (atomic_read(attr) == uint_val)
+	if (atomic_read(attr) == val)
 		return count;
 
-	bat_info(net_dev, "%s: Changing from: %i to: %lu\n",
-		 attr_name, atomic_read(attr), uint_val);
+	bat_info(net_dev, "%s: Changing from: %i to: %u\n",
+		 attr_name, atomic_read(attr), val);
 
-	atomic_set(attr, uint_val);
+	atomic_set(attr, val);
 	return count;
 }
 
@@ -211,32 +211,33 @@ static ssize_t show_vis_mode(struct kobject *kobj, struct attribute *attr,
 }
 
 static ssize_t store_vis_mode(struct kobject *kobj, struct attribute *attr,
-			      char *buff, size_t count)
+			      char *buf, size_t count)
 {
 	struct net_device *net_dev = kobj_to_netdev(kobj);
 	struct bat_priv *bat_priv = netdev_priv(net_dev);
-	unsigned long val;
-	int ret, vis_mode_tmp = -1;
+	unsigned int vis_mode_tmp;
 
-	ret = strict_strtoul(buff, 10, &val);
+	if (count > 0 && buf[count - 1] == '\n')
+		buf[count - 1] = '\0';
 
-	if (((count == 2) && (!ret) && (val == VIS_TYPE_CLIENT_UPDATE)) ||
-	    (strncmp(buff, "client", 6) == 0) ||
-	    (strncmp(buff, "off", 3) == 0))
+	if (strcmp(buf, "client") == 0 || strcmp(buf, "off") == 0)
 		vis_mode_tmp = VIS_TYPE_CLIENT_UPDATE;
-
-	if (((count == 2) && (!ret) && (val == VIS_TYPE_SERVER_SYNC)) ||
-	    (strncmp(buff, "server", 6) == 0))
+	else if (strcmp(buf, "server") == 0)
 		vis_mode_tmp = VIS_TYPE_SERVER_SYNC;
-
-	if (vis_mode_tmp < 0) {
-		if (buff[count - 1] == '\n')
-			buff[count - 1] = '\0';
-
-		bat_info(net_dev,
-			 "Invalid parameter for 'vis mode' setting received: "
-			 "%s\n", buff);
-		return -EINVAL;
+	else {
+		unsigned int val;
+		int rv;
+
+		rv = kstrtoint(buf, 10, &val);
+		if (rv < 0)
+			return rv;
+		switch (val) {
+		case VIS_TYPE_CLIENT_UPDATE:
+		case VIS_TYPE_SERVER_SYNC:
+			vis_mode_tmp = val;
+		default:
+			return -EINVAL;
+		}
 	}
 
 	if (atomic_read(&bat_priv->vis_mode) == vis_mode_tmp)
@@ -247,7 +248,7 @@ static ssize_t store_vis_mode(struct kobject *kobj, struct attribute *attr,
 		 "client" : "server", vis_mode_tmp == VIS_TYPE_CLIENT_UPDATE ?
 		 "client" : "server");
 
-	atomic_set(&bat_priv->vis_mode, (unsigned)vis_mode_tmp);
+	atomic_set(&bat_priv->vis_mode, vis_mode_tmp);
 	return count;
 }
 
diff --git a/net/batman-adv/gateway_common.c b/net/batman-adv/gateway_common.c
index b962982..b201e41 100644
--- a/net/batman-adv/gateway_common.c
+++ b/net/batman-adv/gateway_common.c
@@ -96,7 +96,7 @@ static bool parse_gw_bandwidth(struct net_device *net_dev, char *buff,
 			*tmp_ptr = '\0';
 	}
 
-	ret = strict_strtoul(buff, 10, down);
+	ret = kstrtoul(buff, 10, down);
 	if (ret) {
 		bat_err(net_dev,
 			"Download speed of gateway mode invalid: %s\n",
@@ -121,7 +121,7 @@ static bool parse_gw_bandwidth(struct net_device *net_dev, char *buff,
 				*tmp_ptr = '\0';
 		}
 
-		ret = strict_strtoul(slash_ptr + 1, 10, up);
+		ret = kstrtoul(slash_ptr + 1, 10, up);
 		if (ret) {
 			bat_err(net_dev,
 				"Upload speed of gateway mode invalid: "
diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c
index 5fce3d6..131ce95 100644
--- a/net/bluetooth/hci_sysfs.c
+++ b/net/bluetooth/hci_sysfs.c
@@ -277,9 +277,9 @@ static ssize_t show_idle_timeout(struct device *dev, struct device_attribute *at
 static ssize_t store_idle_timeout(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
 {
 	struct hci_dev *hdev = dev_get_drvdata(dev);
-	unsigned long val;
+	u32 val;
 
-	if (strict_strtoul(buf, 0, &val) < 0)
+	if (kstrtou32(buf, 0, &val) < 0)
 		return -EINVAL;
 
 	if (val != 0 && (val < 500 || val > 3600000))
@@ -299,12 +299,12 @@ static ssize_t show_sniff_max_interval(struct device *dev, struct device_attribu
 static ssize_t store_sniff_max_interval(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
 {
 	struct hci_dev *hdev = dev_get_drvdata(dev);
-	unsigned long val;
+	u16 val;
 
-	if (strict_strtoul(buf, 0, &val) < 0)
+	if (kstrtou16(buf, 0, &val) < 0)
 		return -EINVAL;
 
-	if (val < 0x0002 || val > 0xFFFE || val % 2)
+	if (val == 0 || val % 2)
 		return -EINVAL;
 
 	if (val < hdev->sniff_min_interval)
@@ -324,12 +324,12 @@ static ssize_t show_sniff_min_interval(struct device *dev, struct device_attribu
 static ssize_t store_sniff_min_interval(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
 {
 	struct hci_dev *hdev = dev_get_drvdata(dev);
-	unsigned long val;
+	u16 val;
 
-	if (strict_strtoul(buf, 0, &val) < 0)
+	if (kstrtou16(buf, 0, &val) < 0)
 		return -EINVAL;
 
-	if (val < 0x0002 || val > 0xFFFE || val % 2)
+	if (val == 0 || val % 2)
 		return -EINVAL;
 
 	if (val > hdev->sniff_max_interval)
diff --git a/net/dns_resolver/dns_key.c b/net/dns_resolver/dns_key.c
index 739435a..8cd5294 100644
--- a/net/dns_resolver/dns_key.c
+++ b/net/dns_resolver/dns_key.c
@@ -62,7 +62,6 @@ static int
 dns_resolver_instantiate(struct key *key, const void *_data, size_t datalen)
 {
 	struct user_key_payload *upayload;
-	unsigned long derrno;
 	int ret;
 	size_t result_len = 0;
 	const char *data = _data, *end, *opt;
@@ -113,11 +112,13 @@ dns_resolver_instantiate(struct key *key, const void *_data, size_t datalen)
 			 * that's to be recorded as the result in this key */
 			if (opt_nlen == sizeof(DNS_ERRORNO_OPTION) - 1 &&
 			    memcmp(opt, DNS_ERRORNO_OPTION, opt_nlen) == 0) {
+				unsigned long derrno;
+
 				kdebug("dns error number option");
 				if (opt_vlen <= 0)
 					goto bad_option_value;
 
-				ret = strict_strtoul(eq, 10, &derrno);
+				ret = kstrtoul(eq, 10, &derrno);
 				if (ret < 0)
 					goto bad_option_value;
 
diff --git a/net/mac80211/debugfs.c b/net/mac80211/debugfs.c
index 1f02e59..81f8790 100644
--- a/net/mac80211/debugfs.c
+++ b/net/mac80211/debugfs.c
@@ -186,7 +186,7 @@ static ssize_t uapsd_queues_write(struct file *file,
 				  size_t count, loff_t *ppos)
 {
 	struct ieee80211_local *local = file->private_data;
-	unsigned long val;
+	unsigned int val;
 	char buf[10];
 	size_t len;
 	int ret;
@@ -196,8 +196,7 @@ static ssize_t uapsd_queues_write(struct file *file,
 		return -EFAULT;
 	buf[len] = '\0';
 
-	ret = strict_strtoul(buf, 0, &val);
-
+	ret = kstrtouint(buf, 0, &val);
 	if (ret)
 		return -EINVAL;
 
@@ -230,7 +229,7 @@ static ssize_t uapsd_max_sp_len_write(struct file *file,
 				      size_t count, loff_t *ppos)
 {
 	struct ieee80211_local *local = file->private_data;
-	unsigned long val;
+	unsigned int val;
 	char buf[10];
 	size_t len;
 	int ret;
@@ -240,8 +239,7 @@ static ssize_t uapsd_max_sp_len_write(struct file *file,
 		return -EFAULT;
 	buf[len] = '\0';
 
-	ret = strict_strtoul(buf, 0, &val);
-
+	ret = kstrtouint(buf, 0, &val);
 	if (ret)
 		return -EINVAL;
 
diff --git a/net/rfkill/core.c b/net/rfkill/core.c
index 0198191..0a69c82 100644
--- a/net/rfkill/core.c
+++ b/net/rfkill/core.c
@@ -638,17 +638,16 @@ static ssize_t rfkill_soft_store(struct device *dev,
 				  const char *buf, size_t count)
 {
 	struct rfkill *rfkill = to_rfkill(dev);
-	unsigned long state;
+	unsigned int state;
 	int err;
 
 	if (!capable(CAP_NET_ADMIN))
 		return -EPERM;
 
-	err = strict_strtoul(buf, 0, &state);
+	err = kstrtouint(buf, 0, &state);
 	if (err)
 		return err;
-
-	if (state > 1 )
+	if (state > 1)
 		return -EINVAL;
 
 	mutex_lock(&rfkill_global_mutex);
@@ -682,13 +681,13 @@ static ssize_t rfkill_state_store(struct device *dev,
 				  const char *buf, size_t count)
 {
 	struct rfkill *rfkill = to_rfkill(dev);
-	unsigned long state;
+	int state;
 	int err;
 
 	if (!capable(CAP_NET_ADMIN))
 		return -EPERM;
 
-	err = strict_strtoul(buf, 0, &state);
+	err = kstrtoint(buf, 0, &state);
 	if (err)
 		return err;
 
diff --git a/net/sunrpc/addr.c b/net/sunrpc/addr.c
index 1419d0c..36c554c 100644
--- a/net/sunrpc/addr.c
+++ b/net/sunrpc/addr.c
@@ -173,15 +173,15 @@ static int rpc_parse_scope_id(const char *buf, const size_t buflen,
 	len = (buf + buflen) - delim - 1;
 	p = kstrndup(delim + 1, len, GFP_KERNEL);
 	if (p) {
-		unsigned long scope_id = 0;
 		struct net_device *dev;
+		u32 scope_id;
 
 		dev = dev_get_by_name(&init_net, p);
 		if (dev != NULL) {
 			scope_id = dev->ifindex;
 			dev_put(dev);
 		} else {
-			if (strict_strtoul(p, 10, &scope_id) == 0) {
+			if (kstrtou32(p, 10, &scope_id) < 0) {
 				kfree(p);
 				return 0;
 			}
@@ -299,7 +299,7 @@ EXPORT_SYMBOL_GPL(rpc_sockaddr2uaddr);
  * @sap: buffer into which to plant socket address
  * @salen: size of buffer
  *
- * @uaddr does not have to be '\0'-terminated, but strict_strtoul() and
+ * @uaddr does not have to be '\0'-terminated, but kstrto*() and
  * rpc_pton() require proper string termination to be successful.
  *
  * Returns the size of the socket address if successful; otherwise
@@ -309,7 +309,7 @@ size_t rpc_uaddr2sockaddr(const char *uaddr, const size_t uaddr_len,
 			  struct sockaddr *sap, const size_t salen)
 {
 	char *c, buf[RPCBIND_MAXUADDRLEN + sizeof('\0')];
-	unsigned long portlo, porthi;
+	u8 portlo, porthi;
 	unsigned short port;
 
 	if (uaddr_len > RPCBIND_MAXUADDRLEN)
@@ -321,21 +321,17 @@ size_t rpc_uaddr2sockaddr(const char *uaddr, const size_t uaddr_len,
 	c = strrchr(buf, '.');
 	if (unlikely(c == NULL))
 		return 0;
-	if (unlikely(strict_strtoul(c + 1, 10, &portlo) != 0))
-		return 0;
-	if (unlikely(portlo > 255))
+	if (unlikely(kstrtou8(c + 1, 10, &portlo) != 0))
 		return 0;
 
 	*c = '\0';
 	c = strrchr(buf, '.');
 	if (unlikely(c == NULL))
 		return 0;
-	if (unlikely(strict_strtoul(c + 1, 10, &porthi) != 0))
-		return 0;
-	if (unlikely(porthi > 255))
+	if (unlikely(kstrtou8(c + 1, 10, &porthi) != 0))
 		return 0;
 
-	port = (unsigned short)((porthi << 8) | portlo);
+	port = (porthi << 8) | portlo;
 
 	*c = '\0';
 	if (rpc_pton(buf, strlen(buf), sap, salen) == 0)
diff --git a/net/sunrpc/auth.c b/net/sunrpc/auth.c
index 67e3127..800152f 100644
--- a/net/sunrpc/auth.c
+++ b/net/sunrpc/auth.c
@@ -47,9 +47,9 @@ static int param_set_hashtbl_sz(const char *val, const struct kernel_param *kp)
 
 	if (!val)
 		goto out_inval;
-	ret = strict_strtoul(val, 0, &num);
-	if (ret == -EINVAL)
-		goto out_inval;
+	ret = kstrtoul(val, 0, &num);
+	if (ret < 0)
+		return ret;
 	nbits = fls(num);
 	if (num > (1U << nbits))
 		nbits++;
diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
index c431f5a..01d15ec2 100644
--- a/net/sunrpc/xprtsock.c
+++ b/net/sunrpc/xprtsock.c
@@ -2499,13 +2499,15 @@ static int param_set_uint_minmax(const char *val,
 		const struct kernel_param *kp,
 		unsigned int min, unsigned int max)
 {
-	unsigned long num;
+	unsigned int num;
 	int ret;
 
 	if (!val)
 		return -EINVAL;
-	ret = strict_strtoul(val, 0, &num);
-	if (ret == -EINVAL || num < min || num > max)
+	ret = kstrtouint(val, 0, &num);
+	if (ret < 0)
+		return ret;
+	if (num < min || num > max)
 		return -EINVAL;
 	*((unsigned int *)kp->arg) = num;
 	return 0;
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 45/52] kstrtox: convert arm
  2011-02-05 14:20 [PATCH 01/52] kstrtox: converting strings to integers done (hopefully) right Alexey Dobriyan
                   ` (42 preceding siblings ...)
  2011-02-05 14:20 ` [PATCH 44/52] kstrtox: convert net/ Alexey Dobriyan
@ 2011-02-05 14:20 ` Alexey Dobriyan
  2011-02-05 14:20 ` [PATCH 46/52] kstrtox: convert microblaze Alexey Dobriyan
                   ` (6 subsequent siblings)
  50 siblings, 0 replies; 58+ messages in thread
From: Alexey Dobriyan @ 2011-02-05 14:20 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, adobriyan

In arch/arm/mach-omap2/board-omap3touchbook.c:
remove "tbr" parameter, it's unused.

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
 arch/arm/mach-omap2/board-omap3touchbook.c |   11 -----------
 arch/arm/mach-omap2/mux.c                  |   15 ++++++---------
 arch/arm/mach-pxa/balloon3.c               |    2 +-
 arch/arm/mach-pxa/viper.c                  |    3 +--
 arch/arm/mach-s3c2412/mach-jive.c          |    2 +-
 arch/arm/mach-ux500/mbox-db5500.c          |   27 ++++++++-------------------
 arch/arm/mach-w90x900/cpu.c                |    5 +++--
 arch/arm/plat-omap/mcbsp.c                 |    4 ++--
 8 files changed, 22 insertions(+), 47 deletions(-)

diff --git a/arch/arm/mach-omap2/board-omap3touchbook.c b/arch/arm/mach-omap2/board-omap3touchbook.c
index db1f74f..16f334f 100644
--- a/arch/arm/mach-omap2/board-omap3touchbook.c
+++ b/arch/arm/mach-omap2/board-omap3touchbook.c
@@ -62,8 +62,6 @@
 #define TB_BL_PWM_TIMER		9
 #define TB_KILL_POWER_GPIO	168
 
-static unsigned long touchbook_revision;
-
 static struct mtd_partition omap3touchbook_nand_partitions[] = {
 	/* All the partition sizes are listed in terms of NAND block size */
 	{
@@ -493,15 +491,6 @@ static void omap3_touchbook_poweroff(void)
 	gpio_direction_output(TB_KILL_POWER_GPIO, 0);
 }
 
-static int __init early_touchbook_revision(char *p)
-{
-	if (!p)
-		return 0;
-
-	return strict_strtoul(p, 10, &touchbook_revision);
-}
-early_param("tbr", early_touchbook_revision);
-
 static struct omap_musb_board_data musb_board_data = {
 	.interface_type		= MUSB_INTERFACE_ULPI,
 	.mode			= MUSB_OTG,
diff --git a/arch/arm/mach-omap2/mux.c b/arch/arm/mach-omap2/mux.c
index fae49d1..ab5087a 100644
--- a/arch/arm/mach-omap2/mux.c
+++ b/arch/arm/mach-omap2/mux.c
@@ -548,7 +548,7 @@ static ssize_t omap_mux_dbg_signal_write(struct file *file,
 	char buf[OMAP_MUX_MAX_ARG_CHAR];
 	struct seq_file *seqf;
 	struct omap_mux *m;
-	unsigned long val;
+	u16 val;
 	int buf_size, ret;
 	struct omap_mux_partition *partition;
 
@@ -561,13 +561,10 @@ static ssize_t omap_mux_dbg_signal_write(struct file *file,
 	if (copy_from_user(buf, user_buf, buf_size))
 		return -EFAULT;
 
-	ret = strict_strtoul(buf, 0x10, &val);
+	ret = kstrtou16(buf, 0x10, &val);
 	if (ret < 0)
 		return ret;
 
-	if (val > 0xffff)
-		return -EINVAL;
-
 	seqf = file->private_data;
 	m = seqf->private;
 
@@ -575,7 +572,7 @@ static ssize_t omap_mux_dbg_signal_write(struct file *file,
 	if (!partition)
 		return -ENODEV;
 
-	omap_mux_write(partition, (u16)val, m->reg_offset);
+	omap_mux_write(partition, val, m->reg_offset);
 	*ppos += count;
 
 	return count;
@@ -770,18 +767,18 @@ static void __init omap_mux_set_cmdline_signals(void)
 
 	while ((token = strsep(&next_opt, ",")) != NULL) {
 		char *keyval, *name;
-		unsigned long val;
 
 		keyval = token;
 		name = strsep(&keyval, "=");
 		if (name) {
+			u16 val;
 			int res;
 
-			res = strict_strtoul(keyval, 0x10, &val);
+			res = kstrtou16(keyval, 0x10, &val);
 			if (res < 0)
 				continue;
 
-			omap_mux_init_signal(name, (u16)val);
+			omap_mux_init_signal(name, val);
 		}
 	}
 
diff --git a/arch/arm/mach-pxa/balloon3.c b/arch/arm/mach-pxa/balloon3.c
index a134a14..077fdc0 100644
--- a/arch/arm/mach-pxa/balloon3.c
+++ b/arch/arm/mach-pxa/balloon3.c
@@ -91,7 +91,7 @@ int __init parse_balloon3_features(char *arg)
 	if (!arg)
 		return 0;
 
-	return strict_strtoul(arg, 0, &balloon3_features_present);
+	return kstrtoul(arg, 0, &balloon3_features_present);
 }
 early_param("balloon3_features", parse_balloon3_features);
 
diff --git a/arch/arm/mach-pxa/viper.c b/arch/arm/mach-pxa/viper.c
index 49eeeab..bed35b8 100644
--- a/arch/arm/mach-pxa/viper.c
+++ b/arch/arm/mach-pxa/viper.c
@@ -767,8 +767,7 @@ static unsigned long viper_tpm;
 
 static int __init viper_tpm_setup(char *str)
 {
-	strict_strtoul(str, 10, &viper_tpm);
-	return 1;
+	return !kstrtoul(str, 10, &viper_tpm);
 }
 
 __setup("tpm=", viper_tpm_setup);
diff --git a/arch/arm/mach-s3c2412/mach-jive.c b/arch/arm/mach-s3c2412/mach-jive.c
index 923e01b..a21b119 100644
--- a/arch/arm/mach-s3c2412/mach-jive.c
+++ b/arch/arm/mach-s3c2412/mach-jive.c
@@ -240,7 +240,7 @@ static int __init jive_mtdset(char *options)
 	if (options == NULL || options[0] == '\0')
 		return 0;
 
-	if (strict_strtoul(options, 10, &set)) {
+	if (kstrtoul(options, 10, &set)) {
 		printk(KERN_ERR "failed to parse mtdset=%s\n", options);
 		return 0;
 	}
diff --git a/arch/arm/mach-ux500/mbox-db5500.c b/arch/arm/mach-ux500/mbox-db5500.c
index cbf1571..9c7b832 100644
--- a/arch/arm/mach-ux500/mbox-db5500.c
+++ b/arch/arm/mach-ux500/mbox-db5500.c
@@ -122,29 +122,18 @@ static ssize_t mbox_write_fifo(struct device *dev,
 			       const char *buf,
 			       size_t count)
 {
-	unsigned long mbox_mess;
-	unsigned long nbr_sends;
-	unsigned long i;
-	char int_buf[16];
-	char *token;
-	char *val;
-
 	struct mbox *mbox = (struct mbox *) dev->platform_data;
+	unsigned int mbox_mess, nbr_sends;
+	unsigned int i;
 
-	strncpy((char *) &int_buf, buf, sizeof(int_buf));
-	token = (char *) &int_buf;
-
-	/* Parse message */
-	val = strsep(&token, " ");
-	if ((val == NULL) || (strict_strtoul(val, 16, &mbox_mess) != 0))
-		mbox_mess = 0xDEADBEEF;
-
-	val = strsep(&token, " ");
-	if ((val == NULL) || (strict_strtoul(val, 10, &nbr_sends) != 0))
+	if (sscanf(buf, "%u %u", &mbox_mess, &nbr_sends) != 2) {
 		nbr_sends = 1;
+		if (sscanf(buf, "%u", &mbox_mess) != 1)
+			return -EINVAL;
+	}
 
-	dev_dbg(dev, "Will write 0x%lX %ld times using data struct at 0x%X\n",
-		mbox_mess, nbr_sends, (u32) mbox);
+	dev_dbg(dev, "Will write 0x%X %u times using data struct at %p\n",
+		mbox_mess, nbr_sends, mbox);
 
 	for (i = 0; i < nbr_sends; i++)
 		mbox_send(mbox, mbox_mess, true);
diff --git a/arch/arm/mach-w90x900/cpu.c b/arch/arm/mach-w90x900/cpu.c
index 83c5632..67f015c 100644
--- a/arch/arm/mach-w90x900/cpu.c
+++ b/arch/arm/mach-w90x900/cpu.c
@@ -170,12 +170,13 @@ static int __init nuc900_set_clkval(unsigned int cpufreq)
 }
 static int __init nuc900_set_cpufreq(char *str)
 {
-	unsigned long cpufreq, val;
+	unsigned int cpufreq, val;
 
 	if (!*str)
 		return 0;
 
-	strict_strtoul(str, 0, &cpufreq);
+	if (kstrtouint(str, 0, &cpufreq) < 0)
+		return 0;
 
 	nuc900_clock_source(NULL, "ext");
 
diff --git a/arch/arm/plat-omap/mcbsp.c b/arch/arm/plat-omap/mcbsp.c
index b5a6e17..09e4015 100644
--- a/arch/arm/plat-omap/mcbsp.c
+++ b/arch/arm/plat-omap/mcbsp.c
@@ -1485,10 +1485,10 @@ static ssize_t prop##_store(struct device *dev,				\
 				const char *buf, size_t size)		\
 {									\
 	struct omap_mcbsp *mcbsp = dev_get_drvdata(dev);		\
-	unsigned long val;						\
+	u16 val;							\
 	int status;							\
 									\
-	status = strict_strtoul(buf, 0, &val);				\
+	status = kstrtou16(buf, 0, &val);				\
 	if (status)							\
 		return status;						\
 									\
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 46/52] kstrtox: convert microblaze
  2011-02-05 14:20 [PATCH 01/52] kstrtox: converting strings to integers done (hopefully) right Alexey Dobriyan
                   ` (43 preceding siblings ...)
  2011-02-05 14:20 ` [PATCH 45/52] kstrtox: convert arm Alexey Dobriyan
@ 2011-02-05 14:20 ` Alexey Dobriyan
  2011-02-10 13:55   ` Michal Simek
  2011-02-05 14:20 ` [PATCH 47/52] kstrtox: convert mips Alexey Dobriyan
                   ` (5 subsequent siblings)
  50 siblings, 1 reply; 58+ messages in thread
From: Alexey Dobriyan @ 2011-02-05 14:20 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, adobriyan


Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
 arch/microblaze/kernel/traps.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/microblaze/kernel/traps.c b/arch/microblaze/kernel/traps.c
index ba034d4..ac81870 100644
--- a/arch/microblaze/kernel/traps.c
+++ b/arch/microblaze/kernel/traps.c
@@ -27,7 +27,7 @@ static unsigned long kstack_depth_to_print;	/* 0 == entire stack */
 
 static int __init kstack_setup(char *s)
 {
-	return !strict_strtoul(s, 0, &kstack_depth_to_print);
+	return !kstrtoul(s, 0, &kstack_depth_to_print);
 }
 __setup("kstack=", kstack_setup);
 
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 47/52] kstrtox: convert mips
  2011-02-05 14:20 [PATCH 01/52] kstrtox: converting strings to integers done (hopefully) right Alexey Dobriyan
                   ` (44 preceding siblings ...)
  2011-02-05 14:20 ` [PATCH 46/52] kstrtox: convert microblaze Alexey Dobriyan
@ 2011-02-05 14:20 ` Alexey Dobriyan
  2011-02-05 14:20 ` [PATCH 48/52] kstrtox: convert powerpc Alexey Dobriyan
                   ` (4 subsequent siblings)
  50 siblings, 0 replies; 58+ messages in thread
From: Alexey Dobriyan @ 2011-02-05 14:20 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, adobriyan


Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
 arch/mips/alchemy/devboards/pm.c   |    6 ++----
 arch/mips/alchemy/devboards/prom.c |    2 +-
 arch/mips/alchemy/gpr/init.c       |    2 +-
 arch/mips/alchemy/mtx-1/init.c     |    2 +-
 arch/mips/alchemy/xxs1500/init.c   |    2 +-
 arch/mips/loongson/common/env.c    |    3 +--
 arch/mips/pci/ops-tx4927.c         |    9 +++------
 arch/mips/txx9/generic/setup.c     |    4 +---
 8 files changed, 11 insertions(+), 19 deletions(-)

diff --git a/arch/mips/alchemy/devboards/pm.c b/arch/mips/alchemy/devboards/pm.c
index acaf91b..a833f94 100644
--- a/arch/mips/alchemy/devboards/pm.c
+++ b/arch/mips/alchemy/devboards/pm.c
@@ -158,12 +158,10 @@ static ssize_t db1x_pmattr_store(struct kobject *kobj,
 	int tmp;
 
 	if (ATTRCMP(timer_timeout)) {
-		tmp = strict_strtoul(instr, 0, &l);
+		tmp = kstrtoul(instr, 0, &db1x_pm_sleep_secs);
 		if (tmp)
 			return tmp;
 
-		db1x_pm_sleep_secs = l;
-
 	} else if (ATTRCMP(timer)) {
 		if (instr[0] != '0')
 			db1x_pm_wakemsk |= SYS_WAKEMSK_M2;
@@ -181,7 +179,7 @@ static ssize_t db1x_pmattr_store(struct kobject *kobj,
 		}
 
 	} else if (ATTRCMP(wakemsk)) {
-		tmp = strict_strtoul(instr, 0, &l);
+		tmp = kstrtoul(instr, 0, &l);
 		if (tmp)
 			return tmp;
 
diff --git a/arch/mips/alchemy/devboards/prom.c b/arch/mips/alchemy/devboards/prom.c
index baeb213..e02e0eb 100644
--- a/arch/mips/alchemy/devboards/prom.c
+++ b/arch/mips/alchemy/devboards/prom.c
@@ -54,7 +54,7 @@ void __init prom_init(void)
 
 	prom_init_cmdline();
 	memsize_str = prom_getenv("memsize");
-	if (!memsize_str || strict_strtoul(memsize_str, 0, &memsize))
+	if (!memsize_str || kstrtoul(memsize_str, 0, &memsize))
 		memsize = ALCHEMY_BOARD_DEFAULT_MEMSIZE;
 
 	add_memory_region(0, memsize, BOOT_MEM_RAM);
diff --git a/arch/mips/alchemy/gpr/init.c b/arch/mips/alchemy/gpr/init.c
index f044f4c..a4208de 100644
--- a/arch/mips/alchemy/gpr/init.c
+++ b/arch/mips/alchemy/gpr/init.c
@@ -53,7 +53,7 @@ void __init prom_init(void)
 	if (!memsize_str)
 		memsize = 0x04000000;
 	else
-		strict_strtoul(memsize_str, 0, &memsize);
+		kstrtoul(memsize_str, 0, &memsize);
 	add_memory_region(0, memsize, BOOT_MEM_RAM);
 }
 
diff --git a/arch/mips/alchemy/mtx-1/init.c b/arch/mips/alchemy/mtx-1/init.c
index f8d2557..f55f21d 100644
--- a/arch/mips/alchemy/mtx-1/init.c
+++ b/arch/mips/alchemy/mtx-1/init.c
@@ -56,7 +56,7 @@ void __init prom_init(void)
 	if (!memsize_str)
 		memsize = 0x04000000;
 	else
-		strict_strtoul(memsize_str, 0, &memsize);
+		kstrtoul(memsize_str, 0, &memsize);
 	add_memory_region(0, memsize, BOOT_MEM_RAM);
 }
 
diff --git a/arch/mips/alchemy/xxs1500/init.c b/arch/mips/alchemy/xxs1500/init.c
index 15125c2..8915bf4 100644
--- a/arch/mips/alchemy/xxs1500/init.c
+++ b/arch/mips/alchemy/xxs1500/init.c
@@ -54,7 +54,7 @@ void __init prom_init(void)
 	if (!memsize_str)
 		memsize = 0x04000000;
 	else
-		strict_strtoul(memsize_str, 0, &memsize);
+		kstrtoul(memsize_str, 0, &memsize);
 	add_memory_region(0, memsize, BOOT_MEM_RAM);
 }
 
diff --git a/arch/mips/loongson/common/env.c b/arch/mips/loongson/common/env.c
index 11b193f..49811e1 100644
--- a/arch/mips/loongson/common/env.c
+++ b/arch/mips/loongson/common/env.c
@@ -29,9 +29,8 @@ unsigned long memsize, highmemsize;
 
 #define parse_even_earlier(res, option, p)				\
 do {									\
-	int ret;							\
 	if (strncmp(option, (char *)p, strlen(option)) == 0)		\
-		ret = strict_strtol((char *)p + strlen(option"="), 10, &res); \
+		kstrtol((char *)p + strlen(option"="), 10, &res);	\
 } while (0)
 
 void __init prom_init_env(void)
diff --git a/arch/mips/pci/ops-tx4927.c b/arch/mips/pci/ops-tx4927.c
index a1e7e6d..0af3d73 100644
--- a/arch/mips/pci/ops-tx4927.c
+++ b/arch/mips/pci/ops-tx4927.c
@@ -202,18 +202,15 @@ char *__devinit tx4927_pcibios_setup(char *str)
 	unsigned long val;
 
 	if (!strncmp(str, "trdyto=", 7)) {
-		if (strict_strtoul(str + 7, 0, &val) == 0)
-			tx4927_pci_opts.trdyto = val;
+		kstrtou8(str + 7, 0, &tx4927_pci_opts.trdyto);
 		return NULL;
 	}
 	if (!strncmp(str, "retryto=", 8)) {
-		if (strict_strtoul(str + 8, 0, &val) == 0)
-			tx4927_pci_opts.retryto = val;
+		kstrtou8(str + 8, 0, &tx4927_pci_opts.retryto);
 		return NULL;
 	}
 	if (!strncmp(str, "gbwc=", 5)) {
-		if (strict_strtoul(str + 5, 0, &val) == 0)
-			tx4927_pci_opts.gbwc = val;
+		kstrtou16(str + 5, 0, &tx4927_pci_opts.gbwc);
 		return NULL;
 	}
 	return str;
diff --git a/arch/mips/txx9/generic/setup.c b/arch/mips/txx9/generic/setup.c
index 812816c..700f299 100644
--- a/arch/mips/txx9/generic/setup.c
+++ b/arch/mips/txx9/generic/setup.c
@@ -308,9 +308,7 @@ static void __init preprocess_cmdline(void)
 			txx9_board_vec = find_board_byname(str + 6);
 			continue;
 		} else if (strncmp(str, "masterclk=", 10) == 0) {
-			unsigned long val;
-			if (strict_strtoul(str + 10, 10, &val) == 0)
-				txx9_master_clock = val;
+			kstrtouint(str + 10, 10, &txx9_master_clock);
 			continue;
 		} else if (strcmp(str, "icdisable") == 0) {
 			txx9_ic_disable = 1;
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 48/52] kstrtox: convert powerpc
  2011-02-05 14:20 [PATCH 01/52] kstrtox: converting strings to integers done (hopefully) right Alexey Dobriyan
                   ` (45 preceding siblings ...)
  2011-02-05 14:20 ` [PATCH 47/52] kstrtox: convert mips Alexey Dobriyan
@ 2011-02-05 14:20 ` Alexey Dobriyan
  2011-02-05 14:20 ` [PATCH 49/52] kstrtox: convert s390 Alexey Dobriyan
                   ` (3 subsequent siblings)
  50 siblings, 0 replies; 58+ messages in thread
From: Alexey Dobriyan @ 2011-02-05 14:20 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, adobriyan


Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
 arch/powerpc/kernel/setup_64.c            |    6 +++---
 arch/powerpc/kernel/vio.c                 |    4 ++--
 arch/powerpc/platforms/pseries/dlpar.c    |    4 ++--
 arch/powerpc/platforms/pseries/mobility.c |    2 +-
 arch/powerpc/sysdev/fsl_85xx_l2ctlr.c     |    8 ++++----
 5 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
index 5a0401f..1e05bfc 100644
--- a/arch/powerpc/kernel/setup_64.c
+++ b/arch/powerpc/kernel/setup_64.c
@@ -113,13 +113,13 @@ static void check_smt_enabled(void)
 		else if (!strcmp(smt_enabled_cmdline, "off"))
 			smt_enabled_at_boot = 0;
 		else {
-			long smt;
+			int smt;
 			int rc;
 
-			rc = strict_strtol(smt_enabled_cmdline, 10, &smt);
+			rc = kstrtoint(smt_enabled_cmdline, 10, &smt);
 			if (!rc)
 				smt_enabled_at_boot =
-					min(threads_per_core, (int)smt);
+					min(threads_per_core, smt);
 		}
 	} else {
 		dn = of_find_node_by_path("/options");
diff --git a/arch/powerpc/kernel/vio.c b/arch/powerpc/kernel/vio.c
index 1b695fd..c69d76f 100644
--- a/arch/powerpc/kernel/vio.c
+++ b/arch/powerpc/kernel/vio.c
@@ -946,10 +946,10 @@ static ssize_t viodev_cmo_desired_set(struct device *dev,
 		struct device_attribute *attr, const char *buf, size_t count)
 {
 	struct vio_dev *viodev = to_vio_dev(dev);
-	size_t new_desired;
+	unsigned long new_desired;
 	int ret;
 
-	ret = strict_strtoul(buf, 10, &new_desired);
+	ret = kstrtoul(buf, 10, &new_desired);
 	if (ret)
 		return ret;
 
diff --git a/arch/powerpc/platforms/pseries/dlpar.c b/arch/powerpc/platforms/pseries/dlpar.c
index b74a923..c8a2e9e 100644
--- a/arch/powerpc/platforms/pseries/dlpar.c
+++ b/arch/powerpc/platforms/pseries/dlpar.c
@@ -403,12 +403,12 @@ out:
 static ssize_t dlpar_cpu_probe(const char *buf, size_t count)
 {
 	struct device_node *dn;
-	unsigned long drc_index;
+	u32 drc_index;
 	char *cpu_name;
 	int rc;
 
 	cpu_hotplug_driver_lock();
-	rc = strict_strtoul(buf, 0, &drc_index);
+	rc = kstrtou32(buf, 0, &drc_index);
 	if (rc) {
 		rc = -EINVAL;
 		goto out;
diff --git a/arch/powerpc/platforms/pseries/mobility.c b/arch/powerpc/platforms/pseries/mobility.c
index 3e7f651..5baeb2f 100644
--- a/arch/powerpc/platforms/pseries/mobility.c
+++ b/arch/powerpc/platforms/pseries/mobility.c
@@ -316,7 +316,7 @@ static ssize_t migrate_store(struct class *class, struct class_attribute *attr,
 	u64 streamid;
 	int rc;
 
-	rc = strict_strtoull(buf, 0, &streamid);
+	rc = kstrtou64(buf, 0, &streamid);
 	if (rc)
 		return rc;
 
diff --git a/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c b/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c
index cc8d655..d9b8b68 100644
--- a/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c
+++ b/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c
@@ -32,9 +32,9 @@ struct mpc85xx_l2ctlr __iomem *l2ctlr;
 
 static long get_cache_sram_size(void)
 {
-	unsigned long val;
+	unsigned int val;
 
-	if (!sram_size || (strict_strtoul(sram_size, 0, &val) < 0))
+	if (!sram_size || kstrtouint(sram_size, 0, &val) < 0)
 		return -EINVAL;
 
 	return val;
@@ -42,9 +42,9 @@ static long get_cache_sram_size(void)
 
 static long get_cache_sram_offset(void)
 {
-	unsigned long val;
+	unsigned int val;
 
-	if (!sram_offset || (strict_strtoul(sram_offset, 0, &val) < 0))
+	if (!sram_offset || kstrtouint(sram_offset, 0, &val) < 0)
 		return -EINVAL;
 
 	return val;
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 49/52] kstrtox: convert s390
  2011-02-05 14:20 [PATCH 01/52] kstrtox: converting strings to integers done (hopefully) right Alexey Dobriyan
                   ` (46 preceding siblings ...)
  2011-02-05 14:20 ` [PATCH 48/52] kstrtox: convert powerpc Alexey Dobriyan
@ 2011-02-05 14:20 ` Alexey Dobriyan
  2011-02-05 14:20 ` [PATCH 50/52] kstrtox: convert tile Alexey Dobriyan
                   ` (2 subsequent siblings)
  50 siblings, 0 replies; 58+ messages in thread
From: Alexey Dobriyan @ 2011-02-05 14:20 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, adobriyan


Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
 arch/s390/kernel/ptrace.c        |    8 +++--
 arch/s390/kernel/vdso.c          |    5 ++-
 drivers/s390/block/dasd_devmap.c |   20 +++++------
 drivers/s390/char/sclp_async.c   |    8 +++--
 drivers/s390/cio/ccwgroup.c      |    4 +-
 drivers/s390/cio/cmf.c           |    9 +++--
 drivers/s390/cio/css.c           |    4 +-
 drivers/s390/cio/device.c        |    6 ++--
 drivers/s390/cio/qdio_debug.c    |    6 ++-
 drivers/s390/net/qeth_l3_sys.c   |   10 ++---
 drivers/s390/scsi/zfcp_aux.c     |    4 +-
 drivers/s390/scsi/zfcp_sysfs.c   |   66 +++++++++++++++++++++++---------------
 drivers/tty/hvc/hvc_iucv.c       |    6 ++--
 13 files changed, 88 insertions(+), 68 deletions(-)

diff --git a/arch/s390/kernel/ptrace.c b/arch/s390/kernel/ptrace.c
index ef86ad2..8d63a16 100644
--- a/arch/s390/kernel/ptrace.c
+++ b/arch/s390/kernel/ptrace.c
@@ -1143,12 +1143,14 @@ unsigned long regs_get_register(struct pt_regs *regs, unsigned int offset)
 
 int regs_query_register_offset(const char *name)
 {
-	unsigned long offset;
+	unsigned int offset;
+	int rv;
 
 	if (!name || *name != 'r')
 		return -EINVAL;
-	if (strict_strtoul(name + 1, 10, &offset))
-		return -EINVAL;
+	rv = kstrtouint(name + 1, 10, &offset);
+	if (rv < 0)
+		return rv;
 	if (offset >= NUM_GPRS)
 		return -EINVAL;
 	return offset;
diff --git a/arch/s390/kernel/vdso.c b/arch/s390/kernel/vdso.c
index f438d74..b1f5e5a 100644
--- a/arch/s390/kernel/vdso.c
+++ b/arch/s390/kernel/vdso.c
@@ -54,7 +54,6 @@ unsigned int __read_mostly vdso_enabled = 1;
 
 static int __init vdso_setup(char *s)
 {
-	unsigned long val;
 	int rc;
 
 	rc = 0;
@@ -63,7 +62,9 @@ static int __init vdso_setup(char *s)
 	else if (strncmp(s, "off", 4) == 0)
 		vdso_enabled = 0;
 	else {
-		rc = strict_strtoul(s, 0, &val);
+		unsigned long val;
+
+		rc = kstrtoul(s, 0, &val);
 		vdso_enabled = rc ? 0 : !!val;
 	}
 	return !rc;
diff --git a/drivers/s390/block/dasd_devmap.c b/drivers/s390/block/dasd_devmap.c
index cb6a67b..5a3c4b9 100644
--- a/drivers/s390/block/dasd_devmap.c
+++ b/drivers/s390/block/dasd_devmap.c
@@ -902,7 +902,7 @@ dasd_use_raw_store(struct device *dev, struct device_attribute *attr,
 	if (IS_ERR(devmap))
 		return PTR_ERR(devmap);
 
-	if ((strict_strtoul(buf, 10, &val) != 0) || val > 1)
+	if (kstrtoul(buf, 10, &val) != 0 || val > 1)
 		return -EINVAL;
 
 	spin_lock(&dasd_devmap_lock);
@@ -1159,20 +1159,18 @@ dasd_expires_store(struct device *dev, struct device_attribute *attr,
 {
 	struct dasd_device *device;
 	unsigned long val;
+	int rv;
+
+	rv = kstrtoul(buf, 10, &val);
+	if (rv < 0)
+		return rv;
+	if (val == 0 || val > DASD_EXPIRES_MAX)
+		return -EINVAL;
 
 	device = dasd_device_from_cdev(to_ccwdev(dev));
 	if (IS_ERR(device))
 		return -ENODEV;
-
-	if ((strict_strtoul(buf, 10, &val) != 0) ||
-	    (val > DASD_EXPIRES_MAX) || val == 0) {
-		dasd_put_device(device);
-		return -EINVAL;
-	}
-
-	if (val)
-		device->default_expires = val;
-
+	device->default_expires = val;
 	dasd_put_device(device);
 	return count;
 }
diff --git a/drivers/s390/char/sclp_async.c b/drivers/s390/char/sclp_async.c
index 7ad30e7..75a58dc 100644
--- a/drivers/s390/char/sclp_async.c
+++ b/drivers/s390/char/sclp_async.c
@@ -67,7 +67,6 @@ static int proc_handler_callhome(struct ctl_table *ctl, int write,
 				 void __user *buffer, size_t *count,
 				 loff_t *ppos)
 {
-	unsigned long val;
 	int len, rc;
 	char buf[3];
 
@@ -81,13 +80,16 @@ static int proc_handler_callhome(struct ctl_table *ctl, int write,
 		if (rc != 0)
 			return -EFAULT;
 	} else {
+		int val;
+
 		len = *count;
 		rc = copy_from_user(buf, buffer, sizeof(buf));
 		if (rc != 0)
 			return -EFAULT;
 		buf[sizeof(buf) - 1] = '\0';
-		if (strict_strtoul(buf, 0, &val) != 0)
-			return -EINVAL;
+		rc = kstrtoint(buf, 0, &val);
+		if (rc < 0)
+			return rc;
 		if (val != 0 && val != 1)
 			return -EINVAL;
 		callhome_enabled = val;
diff --git a/drivers/s390/cio/ccwgroup.c b/drivers/s390/cio/ccwgroup.c
index 2864581..6f17efe 100644
--- a/drivers/s390/cio/ccwgroup.c
+++ b/drivers/s390/cio/ccwgroup.c
@@ -419,7 +419,7 @@ ccwgroup_online_store (struct device *dev, struct device_attribute *attr, const
 {
 	struct ccwgroup_device *gdev;
 	struct ccwgroup_driver *gdrv;
-	unsigned long value;
+	int value;
 	int ret;
 
 	if (!dev->driver)
@@ -431,7 +431,7 @@ ccwgroup_online_store (struct device *dev, struct device_attribute *attr, const
 	if (!try_module_get(gdrv->owner))
 		return -EINVAL;
 
-	ret = strict_strtoul(buf, 0, &value);
+	ret = kstrtoint(buf, 0, &value);
 	if (ret)
 		goto out;
 
diff --git a/drivers/s390/cio/cmf.c b/drivers/s390/cio/cmf.c
index 2985eb4..df48ea3 100644
--- a/drivers/s390/cio/cmf.c
+++ b/drivers/s390/cio/cmf.c
@@ -1181,10 +1181,10 @@ static ssize_t cmb_enable_store(struct device *dev,
 				size_t c)
 {
 	struct ccw_device *cdev;
+	int val;
 	int ret;
-	unsigned long val;
 
-	ret = strict_strtoul(buf, 16, &val);
+	ret = kstrtoint(buf, 16, &val);
 	if (ret)
 		return ret;
 
@@ -1197,8 +1197,11 @@ static ssize_t cmb_enable_store(struct device *dev,
 	case 1:
 		ret = enable_cmf(cdev);
 		break;
+	default:
+		ret = -EINVAL;
 	}
-
+	if (ret < 0)
+		return ret;
 	return c;
 }
 
diff --git a/drivers/s390/cio/css.c b/drivers/s390/cio/css.c
index 24d8e97..fe92213 100644
--- a/drivers/s390/cio/css.c
+++ b/drivers/s390/cio/css.c
@@ -710,10 +710,10 @@ css_cm_enable_store(struct device *dev, struct device_attribute *attr,
 		    const char *buf, size_t count)
 {
 	struct channel_subsystem *css = to_css(dev);
+	int val;
 	int ret;
-	unsigned long val;
 
-	ret = strict_strtoul(buf, 16, &val);
+	ret = kstrtoint(buf, 16, &val);
 	if (ret)
 		return ret;
 	mutex_lock(&css->mutex);
diff --git a/drivers/s390/cio/device.c b/drivers/s390/cio/device.c
index b7eaff9..f2edaa8 100644
--- a/drivers/s390/cio/device.c
+++ b/drivers/s390/cio/device.c
@@ -536,8 +536,8 @@ static ssize_t online_store (struct device *dev, struct device_attribute *attr,
 			     const char *buf, size_t count)
 {
 	struct ccw_device *cdev = to_ccwdev(dev);
-	int force, ret;
-	unsigned long i;
+	int force, i;
+	int ret;
 
 	if (!dev_fsm_final_state(cdev) &&
 	    cdev->private->state != DEV_STATE_DISCONNECTED)
@@ -555,7 +555,7 @@ static ssize_t online_store (struct device *dev, struct device_attribute *attr,
 		ret = 0;
 	} else {
 		force = 0;
-		ret = strict_strtoul(buf, 16, &i);
+		ret = kstrtoint(buf, 16, &i);
 	}
 	if (ret)
 		goto out;
diff --git a/drivers/s390/cio/qdio_debug.c b/drivers/s390/cio/qdio_debug.c
index f8b03a6..ff6ca17 100644
--- a/drivers/s390/cio/qdio_debug.c
+++ b/drivers/s390/cio/qdio_debug.c
@@ -187,7 +187,7 @@ static ssize_t qperf_seq_write(struct file *file, const char __user *ubuf,
 	struct seq_file *seq = file->private_data;
 	struct qdio_irq *irq_ptr = seq->private;
 	struct qdio_q *q;
-	unsigned long val;
+	int val;
 	char buf[8];
 	int ret, i;
 
@@ -199,7 +199,7 @@ static ssize_t qperf_seq_write(struct file *file, const char __user *ubuf,
 		return -EFAULT;
 	buf[count] = 0;
 
-	ret = strict_strtoul(buf, 10, &val);
+	ret = kstrtoint(buf, 10, &val);
 	if (ret < 0)
 		return ret;
 
@@ -215,6 +215,8 @@ static ssize_t qperf_seq_write(struct file *file, const char __user *ubuf,
 	case 1:
 		irq_ptr->perf_stat_enabled = 1;
 		break;
+	default:
+		return -EINVAL;
 	}
 	return count;
 }
diff --git a/drivers/s390/net/qeth_l3_sys.c b/drivers/s390/net/qeth_l3_sys.c
index 67cfa68..4e9cb7c 100644
--- a/drivers/s390/net/qeth_l3_sys.c
+++ b/drivers/s390/net/qeth_l3_sys.c
@@ -355,8 +355,8 @@ static ssize_t qeth_l3_dev_sniffer_store(struct device *dev,
 		struct device_attribute *attr, const char *buf, size_t count)
 {
 	struct qeth_card *card = dev_get_drvdata(dev);
-	int rc = 0;
-	unsigned long i;
+	int i;
+	int rc;
 
 	if (!card)
 		return -EINVAL;
@@ -371,11 +371,9 @@ static ssize_t qeth_l3_dev_sniffer_store(struct device *dev,
 		goto out;
 	}
 
-	rc = strict_strtoul(buf, 16, &i);
-	if (rc) {
-		rc = -EINVAL;
+	rc = kstrtoint(buf, 16, &i);
+	if (rc)
 		goto out;
-	}
 	switch (i) {
 	case 0:
 		card->options.sniffer = i;
diff --git a/drivers/s390/scsi/zfcp_aux.c b/drivers/s390/scsi/zfcp_aux.c
index 51c666f..78a652a 100644
--- a/drivers/s390/scsi/zfcp_aux.c
+++ b/drivers/s390/scsi/zfcp_aux.c
@@ -102,11 +102,11 @@ static void __init zfcp_init_device_setup(char *devstr)
 	strncpy(busid, token, ZFCP_BUS_ID_SIZE);
 
 	token = strsep(&str, ",");
-	if (!token || strict_strtoull(token, 0, (unsigned long long *) &wwpn))
+	if (!token || kstrtou64(token, 0, &wwpn))
 		goto err_out;
 
 	token = strsep(&str, ",");
-	if (!token || strict_strtoull(token, 0, (unsigned long long *) &lun))
+	if (!token || kstrtou64(token, 0, &lun))
 		goto err_out;
 
 	kfree(str_saved);
diff --git a/drivers/s390/scsi/zfcp_sysfs.c b/drivers/s390/scsi/zfcp_sysfs.c
index cdc4ff7..9de9b62 100644
--- a/drivers/s390/scsi/zfcp_sysfs.c
+++ b/drivers/s390/scsi/zfcp_sysfs.c
@@ -99,9 +99,13 @@ static ssize_t zfcp_sysfs_port_failed_store(struct device *dev,
 					    const char *buf, size_t count)
 {
 	struct zfcp_port *port = container_of(dev, struct zfcp_port, dev);
-	unsigned long val;
+	int val;
+	int rv;
 
-	if (strict_strtoul(buf, 0, &val) || val != 0)
+	rv = kstrtoint(buf, 0, &val);
+	if (rv < 0)
+		return rv;
+	if (val != 0)
 		return -EINVAL;
 
 	zfcp_erp_set_port_status(port, ZFCP_STATUS_COMMON_RUNNING);
@@ -137,10 +141,14 @@ static ssize_t zfcp_sysfs_unit_failed_store(struct device *dev,
 					    const char *buf, size_t count)
 {
 	struct zfcp_unit *unit = container_of(dev, struct zfcp_unit, dev);
-	unsigned long val;
 	struct scsi_device *sdev;
+	int val;
+	int rv;
 
-	if (strict_strtoul(buf, 0, &val) || val != 0)
+	rv = kstrtoint(buf, 0, &val);
+	if (rv < 0)
+		return rv;
+	if (val != 0)
 		return -EINVAL;
 
 	sdev = zfcp_unit_sdev(unit);
@@ -183,23 +191,23 @@ static ssize_t zfcp_sysfs_adapter_failed_store(struct device *dev,
 					       const char *buf, size_t count)
 {
 	struct ccw_device *cdev = to_ccwdev(dev);
-	struct zfcp_adapter *adapter = zfcp_ccw_adapter_by_cdev(cdev);
-	unsigned long val;
-	int retval = 0;
+	struct zfcp_adapter *adapter;
+	int val;
+	int retval;
 
+	retval = kstrtoint(buf, 0, &val);
+	if (retval < 0)
+		return retval;
+	if (val != 0)
+		return -EINVAL;
+
+	adapter = zfcp_ccw_adapter_by_cdev(cdev);
 	if (!adapter)
 		return -ENODEV;
-
-	if (strict_strtoul(buf, 0, &val) || val != 0) {
-		retval = -EINVAL;
-		goto out;
-	}
-
 	zfcp_erp_set_adapter_status(adapter, ZFCP_STATUS_COMMON_RUNNING);
 	zfcp_erp_adapter_reopen(adapter, ZFCP_STATUS_COMMON_ERP_FAILED,
 				"syafai2");
 	zfcp_erp_wait(adapter);
-out:
 	zfcp_ccw_adapter_put(adapter);
 	return retval ? retval : (ssize_t) count;
 }
@@ -232,22 +240,24 @@ static ssize_t zfcp_sysfs_port_remove_store(struct device *dev,
 					    const char *buf, size_t count)
 {
 	struct ccw_device *cdev = to_ccwdev(dev);
-	struct zfcp_adapter *adapter = zfcp_ccw_adapter_by_cdev(cdev);
+	struct zfcp_adapter *adapter;
 	struct zfcp_port *port;
 	u64 wwpn;
-	int retval = -EINVAL;
+	int retval;
+
+	retval = kstrtou64(buf, 0, &wwpn);
+	if (retval < 0)
+		return retval;
 
+	adapter = zfcp_ccw_adapter_by_cdev(cdev);
 	if (!adapter)
 		return -ENODEV;
 
-	if (strict_strtoull(buf, 0, (unsigned long long *) &wwpn))
-		goto out;
-
 	port = zfcp_get_port_by_wwpn(adapter, wwpn);
-	if (!port)
+	if (!port) {
+		retval = -EINVAL;
 		goto out;
-	else
-		retval = 0;
+	}
 
 	write_lock_irq(&adapter->port_list_lock);
 	list_del(&port->list);
@@ -289,9 +299,11 @@ static ssize_t zfcp_sysfs_unit_add_store(struct device *dev,
 {
 	struct zfcp_port *port = container_of(dev, struct zfcp_port, dev);
 	u64 fcp_lun;
+	int rv;
 
-	if (strict_strtoull(buf, 0, (unsigned long long *) &fcp_lun))
-		return -EINVAL;
+	rv = kstrtou64(buf, 0, &fcp_lun);
+	if (rv < 0)
+		return rv;
 
 	if (zfcp_unit_add(port, fcp_lun))
 		return -EINVAL;
@@ -306,9 +318,11 @@ static ssize_t zfcp_sysfs_unit_remove_store(struct device *dev,
 {
 	struct zfcp_port *port = container_of(dev, struct zfcp_port, dev);
 	u64 fcp_lun;
+	int rv;
 
-	if (strict_strtoull(buf, 0, (unsigned long long *) &fcp_lun))
-		return -EINVAL;
+	rv =  kstrtou64(buf, 0, &fcp_lun);
+	if (rv < 0)
+		return rv;
 
 	if (zfcp_unit_remove(port, fcp_lun))
 		return -EINVAL;
diff --git a/drivers/tty/hvc/hvc_iucv.c b/drivers/tty/hvc/hvc_iucv.c
index c3425bb..ade3355 100644
--- a/drivers/tty/hvc/hvc_iucv.c
+++ b/drivers/tty/hvc/hvc_iucv.c
@@ -94,7 +94,7 @@ static void hvc_iucv_msg_complete(struct iucv_path *, struct iucv_message *);
 
 
 /* Kernel module parameter: use one terminal device as default */
-static unsigned long hvc_iucv_devices = 1;
+static unsigned int hvc_iucv_devices = 1;
 
 /* Array of allocated hvc iucv tty lines... */
 static struct hvc_iucv_private *hvc_iucv_table[MAX_HVC_IUCV_LINES];
@@ -1227,7 +1227,7 @@ static int __init hvc_iucv_init(void)
 	}
 
 	if (hvc_iucv_devices > MAX_HVC_IUCV_LINES) {
-		pr_err("%lu is not a valid value for the hvc_iucv= "
+		pr_err("%u is not a valid value for the hvc_iucv= "
 			"kernel parameter\n", hvc_iucv_devices);
 		rc = -EINVAL;
 		goto out_error;
@@ -1328,7 +1328,7 @@ out_error:
  */
 static	int __init hvc_iucv_config(char *val)
 {
-	 return strict_strtoul(val, 10, &hvc_iucv_devices);
+	 return kstrtouint(val, 10, &hvc_iucv_devices);
 }
 
 
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 50/52] kstrtox: convert tile
  2011-02-05 14:20 [PATCH 01/52] kstrtox: converting strings to integers done (hopefully) right Alexey Dobriyan
                   ` (47 preceding siblings ...)
  2011-02-05 14:20 ` [PATCH 49/52] kstrtox: convert s390 Alexey Dobriyan
@ 2011-02-05 14:20 ` Alexey Dobriyan
  2011-02-05 14:20 ` [PATCH 51/52] kstrtox: convert x86 Alexey Dobriyan
  2011-02-05 14:33 ` [PATCH 01/52] kstrtox: converting strings to integers done (hopefully) right Geert Uytterhoeven
  50 siblings, 0 replies; 58+ messages in thread
From: Alexey Dobriyan @ 2011-02-05 14:20 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, adobriyan


Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
 arch/tile/kernel/setup.c       |   15 ++++++++-------
 arch/tile/kernel/single_step.c |    4 +---
 arch/tile/kernel/traps.c       |    4 +---
 arch/tile/mm/init.c            |    9 +++------
 4 files changed, 13 insertions(+), 19 deletions(-)

diff --git a/arch/tile/kernel/setup.c b/arch/tile/kernel/setup.c
index f185736..cf3f155 100644
--- a/arch/tile/kernel/setup.c
+++ b/arch/tile/kernel/setup.c
@@ -101,8 +101,9 @@ unsigned long __initdata pci_reserve_end_pfn = -1U;
 
 static int __init setup_maxmem(char *str)
 {
-	long maxmem_mb;
-	if (str == NULL || strict_strtol(str, 0, &maxmem_mb) != 0 ||
+	unsigned int maxmem_mb;
+
+	if (str == NULL || kstrtouint(str, 0, &maxmem_mb) != 0 ||
 	    maxmem_mb == 0)
 		return -EINVAL;
 
@@ -117,16 +118,16 @@ early_param("maxmem", setup_maxmem);
 static int __init setup_maxnodemem(char *str)
 {
 	char *endp;
-	long maxnodemem_mb, node;
+	unsigned int maxnodemem_mb, node;
 
 	node = str ? simple_strtoul(str, &endp, 0) : INT_MAX;
 	if (node >= MAX_NUMNODES || *endp != ':' ||
-	    strict_strtol(endp+1, 0, &maxnodemem_mb) != 0)
+	    kstrtouint(endp+1, 0, &maxnodemem_mb) != 0)
 		return -EINVAL;
 
 	maxnodemem_pfn[node] = (maxnodemem_mb >> (HPAGE_SHIFT - 20)) <<
 		(HPAGE_SHIFT - PAGE_SHIFT);
-	pr_info("Forcing RAM used on node %ld to no more than %dMB\n",
+	pr_info("Forcing RAM used on node %u to no more than %uMB\n",
 	       node, maxnodemem_pfn[node] >> (20 - PAGE_SHIFT));
 	return 0;
 }
@@ -147,9 +148,9 @@ early_param("isolnodes", setup_isolnodes);
 #ifdef CONFIG_PCI
 static int __init setup_pci_reserve(char* str)
 {
-	unsigned long mb;
+	unsigned int mb;
 
-	if (str == NULL || strict_strtoul(str, 0, &mb) != 0 ||
+	if (str == NULL || kstrtouint(str, 0, &mb) != 0 ||
 	    mb > 3 * 1024)
 		return -EINVAL;
 
diff --git a/arch/tile/kernel/single_step.c b/arch/tile/kernel/single_step.c
index 1eb3b39..1e7bb00 100644
--- a/arch/tile/kernel/single_step.c
+++ b/arch/tile/kernel/single_step.c
@@ -36,10 +36,8 @@ int unaligned_printk;
 
 static int __init setup_unaligned_printk(char *str)
 {
-	long val;
-	if (strict_strtol(str, 0, &val) != 0)
+	if (kstrtoint(str, 0, &unaligned_printk) != 0)
 		return 0;
-	unaligned_printk = val;
 	pr_info("Printk for each unaligned data accesses is %s\n",
 		unaligned_printk ? "enabled" : "disabled");
 	return 1;
diff --git a/arch/tile/kernel/traps.c b/arch/tile/kernel/traps.c
index 5474fc2..e7e1319 100644
--- a/arch/tile/kernel/traps.c
+++ b/arch/tile/kernel/traps.c
@@ -41,10 +41,8 @@ static int __init setup_unaligned_fixup(char *str)
 	 * will still parse the instruction, then fire a SIGBUS with
 	 * the correct address from inside the single_step code.
 	 */
-	long val;
-	if (strict_strtol(str, 0, &val) != 0)
+	if (kstrtoint(str, 0, &unaligned_fixup) != 0)
 		return 0;
-	unaligned_fixup = val;
 	pr_info("Fixups for unaligned data accesses are %s\n",
 	       unaligned_fixup >= 0 ?
 	       (unaligned_fixup ? "enabled" : "disabled") :
diff --git a/arch/tile/mm/init.c b/arch/tile/mm/init.c
index 0b9ce69..8339a64 100644
--- a/arch/tile/mm/init.c
+++ b/arch/tile/mm/init.c
@@ -988,12 +988,9 @@ static long __write_once initfree = 1;
 /* Select whether to free (1) or mark unusable (0) the __init pages. */
 static int __init set_initfree(char *str)
 {
-	long val;
-	if (strict_strtol(str, 0, &val)) {
-		initfree = val;
-		pr_info("initfree: %s free init pages\n",
-			initfree ? "will" : "won't");
-	}
+	if (kstrtoint(str, 0, &initfree) < 0)
+		return 0;
+	pr_info("initfree: %s free init pages\n", initfree ? "will" : "won't");
 	return 1;
 }
 __setup("initfree=", set_initfree);
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 51/52] kstrtox: convert x86
  2011-02-05 14:20 [PATCH 01/52] kstrtox: converting strings to integers done (hopefully) right Alexey Dobriyan
                   ` (48 preceding siblings ...)
  2011-02-05 14:20 ` [PATCH 50/52] kstrtox: convert tile Alexey Dobriyan
@ 2011-02-05 14:20 ` Alexey Dobriyan
  2011-02-05 14:33 ` [PATCH 01/52] kstrtox: converting strings to integers done (hopefully) right Geert Uytterhoeven
  50 siblings, 0 replies; 58+ messages in thread
From: Alexey Dobriyan @ 2011-02-05 14:20 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, adobriyan


Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
 arch/x86/kernel/cpu/cpufreq/powernow-k8.c |   12 ++++++++----
 arch/x86/kernel/cpu/intel_cacheinfo.c     |   15 ++++++++-------
 arch/x86/kernel/cpu/mcheck/mce.c          |   25 ++++++++++++++-----------
 arch/x86/kernel/cpu/mcheck/mce_amd.c      |   12 ++++++++----
 arch/x86/kvm/mmu_audit.c                  |    6 +++---
 arch/x86/platform/uv/tlb_uv.c             |   19 ++++++++++++-------
 drivers/platform/x86/classmate-laptop.c   |    2 +-
 drivers/platform/x86/compal-laptop.c      |   14 ++++++--------
 8 files changed, 60 insertions(+), 45 deletions(-)

diff --git a/arch/x86/kernel/cpu/cpufreq/powernow-k8.c b/arch/x86/kernel/cpu/cpufreq/powernow-k8.c
index 35c7e65..3b23367 100644
--- a/arch/x86/kernel/cpu/cpufreq/powernow-k8.c
+++ b/arch/x86/kernel/cpu/cpufreq/powernow-k8.c
@@ -1451,11 +1451,15 @@ static void cpb_toggle(bool t)
 static ssize_t store_cpb(struct cpufreq_policy *policy, const char *buf,
 				 size_t count)
 {
-	int ret = -EINVAL;
-	unsigned long val = 0;
+	int val;
+	int ret;
 
-	ret = strict_strtoul(buf, 10, &val);
-	if (!ret && (val == 0 || val == 1) && cpb_capable)
+	ret = kstrtoint(buf, 10, &val);
+	if (ret < 0)
+		return ret;
+	if (val != 0 && val != 1)
+		return -EINVAL;
+	if (cpb_capable)
 		cpb_toggle(val);
 	else
 		return -EINVAL;
diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c
index ec2c19a..35afb5e 100644
--- a/arch/x86/kernel/cpu/intel_cacheinfo.c
+++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
@@ -408,7 +408,7 @@ SHOW_CACHE_DISABLE(0)
 SHOW_CACHE_DISABLE(1)
 
 static void amd_l3_disable_index(struct amd_l3_cache *l3, int cpu,
-				 unsigned slot, unsigned long idx)
+				 unsigned slot, u32 idx)
 {
 	int i;
 
@@ -447,12 +447,12 @@ static void amd_l3_disable_index(struct amd_l3_cache *l3, int cpu,
  *
  * @return: 0 on success, error status on failure
  */
-int amd_set_l3_disable_slot(struct amd_l3_cache *l3, int cpu, unsigned slot,
-			    unsigned long index)
+static int amd_set_l3_disable_slot(struct amd_l3_cache *l3, int cpu,
+				   unsigned slot, u32 index)
 {
 	int ret = 0;
 
-#define SUBCACHE_MASK	(3UL << 20)
+#define SUBCACHE_MASK	(3U << 20)
 #define SUBCACHE_INDEX	0xfff
 
 	/*
@@ -484,7 +484,7 @@ static ssize_t store_cache_disable(struct _cpuid4_info *this_leaf,
 				  const char *buf, size_t count,
 				  unsigned int slot)
 {
-	unsigned long val = 0;
+	u32 val;
 	int cpu, err = 0;
 
 	if (!capable(CAP_SYS_ADMIN))
@@ -496,8 +496,9 @@ static ssize_t store_cache_disable(struct _cpuid4_info *this_leaf,
 
 	cpu = cpumask_first(to_cpumask(this_leaf->shared_cpu_map));
 
-	if (strict_strtoul(buf, 10, &val) < 0)
-		return -EINVAL;
+	err = kstrtou32(buf, 10, &val);
+	if (err < 0)
+		return err;
 
 	err = amd_set_l3_disable_slot(this_leaf->l3, cpu, slot, val);
 	if (err) {
diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
index d916183..a3858d5 100644
--- a/arch/x86/kernel/cpu/mcheck/mce.c
+++ b/arch/x86/kernel/cpu/mcheck/mce.c
@@ -1833,12 +1833,11 @@ static ssize_t show_bank(struct sys_device *s, struct sysdev_attribute *attr,
 static ssize_t set_bank(struct sys_device *s, struct sysdev_attribute *attr,
 			const char *buf, size_t size)
 {
-	u64 new;
+	int rv;
 
-	if (strict_strtoull(buf, 0, &new) < 0)
-		return -EINVAL;
-
-	attr_to_bank(attr)->ctl = new;
+	rv = kstrtou64(buf, 0, &attr_to_bank(attr)->ctl);
+	if (rv < 0)
+		return rv;
 	mce_restart();
 
 	return size;
@@ -1871,10 +1870,12 @@ static ssize_t set_ignore_ce(struct sys_device *s,
 			     struct sysdev_attribute *attr,
 			     const char *buf, size_t size)
 {
-	u64 new;
+	unsigned long long new;
+	int rv;
 
-	if (strict_strtoull(buf, 0, &new) < 0)
-		return -EINVAL;
+	rv = kstrtoull(buf, 0, &new);
+	if (rv < 0)
+		return rv;
 
 	if (mce_ignore_ce ^ !!new) {
 		if (new) {
@@ -1894,10 +1895,12 @@ static ssize_t set_cmci_disabled(struct sys_device *s,
 				 struct sysdev_attribute *attr,
 				 const char *buf, size_t size)
 {
-	u64 new;
+	unsigned long long new;
+	int rv;
 
-	if (strict_strtoull(buf, 0, &new) < 0)
-		return -EINVAL;
+	rv = kstrtoull(buf, 0, &new);
+	if (rv < 0)
+		return rv;
 
 	if (mce_cmci_disabled ^ !!new) {
 		if (new) {
diff --git a/arch/x86/kernel/cpu/mcheck/mce_amd.c b/arch/x86/kernel/cpu/mcheck/mce_amd.c
index 5bf2fac..f74e790 100644
--- a/arch/x86/kernel/cpu/mcheck/mce_amd.c
+++ b/arch/x86/kernel/cpu/mcheck/mce_amd.c
@@ -312,9 +312,11 @@ store_interrupt_enable(struct threshold_block *b, const char *buf, size_t size)
 {
 	struct thresh_restart tr;
 	unsigned long new;
+	int rv;
 
-	if (strict_strtoul(buf, 0, &new) < 0)
-		return -EINVAL;
+	rv = kstrtoul(buf, 0, &new);
+	if (rv < 0)
+		return rv;
 
 	b->interrupt_enable = !!new;
 
@@ -331,9 +333,11 @@ store_threshold_limit(struct threshold_block *b, const char *buf, size_t size)
 {
 	struct thresh_restart tr;
 	unsigned long new;
+	int rv;
 
-	if (strict_strtoul(buf, 0, &new) < 0)
-		return -EINVAL;
+	rv = kstrtoul(buf, 0, &new);
+	if (rv < 0)
+		return rv;
 
 	if (new > THRESHOLD_MAX)
 		new = THRESHOLD_MAX;
diff --git a/arch/x86/kvm/mmu_audit.c b/arch/x86/kvm/mmu_audit.c
index 5f6223b..f60bbbf 100644
--- a/arch/x86/kvm/mmu_audit.c
+++ b/arch/x86/kvm/mmu_audit.c
@@ -275,12 +275,12 @@ static void mmu_audit_disable(void)
 
 static int mmu_audit_set(const char *val, const struct kernel_param *kp)
 {
+	int enable;
 	int ret;
-	unsigned long enable;
 
-	ret = strict_strtoul(val, 10, &enable);
+	ret = kstrtoint(val, 10, &enable);
 	if (ret < 0)
-		return -EINVAL;
+		return ret;
 
 	switch (enable) {
 	case 0:
diff --git a/arch/x86/platform/uv/tlb_uv.c b/arch/x86/platform/uv/tlb_uv.c
index df58e9c..4b687ae 100644
--- a/arch/x86/platform/uv/tlb_uv.c
+++ b/arch/x86/platform/uv/tlb_uv.c
@@ -1028,21 +1028,22 @@ static ssize_t uv_ptc_proc_write(struct file *file, const char __user *user,
 				 size_t count, loff_t *data)
 {
 	int cpu;
-	long input_arg;
+	int input_arg;
 	char optstr[64];
 	struct ptc_stats *stat;
+	int rv;
 
 	if (count == 0 || count > sizeof(optstr))
 		return -EINVAL;
 	if (copy_from_user(optstr, user, count))
 		return -EFAULT;
 	optstr[count - 1] = '\0';
-	if (strict_strtol(optstr, 10, &input_arg) < 0) {
-		printk(KERN_DEBUG "%s is invalid\n", optstr);
-		return -EINVAL;
-	}
+	rv = kstrtoint(optstr, 10, &input_arg);
+	if (rv < 0)
+		return rv;
 
-	if (input_arg == 0) {
+	switch (input_arg) {
+	case 0:
 		printk(KERN_DEBUG "# cpu:      cpu number\n");
 		printk(KERN_DEBUG "Sender statistics:\n");
 		printk(KERN_DEBUG
@@ -1110,11 +1111,15 @@ static ssize_t uv_ptc_proc_write(struct file *file, const char __user *user,
 		"disable:  number times use of the BAU was disabled\n");
 		printk(KERN_DEBUG
 		"enable:   number times use of the BAU was re-enabled\n");
-	} else if (input_arg == -1) {
+		break;
+	case -1:
 		for_each_present_cpu(cpu) {
 			stat = &per_cpu(ptcstats, cpu);
 			memset(stat, 0, sizeof(struct ptc_stats));
 		}
+		break;
+	default:
+		return -EINVAL;
 	}
 
 	return count;
diff --git a/drivers/platform/x86/classmate-laptop.c b/drivers/platform/x86/classmate-laptop.c
index 9111354..e54994d 100644
--- a/drivers/platform/x86/classmate-laptop.c
+++ b/drivers/platform/x86/classmate-laptop.c
@@ -198,7 +198,7 @@ static ssize_t cmpc_accel_sensitivity_store(struct device *dev,
 	inputdev = dev_get_drvdata(&acpi->dev);
 	accel = dev_get_drvdata(&inputdev->dev);
 
-	r = strict_strtoul(buf, 0, &sensitivity);
+	r = kstrtoul(buf, 0, &sensitivity);
 	if (r)
 		return r;
 
diff --git a/drivers/platform/x86/compal-laptop.c b/drivers/platform/x86/compal-laptop.c
index 034572b..0fae544 100644
--- a/drivers/platform/x86/compal-laptop.c
+++ b/drivers/platform/x86/compal-laptop.c
@@ -421,13 +421,12 @@ static ssize_t pwm_enable_store(struct device *dev,
 		struct device_attribute *attr, const char *buf, size_t count)
 {
 	struct compal_data *data = dev_get_drvdata(dev);
-	long val;
+	unsigned int val;
 	int err;
-	err = strict_strtol(buf, 10, &val);
+
+	err = kstrtouint(buf, 10, &val);
 	if (err)
 		return err;
-	if (val < 0)
-		return -EINVAL;
 
 	data->pwm_enable = val;
 
@@ -459,13 +458,12 @@ static ssize_t pwm_store(struct device *dev, struct device_attribute *attr,
 		const char *buf, size_t count)
 {
 	struct compal_data *data = dev_get_drvdata(dev);
-	long val;
+	u8 val;
 	int err;
-	err = strict_strtol(buf, 10, &val);
+
+	err = kstrtou8(buf, 10, &val);
 	if (err)
 		return err;
-	if (val < 0 || val > 255)
-		return -EINVAL;
 
 	data->curr_pwm = val;
 
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* Re: [PATCH 01/52] kstrtox: converting strings to integers done (hopefully) right
  2011-02-05 14:20 [PATCH 01/52] kstrtox: converting strings to integers done (hopefully) right Alexey Dobriyan
                   ` (49 preceding siblings ...)
  2011-02-05 14:20 ` [PATCH 51/52] kstrtox: convert x86 Alexey Dobriyan
@ 2011-02-05 14:33 ` Geert Uytterhoeven
  2011-02-05 14:40   ` Alexey Dobriyan
  50 siblings, 1 reply; 58+ messages in thread
From: Geert Uytterhoeven @ 2011-02-05 14:33 UTC (permalink / raw)
  To: Alexey Dobriyan; +Cc: akpm, linux-kernel

On Sat, Feb 5, 2011 at 15:20, Alexey Dobriyan <adobriyan@gmail.com> wrote:
> --- /dev/null
> +++ b/lib/kstrtox.c
> @@ -0,0 +1,227 @@
> +/*
> + * Convert integer string representation to an integer.
> + * If an integer doesn't fit into specified type, -E is returned.

Which -E? Currently it returns -EINVAL everywhere.

> +int _kstrtoul(const char *s, unsigned int base, unsigned long *res)
> +{
> +       unsigned long long tmp;
> +       int rv;
> +
> +       rv = kstrtoull(s, base, &tmp);
> +       if (rv < 0)
> +               return rv;
> +       if (tmp != (unsigned long long)(unsigned long)tmp)
> +               return -EINVAL;

-ERANGE for out-of-range?

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 01/52] kstrtox: converting strings to integers done (hopefully) right
  2011-02-05 14:33 ` [PATCH 01/52] kstrtox: converting strings to integers done (hopefully) right Geert Uytterhoeven
@ 2011-02-05 14:40   ` Alexey Dobriyan
  0 siblings, 0 replies; 58+ messages in thread
From: Alexey Dobriyan @ 2011-02-05 14:40 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: akpm, linux-kernel

On Sat, Feb 05, 2011 at 03:33:41PM +0100, Geert Uytterhoeven wrote:
> On Sat, Feb 5, 2011 at 15:20, Alexey Dobriyan <adobriyan@gmail.com> wrote:

> > + * Convert integer string representation to an integer.
> > + * If an integer doesn't fit into specified type, -E is returned.
> 
> Which -E? Currently it returns -EINVAL everywhere.

Comment meant function follows 0/-E idiom for return value.

> > +       if (tmp != (unsigned long long)(unsigned long)tmp)
> > +               return -EINVAL;
> 
> -ERANGE for out-of-range?

Hmm, interesting.
It should prevent -EINVAL hardcoding.

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 16/52] kstrtox: convert drivers/edac/
  2011-02-05 14:20 ` [PATCH 16/52] kstrtox: convert drivers/edac/ Alexey Dobriyan
@ 2011-02-05 17:34   ` Borislav Petkov
  2011-02-06 18:52     ` Alexey Dobriyan
  0 siblings, 1 reply; 58+ messages in thread
From: Borislav Petkov @ 2011-02-05 17:34 UTC (permalink / raw)
  To: Alexey Dobriyan; +Cc: akpm, linux-kernel, borislav.petkov

On Sat, Feb 05, 2011 at 04:20:19PM +0200, Alexey Dobriyan wrote:

Some kind of a boilerplate commit message is still better than none at all.

> 
> Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
> ---
>  drivers/edac/amd64_edac_inj.c |  135 +++++++++++++++++------------------------
>  drivers/edac/edac_mc_sysfs.c  |   20 +++---
>  drivers/edac/i7core_edac.c    |   41 +++++++------
>  drivers/edac/mce_amd_inj.c    |   28 ++++-----
>  4 files changed, 101 insertions(+), 123 deletions(-)
> 
> diff --git a/drivers/edac/amd64_edac_inj.c b/drivers/edac/amd64_edac_inj.c
> index 688478d..180a498 100644
> --- a/drivers/edac/amd64_edac_inj.c
> +++ b/drivers/edac/amd64_edac_inj.c
> @@ -16,21 +16,18 @@ static ssize_t amd64_inject_section_store(struct mem_ctl_info *mci,
>  					  const char *data, size_t count)
>  {
>  	struct amd64_pvt *pvt = mci->pvt_info;
> -	unsigned long value;
> -	int ret = 0;
> -
> -	ret = strict_strtoul(data, 10, &value);
> -	if (ret != -EINVAL) {
> -
> -		if (value > 3) {
> -			amd64_warn("%s: invalid section 0x%lx\n", __func__, value);
> -			return -EINVAL;
> -		}
> -
> -		pvt->injection.section = (u32) value;
> -		return count;
> +	u32 value;
> +	int ret;
> +
> +	ret = kstrtou32(data, 10, &value);
> +	if (ret < 0)
> +		return ret;

newline here

> +	if (value > 3) {
> +		amd64_warn("%s: invalid section 0x%x\n", __func__, value);
> +		return -EINVAL;
>  	}

and here.

> -	return ret;
> +	pvt->injection.section = value;
> +	return count;
>  }
>  
>  static ssize_t amd64_inject_word_show(struct mem_ctl_info *mci, char *buf)
> @@ -49,21 +46,18 @@ static ssize_t amd64_inject_word_store(struct mem_ctl_info *mci,
>  					const char *data, size_t count)
>  {
>  	struct amd64_pvt *pvt = mci->pvt_info;
> -	unsigned long value;
> -	int ret = 0;
> -
> -	ret = strict_strtoul(data, 10, &value);
> -	if (ret != -EINVAL) {
> -
> -		if (value > 8) {
> -			amd64_warn("%s: invalid word 0x%lx\n", __func__, value);
> -			return -EINVAL;
> -		}
> -
> -		pvt->injection.word = (u32) value;
> -		return count;
> +	u32 value;
> +	int ret;
> +
> +	ret = kstrtou32(data, 10, &value);
> +	if (ret < 0)
> +		return ret;

newline

> +	if (value > 8) {
> +		amd64_warn("%s: invalid word 0x%x\n", __func__, value);
> +		return -EINVAL;
>  	}

newline.

> -	return ret;
> +	pvt->injection.word = value;
> +	return count;
>  }
>  
>  static ssize_t amd64_inject_ecc_vector_show(struct mem_ctl_info *mci, char *buf)
> @@ -81,22 +75,19 @@ static ssize_t amd64_inject_ecc_vector_store(struct mem_ctl_info *mci,
>  					     const char *data, size_t count)
>  {
>  	struct amd64_pvt *pvt = mci->pvt_info;
> -	unsigned long value;
> -	int ret = 0;
> -
> -	ret = strict_strtoul(data, 16, &value);
> -	if (ret != -EINVAL) {
> -
> -		if (value & 0xFFFF0000) {
> -			amd64_warn("%s: invalid EccVector: 0x%lx\n",
> +	u32 value;
> +	int ret;
> +
> +	ret = kstrtou32(data, 16, &value);
> +	if (ret < 0)
> +		return ret;

newline.

> +	if (value & 0xFFFF0000) {
> +		amd64_warn("%s: invalid EccVector: 0x%x\n",
>  				   __func__, value);
> -			return -EINVAL;
> -		}
> -
> -		pvt->injection.bit_map = (u32) value;
> -		return count;
> +		return -EINVAL;
>  	}
> -	return ret;

newline

> +	pvt->injection.bit_map = value;
> +	return count;
>  }
>  
>  /*
> @@ -107,29 +98,22 @@ static ssize_t amd64_inject_read_store(struct mem_ctl_info *mci,
>  					const char *data, size_t count)
>  {
>  	struct amd64_pvt *pvt = mci->pvt_info;
> -	unsigned long value;
>  	u32 section, word_bits;
> -	int ret = 0;
> -
> -	ret = strict_strtoul(data, 10, &value);
> -	if (ret != -EINVAL) {

Dropping those would mean that the injection read (and write) below
would happen on any value written. Let's keep them and enforce a write
of '1' to be only valid injection trigger like the rest of the /sysfs
interfaces:

	ret = kstrtou8(data, 10, &value);
	if (ret < 0)
		return ret;

	if (value != 1)
		return -EINVAL;

>  
> -		/* Form value to choose 16-byte section of cacheline */
> -		section = F10_NB_ARRAY_DRAM_ECC |
> -				SET_NB_ARRAY_ADDRESS(pvt->injection.section);
> -		pci_write_config_dword(pvt->F3, F10_NB_ARRAY_ADDR, section);
> +	/* Form value to choose 16-byte section of cacheline */
> +	section = F10_NB_ARRAY_DRAM_ECC |
> +		SET_NB_ARRAY_ADDRESS(pvt->injection.section);
> +	pci_write_config_dword(pvt->F3, F10_NB_ARRAY_ADDR, section);
>  
> -		word_bits = SET_NB_DRAM_INJECTION_READ(pvt->injection.word,
> -						pvt->injection.bit_map);
> +	word_bits = SET_NB_DRAM_INJECTION_READ(pvt->injection.word,
> +			pvt->injection.bit_map);
>  
> -		/* Issue 'word' and 'bit' along with the READ request */
> -		pci_write_config_dword(pvt->F3, F10_NB_ARRAY_DATA, word_bits);
> +	/* Issue 'word' and 'bit' along with the READ request */
> +	pci_write_config_dword(pvt->F3, F10_NB_ARRAY_DATA, word_bits);
>  
> -		debugf0("section=0x%x word_bits=0x%x\n", section, word_bits);
> +	debugf0("section=0x%x word_bits=0x%x\n", section, word_bits);
>  
> -		return count;
> -	}
> -	return ret;
> +	return count;
>  }
>  
>  /*
> @@ -140,29 +124,22 @@ static ssize_t amd64_inject_write_store(struct mem_ctl_info *mci,
>  					const char *data, size_t count)
>  {
>  	struct amd64_pvt *pvt = mci->pvt_info;
> -	unsigned long value;
>  	u32 section, word_bits;
> -	int ret = 0;
> -
> -	ret = strict_strtoul(data, 10, &value);
> -	if (ret != -EINVAL) {

Same as above.

>  
> -		/* Form value to choose 16-byte section of cacheline */
> -		section = F10_NB_ARRAY_DRAM_ECC |
> -				SET_NB_ARRAY_ADDRESS(pvt->injection.section);
> -		pci_write_config_dword(pvt->F3, F10_NB_ARRAY_ADDR, section);
> +	/* Form value to choose 16-byte section of cacheline */
> +	section = F10_NB_ARRAY_DRAM_ECC |
> +		SET_NB_ARRAY_ADDRESS(pvt->injection.section);
> +	pci_write_config_dword(pvt->F3, F10_NB_ARRAY_ADDR, section);
>  
> -		word_bits = SET_NB_DRAM_INJECTION_WRITE(pvt->injection.word,
> -						pvt->injection.bit_map);
> +	word_bits = SET_NB_DRAM_INJECTION_WRITE(pvt->injection.word,
> +			pvt->injection.bit_map);
>  
> -		/* Issue 'word' and 'bit' along with the READ request */
> -		pci_write_config_dword(pvt->F3, F10_NB_ARRAY_DATA, word_bits);
> +	/* Issue 'word' and 'bit' along with the READ request */
> +	pci_write_config_dword(pvt->F3, F10_NB_ARRAY_DATA, word_bits);
>  
> -		debugf0("section=0x%x word_bits=0x%x\n", section, word_bits);
> +	debugf0("section=0x%x word_bits=0x%x\n", section, word_bits);
>  
> -		return count;
> -	}
> -	return ret;
> +	return count;
>  }
>  
>  /*
> @@ -197,17 +174,15 @@ struct mcidev_sysfs_attribute amd64_inj_attrs[] = {
>  	{
>  		.attr = {
>  			.name = "inject_write",
> -			.mode = (S_IRUGO | S_IWUSR)
> +			.mode = S_IWUSR,

This change is not mentioned anywhere, why do we need it?

>  		},
> -		.show = NULL,
>  		.store = amd64_inject_write_store,
>  	},
>  	{
>  		.attr = {
>  			.name = "inject_read",
> -			.mode = (S_IRUGO | S_IWUSR)
> +			.mode = S_IWUSR,

ditto.

>  		},
> -		.show = NULL,
>  		.store = amd64_inject_read_store,
>  	},
>  };

Ok, provided the general change to kstrtoX is agreed upon, you can add
my Acked-by to the AMD EDAC changes pending the issues above.

Thanks.

-- 
Regards/Gruss,
    Boris.

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 16/52] kstrtox: convert drivers/edac/
  2011-02-05 17:34   ` Borislav Petkov
@ 2011-02-06 18:52     ` Alexey Dobriyan
  2011-02-07  9:43       ` Borislav Petkov
  0 siblings, 1 reply; 58+ messages in thread
From: Alexey Dobriyan @ 2011-02-06 18:52 UTC (permalink / raw)
  To: Borislav Petkov, akpm, linux-kernel, borislav.petkov

On Sat, Feb 05, 2011 at 06:34:49PM +0100, Borislav Petkov wrote:
> On Sat, Feb 05, 2011 at 04:20:19PM +0200, Alexey Dobriyan wrote:
> 
> Some kind of a boilerplate commit message is still better than none at all.
> 
> > 
> > Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
> > ---
> >  drivers/edac/amd64_edac_inj.c |  135 +++++++++++++++++------------------------
> >  drivers/edac/edac_mc_sysfs.c  |   20 +++---
> >  drivers/edac/i7core_edac.c    |   41 +++++++------
> >  drivers/edac/mce_amd_inj.c    |   28 ++++-----
> >  4 files changed, 101 insertions(+), 123 deletions(-)
> > 
> > diff --git a/drivers/edac/amd64_edac_inj.c b/drivers/edac/amd64_edac_inj.c
> > index 688478d..180a498 100644
> > --- a/drivers/edac/amd64_edac_inj.c
> > +++ b/drivers/edac/amd64_edac_inj.c
> > @@ -16,21 +16,18 @@ static ssize_t amd64_inject_section_store(struct mem_ctl_info *mci,
> >  					  const char *data, size_t count)
> >  {
> >  	struct amd64_pvt *pvt = mci->pvt_info;
> > -	unsigned long value;
> > -	int ret = 0;
> > -
> > -	ret = strict_strtoul(data, 10, &value);
> > -	if (ret != -EINVAL) {
> > -
> > -		if (value > 3) {
> > -			amd64_warn("%s: invalid section 0x%lx\n", __func__, value);
> > -			return -EINVAL;
> > -		}
> > -
> > -		pvt->injection.section = (u32) value;
> > -		return count;
> > +	u32 value;
> > +	int ret;
> > +
> > +	ret = kstrtou32(data, 10, &value);
> > +	if (ret < 0)
> > +		return ret;
> 
> newline here

A what? Why?

> > @@ -107,29 +98,22 @@ static ssize_t amd64_inject_read_store(struct mem_ctl_info *mci,
> >  					const char *data, size_t count)
> >  {
> >  	struct amd64_pvt *pvt = mci->pvt_info;
> > -	unsigned long value;
> >  	u32 section, word_bits;
> > -	int ret = 0;
> > -
> > -	ret = strict_strtoul(data, 10, &value);
> > -	if (ret != -EINVAL) {
> 
> Dropping those would mean that the injection read (and write) below
> would happen on any value written.

Yes, since the value written is unused, and all data were already
written via other files.

> Let's keep them and enforce a write
> of '1' to be only valid injection trigger like the rest of the /sysfs
> interfaces:

Right now, any number will do, so in fact it'd be better to use kstrtoul().

> 	ret = kstrtou8(data, 10, &value);
> 	if (ret < 0)
> 		return ret;
> 
> 	if (value != 1)
> 		return -EINVAL;
> > @@ -197,17 +174,15 @@ struct mcidev_sysfs_attribute amd64_inj_attrs[] = {
> >  	{
> >  		.attr = {
> >  			.name = "inject_write",
> > -			.mode = (S_IRUGO | S_IWUSR)
> > +			.mode = S_IWUSR,
> 
> This change is not mentioned anywhere, why do we need it?

File is write-only. I'll mention this in changelog.

> > -		.show = NULL,
> >  		.store = amd64_inject_write_store,
> >  	},
> >  	{
> >  		.attr = {
> >  			.name = "inject_read",
> > -			.mode = (S_IRUGO | S_IWUSR)
> > +			.mode = S_IWUSR,


^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 16/52] kstrtox: convert drivers/edac/
  2011-02-06 18:52     ` Alexey Dobriyan
@ 2011-02-07  9:43       ` Borislav Petkov
  0 siblings, 0 replies; 58+ messages in thread
From: Borislav Petkov @ 2011-02-07  9:43 UTC (permalink / raw)
  To: Alexey Dobriyan; +Cc: Borislav Petkov, akpm, linux-kernel, Petkov, Borislav

On Sun, Feb 06, 2011 at 01:52:52PM -0500, Alexey Dobriyan wrote:
> On Sat, Feb 05, 2011 at 06:34:49PM +0100, Borislav Petkov wrote:
> > On Sat, Feb 05, 2011 at 04:20:19PM +0200, Alexey Dobriyan wrote:
> > 
> > Some kind of a boilerplate commit message is still better than none at all.
> > 
> > > 
> > > Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
> > > ---
> > >  drivers/edac/amd64_edac_inj.c |  135 +++++++++++++++++------------------------
> > >  drivers/edac/edac_mc_sysfs.c  |   20 +++---
> > >  drivers/edac/i7core_edac.c    |   41 +++++++------
> > >  drivers/edac/mce_amd_inj.c    |   28 ++++-----
> > >  4 files changed, 101 insertions(+), 123 deletions(-)
> > > 
> > > diff --git a/drivers/edac/amd64_edac_inj.c b/drivers/edac/amd64_edac_inj.c
> > > index 688478d..180a498 100644
> > > --- a/drivers/edac/amd64_edac_inj.c
> > > +++ b/drivers/edac/amd64_edac_inj.c
> > > @@ -16,21 +16,18 @@ static ssize_t amd64_inject_section_store(struct mem_ctl_info *mci,
> > >  					  const char *data, size_t count)
> > >  {
> > >  	struct amd64_pvt *pvt = mci->pvt_info;
> > > -	unsigned long value;
> > > -	int ret = 0;
> > > -
> > > -	ret = strict_strtoul(data, 10, &value);
> > > -	if (ret != -EINVAL) {
> > > -
> > > -		if (value > 3) {
> > > -			amd64_warn("%s: invalid section 0x%lx\n", __func__, value);
> > > -			return -EINVAL;
> > > -		}
> > > -
> > > -		pvt->injection.section = (u32) value;
> > > -		return count;
> > > +	u32 value;
> > > +	int ret;
> > > +
> > > +	ret = kstrtou32(data, 10, &value);
> > > +	if (ret < 0)
> > > +		return ret;
> > 
> > newline here
> 
> A what? Why?

Hmm, let me see, better readability.

> 
> > > @@ -107,29 +98,22 @@ static ssize_t amd64_inject_read_store(struct mem_ctl_info *mci,
> > >  					const char *data, size_t count)
> > >  {
> > >  	struct amd64_pvt *pvt = mci->pvt_info;
> > > -	unsigned long value;
> > >  	u32 section, word_bits;
> > > -	int ret = 0;
> > > -
> > > -	ret = strict_strtoul(data, 10, &value);
> > > -	if (ret != -EINVAL) {
> > 
> > Dropping those would mean that the injection read (and write) below
> > would happen on any value written.
> 
> Yes, since the value written is unused, and all data were already
> written via other files.
> 
> > Let's keep them and enforce a write
> > of '1' to be only valid injection trigger like the rest of the /sysfs
> > interfaces:
> 
> Right now, any number will do, so in fact it'd be better to use kstrtoul().

Ok, let's accept only a "1" though.

> 
> > 	ret = kstrtou8(data, 10, &value);
> > 	if (ret < 0)
> > 		return ret;
> > 
> > 	if (value != 1)
> > 		return -EINVAL;
> > > @@ -197,17 +174,15 @@ struct mcidev_sysfs_attribute amd64_inj_attrs[] = {
> > >  	{
> > >  		.attr = {
> > >  			.name = "inject_write",
> > > -			.mode = (S_IRUGO | S_IWUSR)
> > > +			.mode = S_IWUSR,
> > 
> > This change is not mentioned anywhere, why do we need it?
> 
> File is write-only. I'll mention this in changelog.

Ok, actually, come to think of it, it would be even better if it would
show what values are written to the injection registers so I'll supply
->show methods for them. You can drop this hunk changing file perms from
your patch.

Thanks.


-- 
Regards/Gruss,
Boris.

Advanced Micro Devices GmbH
Einsteinring 24, 85609 Dornach
General Managers: Alberto Bozzo, Andrew Bowd
Registration: Dornach, Gemeinde Aschheim, Landkreis Muenchen
Registergericht Muenchen, HRB Nr. 43632

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH 46/52] kstrtox: convert microblaze
  2011-02-05 14:20 ` [PATCH 46/52] kstrtox: convert microblaze Alexey Dobriyan
@ 2011-02-10 13:55   ` Michal Simek
  0 siblings, 0 replies; 58+ messages in thread
From: Michal Simek @ 2011-02-10 13:55 UTC (permalink / raw)
  To: Alexey Dobriyan; +Cc: akpm, linux-kernel

Alexey Dobriyan wrote:
> Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>

you forget to CC me. I will test it.

Michal

> ---
>  arch/microblaze/kernel/traps.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/arch/microblaze/kernel/traps.c b/arch/microblaze/kernel/traps.c
> index ba034d4..ac81870 100644
> --- a/arch/microblaze/kernel/traps.c
> +++ b/arch/microblaze/kernel/traps.c
> @@ -27,7 +27,7 @@ static unsigned long kstack_depth_to_print;	/* 0 == entire stack */
>  
>  static int __init kstack_setup(char *s)
>  {
> -	return !strict_strtoul(s, 0, &kstack_depth_to_print);
> +	return !kstrtoul(s, 0, &kstack_depth_to_print);
>  }
>  __setup("kstack=", kstack_setup);
>  


-- 
Michal Simek, Ing. (M.Eng)
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel 2.6 Microblaze Linux - http://www.monstr.eu/fdt/
Microblaze U-BOOT custodian

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [40/52] kstrtox: convert drivers/usb/
  2011-02-05 14:20 ` [PATCH 40/52] kstrtox: convert drivers/usb/ Alexey Dobriyan
@ 2011-04-14 10:31   ` Michal Nazarewicz
  0 siblings, 0 replies; 58+ messages in thread
From: Michal Nazarewicz @ 2011-04-14 10:31 UTC (permalink / raw)
  To: akpm, Alexey Dobriyan; +Cc: linux-kernel, linux-usb

On Sat, 05 Feb 2011 15:20:43 +0100, Alexey Dobriyan <adobriyan@gmail.com>  
wrote:

> Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
>
> ---
> drivers/usb/gadget/storage_common.c |    7 ++++---

I haven't notice your patch (wasn't sent to linux-usb?) and changed this
file already -- patch is in Greg's tree.

>  drivers/usb/host/ehci-dbg.c         |    6 +++---
>  drivers/usb/serial/iuu_phoenix.c    |   27 ++++++++++-----------------
>  3 files changed, 17 insertions(+), 23 deletions(-)
>
> diff --git a/drivers/usb/gadget/storage_common.c  
> b/drivers/usb/gadget/storage_common.c
> index b015561..ed81718 100644
> --- a/drivers/usb/gadget/storage_common.c
> +++ b/drivers/usb/gadget/storage_common.c
> @@ -713,8 +713,9 @@ static ssize_t fsg_store_ro(struct device *dev,  
> struct device_attribute *attr,
>  	struct rw_semaphore	*filesem = dev_get_drvdata(dev);
>  	unsigned long	ro;
> -	if (strict_strtoul(buf, 2, &ro))
> -		return -EINVAL;
> +	rc = kstrtoul(buf, 2, &ro);
> +	if (rc < 0)
> +		return rc;
> 	/*
>  	 * Allow the write-enable status to change only while the

Also, this is actually incorrect -- it zeroes rc which it should not
do.  I made the same mistake at first. ;)

> @@ -740,7 +741,7 @@ static ssize_t fsg_store_nofua(struct device *dev,
>  	struct fsg_lun	*curlun = fsg_lun_from_dev(dev);
>  	unsigned long	nofua;
> -	if (strict_strtoul(buf, 2, &nofua))
> +	if (kstrtoul(buf, 2, &nofua))
>  		return -EINVAL;
> 	/* Sync data when switching from async mode to sync */


> diff --git a/drivers/usb/host/ehci-dbg.c b/drivers/usb/host/ehci-dbg.c
> @@ -1000,7 +1000,7 @@ static ssize_t debug_lpm_write(struct file *file,  
> const char __user *user_buf,
>  		buf[len - 1] = '\0';
> 	if (strncmp(buf, "enable", 5) == 0) {
> -		if (strict_strtoul(buf + 7, 10, &port))
> +		if (kstrtoul(buf + 7, 10, &port))
>  			return -EINVAL;
>  		params = ehci_readl(ehci, &ehci->caps->hcs_params);
>  		if (port > HCS_N_PORTS(params)) {
> @@ -1018,7 +1018,7 @@ static ssize_t debug_lpm_write(struct file *file,  
> const char __user *user_buf,
>  		printk(KERN_INFO "force enable LPM for port %lu\n", port);
>  	} else if (strncmp(buf, "hird=", 5) == 0) {
>  		unsigned long hird;
> -		if (strict_strtoul(buf + 5, 16, &hird))
> +		if (kstrtoul(buf + 5, 16, &hird))
>  			return -EINVAL;
>  		printk(KERN_INFO "setting hird %s %lu\n", buf + 6, hird);
>  		temp = ehci_readl(ehci, &ehci->regs->command);
> @@ -1026,7 +1026,7 @@ static ssize_t debug_lpm_write(struct file *file,  
> const char __user *user_buf,
>  		temp |= hird << 24;
>  		ehci_writel(ehci, temp, &ehci->regs->command);
>  	} else if (strncmp(buf, "disable", 7) == 0) {
> -		if (strict_strtoul(buf + 8, 10, &port))
> +		if (kstrtoul(buf + 8, 10, &port))
>  			return -EINVAL;
>  		params = ehci_readl(ehci, &ehci->caps->hcs_params);
>  		if (port > HCS_N_PORTS(params)) {

I'm wondering if we care about loosing the possible -ERANGE.

-- 
Best regards,                                         _     _
.o. | Liege of Serenely Enlightened Majesty of      o' \,=./ `o
..o | Computer Science,  Michal "mina86" Nazarewicz    (o o)
ooo +-----<email/xmpp: mnazarewicz@google.com>-----ooO--(_)--Ooo--

^ permalink raw reply	[flat|nested] 58+ messages in thread

end of thread, other threads:[~2011-04-14 10:31 UTC | newest]

Thread overview: 58+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-05 14:20 [PATCH 01/52] kstrtox: converting strings to integers done (hopefully) right Alexey Dobriyan
2011-02-05 14:20 ` [PATCH 02/52] kstrtox: convert kernel/ Alexey Dobriyan
2011-02-05 14:20 ` [PATCH 03/52] kstrtox: convert kernel/trace/ Alexey Dobriyan
2011-02-05 14:20 ` [PATCH 04/52] kstrtox: convert mm/ Alexey Dobriyan
2011-02-05 14:20 ` [PATCH 05/52] kstrtox: convert block/ Alexey Dobriyan
2011-02-05 14:20 ` [PATCH 06/52] kstrtox: convert security/ Alexey Dobriyan
2011-02-05 14:20 ` [PATCH 07/52] kstrtox: convert fs/fuse/ Alexey Dobriyan
2011-02-05 14:20 ` [PATCH 08/52] kstrtox: convert fs/nfs/ Alexey Dobriyan
2011-02-05 14:20 ` [PATCH 09/52] kstrtox: convert fs/proc/ Alexey Dobriyan
2011-02-05 14:20 ` [PATCH 10/52] kstrtox: convert drivers/acpi/ Alexey Dobriyan
2011-02-05 14:20 ` [PATCH 11/52] kstrtox: convert drivers/ata/ Alexey Dobriyan
2011-02-05 14:20 ` [PATCH 12/52] kstrtox: convert drivers/base/ Alexey Dobriyan
2011-02-05 14:20 ` [PATCH 13/52] kstrtox: convert drivers/block/ Alexey Dobriyan
2011-02-05 14:20 ` [PATCH 14/52] kstrtox: convert drivers/bluetooth/ Alexey Dobriyan
2011-02-05 14:20 ` [PATCH 15/52] kstrtox: convert drivers/clocksource/ Alexey Dobriyan
2011-02-05 14:20 ` [PATCH 16/52] kstrtox: convert drivers/edac/ Alexey Dobriyan
2011-02-05 17:34   ` Borislav Petkov
2011-02-06 18:52     ` Alexey Dobriyan
2011-02-07  9:43       ` Borislav Petkov
2011-02-05 14:20 ` [PATCH 17/52] kstrtox: convert drivers/gpio/ Alexey Dobriyan
2011-02-05 14:20 ` [PATCH 18/52] kstrtox: convert drivers/gpu/drm/nouveau/ Alexey Dobriyan
2011-02-05 14:20 ` [PATCH 19/52] kstrtox: convert drivers/hid/ Alexey Dobriyan
2011-02-05 14:20 ` [PATCH 20/52] kstrtox: convert drivers/hwmon/ Alexey Dobriyan
2011-02-05 14:20 ` [PATCH 21/52] kstrtox: convert drivers/ide/ Alexey Dobriyan
2011-02-05 14:20 ` [PATCH 22/52] kstrtox: convert drivers/infiniband/ Alexey Dobriyan
2011-02-05 14:20 ` [PATCH 23/52] kstrtox: convert drivers/input/ Alexey Dobriyan
2011-02-05 14:20 ` [PATCH 24/52] kstrtox: convert drivers/isdn/ Alexey Dobriyan
2011-02-05 14:20 ` [PATCH 25/52] kstrtox: convert drivers/leds/ Alexey Dobriyan
2011-02-05 14:20 ` [PATCH 26/52] kstrtox: convert drivers/macintosh/ Alexey Dobriyan
2011-02-05 14:20 ` [PATCH 27/52] kstrtox: convert drivers/md/ Alexey Dobriyan
2011-02-05 14:20 ` [PATCH 28/52] kstrtox: convert drivers/mfd/ Alexey Dobriyan
2011-02-05 14:20 ` [PATCH 29/52] kstrtox: convert drivers/misc/ Alexey Dobriyan
2011-02-05 14:20 ` [PATCH 30/52] kstrtox: convert drivers/mmc/ Alexey Dobriyan
2011-02-05 14:20 ` [PATCH 31/52] kstrtox: convert drivers/net/ Alexey Dobriyan
2011-02-05 14:20 ` [PATCH 32/52] kstrtox: convert drivers/net/wireless/ Alexey Dobriyan
2011-02-05 14:20 ` [PATCH 33/52] kstrtox: convert drivers/pci/ Alexey Dobriyan
2011-02-05 14:20 ` [PATCH 34/52] kstrtox: convert drivers/power/ Alexey Dobriyan
2011-02-05 14:20 ` [PATCH 35/52] kstrtox: convert drivers/regulator/ Alexey Dobriyan
2011-02-05 14:20 ` [PATCH 36/52] kstrtox: convert drivers/rtc/ Alexey Dobriyan
2011-02-05 14:20 ` [PATCH 37/52] kstrtox: convert drivers/scsi/ Alexey Dobriyan
2011-02-05 14:20 ` [PATCH 38/52] kstrtox: convert drivers/ssb/ Alexey Dobriyan
2011-02-05 14:20 ` [PATCH 39/52] kstrtox: convert drivers/target/ Alexey Dobriyan
2011-02-05 14:20 ` [PATCH 40/52] kstrtox: convert drivers/usb/ Alexey Dobriyan
2011-04-14 10:31   ` [40/52] " Michal Nazarewicz
2011-02-05 14:20 ` [PATCH 41/52] kstrtox: convert drivers/video/ Alexey Dobriyan
2011-02-05 14:20 ` [PATCH 42/52] kstrtox: convert drivers/w1/ Alexey Dobriyan
2011-02-05 14:20 ` [PATCH 43/52] kstrtox: convert sound/ Alexey Dobriyan
2011-02-05 14:20 ` [PATCH 44/52] kstrtox: convert net/ Alexey Dobriyan
2011-02-05 14:20 ` [PATCH 45/52] kstrtox: convert arm Alexey Dobriyan
2011-02-05 14:20 ` [PATCH 46/52] kstrtox: convert microblaze Alexey Dobriyan
2011-02-10 13:55   ` Michal Simek
2011-02-05 14:20 ` [PATCH 47/52] kstrtox: convert mips Alexey Dobriyan
2011-02-05 14:20 ` [PATCH 48/52] kstrtox: convert powerpc Alexey Dobriyan
2011-02-05 14:20 ` [PATCH 49/52] kstrtox: convert s390 Alexey Dobriyan
2011-02-05 14:20 ` [PATCH 50/52] kstrtox: convert tile Alexey Dobriyan
2011-02-05 14:20 ` [PATCH 51/52] kstrtox: convert x86 Alexey Dobriyan
2011-02-05 14:33 ` [PATCH 01/52] kstrtox: converting strings to integers done (hopefully) right Geert Uytterhoeven
2011-02-05 14:40   ` Alexey Dobriyan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).