Skip to contentSkip to conversation

acpi: Use kstrtoul() instead of strtoul()/simple_strtoul()

PATCH Superseded Guenter Roeck 1 participant 1 message Jul 24, 2015

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 acpi: Use kstrtoul() instead of strtoul()/simple_strtoul()

simple_strtoul() is deprecated; replace with kstrtoul(). Return an error if the value passed to the sysfs attribute is not a number.

Drop the definition of strtoul() since it is no longer needed.

---
 drivers/acpi/sysfs.c            | 8 ++++++--
 include/acpi/platform/aclinux.h | 1 -
 2 files changed, 6 insertions(+), 3 deletions(-)
drivers/acpi/sysfs.c +6 -2
index 0876d77b3206..d6ea5712ec57 100644
@@ -616,8 +616,12 @@ static ssize_t counter_set(struct kobject *kobj,
 			all_counters[index].count = tmp;
 		else
 			result = -EINVAL;
-	} else
-		all_counters[index].count = strtoul(buf, NULL, 0);
+	} else {
+		if (!kstrtoul(buf, 0, &tmp))
+			all_counters[index].count = tmp;
+		else
+			result = -EINVAL;
+	}
 
 	if (ACPI_FAILURE(result))
 		result = -EINVAL;
include/acpi/platform/aclinux.h +0 -1
index 74ba46c8157a..9925c1d5d58f 100644
@@ -119,7 +119,6 @@
 
 #define ACPI_MACHINE_WIDTH          BITS_PER_LONG
 #define ACPI_EXPORT_SYMBOL(symbol)  EXPORT_SYMBOL(symbol);
-#define strtoul                     simple_strtoul
 
 #define acpi_cache_t                        struct kmem_cache
 #define acpi_spinlock                       spinlock_t *
Signature · 1 line
2.1.0