From patchwork Tue Jul 28 00:32:22 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 6878791 X-Patchwork-Delegate: rjw@sisk.pl Return-Path: X-Original-To: patchwork-linux-acpi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 599149F39D for ; Tue, 28 Jul 2015 00:32:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 836F920606 for ; Tue, 28 Jul 2015 00:32:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6E576205EF for ; Tue, 28 Jul 2015 00:32:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754791AbbG1Ac3 (ORCPT ); Mon, 27 Jul 2015 20:32:29 -0400 Received: from bh-25.webhostbox.net ([208.91.199.152]:50698 "EHLO bh-25.webhostbox.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754629AbbG1Ac2 (ORCPT ); Mon, 27 Jul 2015 20:32:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=roeck-us.net; s=default; h=Message-Id:Date:Subject:Cc:To:From; bh=9SpVYNmjaHCsNtDzMfyZ8BRNd75K0lBJf3IvgBZkwRk=; b=8XillcCo0Es6xS/pGVga2W8sgsGYt5jo9tzhlMr452WotyJuaC1VD+3wO1lxvqvMeuoflupBuCYZ0lrPLpeWlTyb3dmR/3IQMl+YBUsUiuNVj6VBnNSGmL2r9OoahZmo4xArp6qX250Hq3MIzM4TxpinH8pdgkAM6QkWmahlLtM=; Received: from 108-223-40-66.lightspeed.sntcca.sbcglobal.net ([108.223.40.66]:57088 helo=localhost) by bh-25.webhostbox.net with esmtpa (Exim 4.85) (envelope-from ) id 1ZJsol-001PMp-9p; Tue, 28 Jul 2015 00:32:27 +0000 From: Guenter Roeck To: rjw@rjwysocki.net Cc: lenb@kernel.org, robert.moore@intel.com, lv.zheng@intel.com, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, devel@acpica.org, Guenter Roeck Subject: [PATCH v2] acpi: Use kstrtoul() instead of strtoul()/simple_strtoul() Date: Mon, 27 Jul 2015 17:32:22 -0700 Message-Id: <1438043542-2960-1-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.1.0 X-Authenticated_sender: guenter@roeck-us.net X-OutGoing-Spam-Status: No, score=-1.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - bh-25.webhostbox.net X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - roeck-us.net X-Get-Message-Sender-Via: bh-25.webhostbox.net: authenticated_id: guenter@roeck-us.net X-Source: X-Source-Args: X-Source-Dir: Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Spam-Status: No, score=-8.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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 *