Skip to contentSkip to conversation

s390/qeth: use kstrtobool() in qeth_bridgeport_hostnotification_store()

PATCH In review Andy Shevchenko 2 participants 2 messages Oct 4, 2017 – Oct 5, 2017

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 s390/qeth: use kstrtobool() in qeth_bridgeport_hostnotification_store()

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.

---
 drivers/s390/net/qeth_l2_sys.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)
drivers/s390/net/qeth_l2_sys.c +5 -8
index 4608daedb204..470a4e5f3c62 100644
@@ -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);
 
Signature · 1 line
2.14.2
#1 lore raw
Quoted 5 lines · 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.

---

Thanks Andy, queued up for our next upstream submission.