All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] acpi: Use kstrtoul() instead of strtoul()/simple_strtoul()
@ 2015-07-28  0:32 Guenter Roeck
  2015-07-29 17:51   ` [Devel] " Moore, Robert
  2015-08-02  7:16 ` Pavel Machek
  0 siblings, 2 replies; 14+ messages in thread
From: Guenter Roeck @ 2015-07-28  0:32 UTC (permalink / raw)
  To: rjw
  Cc: lenb, robert.moore, lv.zheng, linux-acpi, linux-kernel, devel,
	Guenter Roeck

simple_strtoul() is deprecated; replace with kstrtoul() and kstrtouint().
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.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
v2: An additional use of strtoul() was introduced with commit 4fa4616e.
    Replace it as well.

 drivers/acpi/acpica/evgpeinit.c | 5 +++--
 drivers/acpi/sysfs.c            | 8 ++++++--
 include/acpi/platform/aclinux.h | 1 -
 3 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/acpi/acpica/evgpeinit.c b/drivers/acpi/acpica/evgpeinit.c
index ea4c0d3fca2d..aa1e8c1f2d4a 100644
--- a/drivers/acpi/acpica/evgpeinit.c
+++ b/drivers/acpi/acpica/evgpeinit.c
@@ -326,6 +326,7 @@ acpi_ev_match_gpe_method(acpi_handle obj_handle,
 	u32 gpe_number;
 	char name[ACPI_NAME_SIZE + 1];
 	u8 type;
+	int err;
 
 	ACPI_FUNCTION_TRACE(ev_match_gpe_method);
 
@@ -377,8 +378,8 @@ acpi_ev_match_gpe_method(acpi_handle obj_handle,
 
 	/* 4) The last two characters of the name are the hex GPE Number */
 
-	gpe_number = strtoul(&name[2], NULL, 16);
-	if (gpe_number == ACPI_UINT32_MAX) {
+	er = kstrtouint(&name[2], 16, &gpe_number);
+	if (err < 0 || gpe_number == ACPI_UINT32_MAX) {
 
 		/* Conversion failed; invalid method, just ignore it */
 
diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
index 0876d77b3206..d6ea5712ec57 100644
--- a/drivers/acpi/sysfs.c
+++ b/drivers/acpi/sysfs.c
@@ -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;
diff --git a/include/acpi/platform/aclinux.h b/include/acpi/platform/aclinux.h
index 74ba46c8157a..9925c1d5d58f 100644
--- a/include/acpi/platform/aclinux.h
+++ b/include/acpi/platform/aclinux.h
@@ -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 *
-- 
2.1.0


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

end of thread, other threads:[~2015-11-06 16:22 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-28  0:32 [PATCH v2] acpi: Use kstrtoul() instead of strtoul()/simple_strtoul() Guenter Roeck
2015-07-29 17:51 ` Moore, Robert
2015-07-29 17:51   ` [Devel] " Moore, Robert
2015-07-29 18:38   ` Guenter Roeck
2015-07-29 19:33     ` Moore, Robert
2015-07-29 19:33       ` [Devel] " Moore, Robert
2015-07-29 19:58       ` Guenter Roeck
2015-07-29 20:04         ` Rafael J. Wysocki
2015-07-29 20:37           ` Guenter Roeck
2015-07-29 19:57     ` Rafael J. Wysocki
2015-08-02  7:16 ` Pavel Machek
2015-08-02  8:19   ` Guenter Roeck
2015-11-06 16:21     ` Moore, Robert
2015-11-06 16:21       ` [Devel] " Moore, Robert

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.