From mboxrd@z Thu Jan 1 00:00:00 1970 From: Julian Wiedmann Subject: [PATCH net-next 04/13] s390/qeth: use kstrtobool() in qeth_bridgeport_hostnotification_store() Date: Wed, 18 Oct 2017 17:40:16 +0200 Message-ID: <20171018154025.73630-5-jwi@linux.vnet.ibm.com> References: <20171018154025.73630-1-jwi@linux.vnet.ibm.com> Cc: , , Martin Schwidefsky , Heiko Carstens , Stefan Raspl , Ursula Braun , Julian Wiedmann To: David Miller Return-path: Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:36958 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751881AbdJRPkq (ORCPT ); Wed, 18 Oct 2017 11:40:46 -0400 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v9IFeQRM027076 for ; Wed, 18 Oct 2017 11:40:45 -0400 Received: from e06smtp14.uk.ibm.com (e06smtp14.uk.ibm.com [195.75.94.110]) by mx0a-001b2d01.pphosted.com with ESMTP id 2dp5h61pja-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 18 Oct 2017 11:40:45 -0400 Received: from localhost by e06smtp14.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 18 Oct 2017 16:40:43 +0100 In-Reply-To: <20171018154025.73630-1-jwi@linux.vnet.ibm.com> Sender: netdev-owner@vger.kernel.org List-ID: From: Andy Shevchenko The sysfs enabled value is a boolean, so kstrtobool() is a better fit for parsing the input string since it does the range checking for us. Signed-off-by: Andy Shevchenko Signed-off-by: Julian Wiedmann --- drivers/s390/net/qeth_l2_sys.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/s390/net/qeth_l2_sys.c b/drivers/s390/net/qeth_l2_sys.c index 4608daedb204..470a4e5f3c62 100644 --- a/drivers/s390/net/qeth_l2_sys.c +++ b/drivers/s390/net/qeth_l2_sys.c @@ -146,18 +146,15 @@ static ssize_t qeth_bridgeport_hostnotification_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; - int enable; + bool enable; + int rc; if (!card) return -EINVAL; - if (sysfs_streq(buf, "0")) - enable = 0; - else if (sysfs_streq(buf, "1")) - enable = 1; - else - return -EINVAL; + rc = kstrtobool(buf, &enable); + if (rc) + return rc; mutex_lock(&card->conf_mutex); -- 2.13.5 From mboxrd@z Thu Jan 1 00:00:00 1970 From: Julian Wiedmann Subject: [PATCH net-next 04/13] s390/qeth: use kstrtobool() in qeth_bridgeport_hostnotification_store() Date: Wed, 18 Oct 2017 17:40:16 +0200 Message-ID: <20171018154025.73630-5-jwi@linux.vnet.ibm.com> References: <20171018154025.73630-1-jwi@linux.vnet.ibm.com> Return-path: In-Reply-To: <20171018154025.73630-1-jwi@linux.vnet.ibm.com> Sender: netdev-owner@vger.kernel.org List-Archive: List-Post: To: David Miller Cc: netdev@vger.kernel.org, linux-s390@vger.kernel.org, Martin Schwidefsky , Heiko Carstens , Stefan Raspl , Ursula Braun , Julian Wiedmann List-ID: From: Andy Shevchenko The sysfs enabled value is a boolean, so kstrtobool() is a better fit for parsing the input string since it does the range checking for us. Signed-off-by: Andy Shevchenko Signed-off-by: Julian Wiedmann --- drivers/s390/net/qeth_l2_sys.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/s390/net/qeth_l2_sys.c b/drivers/s390/net/qeth_l2_sys.c index 4608daedb204..470a4e5f3c62 100644 --- a/drivers/s390/net/qeth_l2_sys.c +++ b/drivers/s390/net/qeth_l2_sys.c @@ -146,18 +146,15 @@ static ssize_t qeth_bridgeport_hostnotification_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; - int enable; + bool enable; + int rc; if (!card) return -EINVAL; - if (sysfs_streq(buf, "0")) - enable = 0; - else if (sysfs_streq(buf, "1")) - enable = 1; - else - return -EINVAL; + rc = kstrtobool(buf, &enable); + if (rc) + return rc; mutex_lock(&card->conf_mutex); -- 2.13.5