linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] pci: use kstrtobool over ad hoc string parsing
@ 2018-02-12 23:04 Kenny Ballou
  2018-02-19 20:56 ` Kenny Ballou
  2018-02-28  3:32 ` Bjorn Helgaas
  0 siblings, 2 replies; 8+ messages in thread
From: Kenny Ballou @ 2018-02-12 23:04 UTC (permalink / raw)
  To: linux-pci; +Cc: Kenny Ballou, googlegot, bhelgaas

Convert ROM read access enable/disable string parsing to use the
`kstrtobool` function.

This fixes Bugzilla Bug 111301 -- Sysfs PCI rom file functionality does
not match documentation.

bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=111301

Reported-by: googlegot@yahoo.com
Signed-off-by: Kenny Ballou <kballou@devnulllabs.io>
---
 drivers/pci/pci-sysfs.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index eb6bee8724cc..3cde1f25e786 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -1424,10 +1424,12 @@ static ssize_t pci_write_rom(struct file *filp, struct kobject *kobj,
 {
 	struct pci_dev *pdev = to_pci_dev(kobj_to_dev(kobj));
 
-	if ((off ==  0) && (*buf == '0') && (count == 2))
-		pdev->rom_attr_enabled = 0;
-	else
+	bool res = false;
+
+	if (kstrtobool(buf, &res) == 0 && res)
 		pdev->rom_attr_enabled = 1;
+	else
+		pdev->rom_attr_enabled = 0;
 
 	return count;
 }
-- 
2.13.6

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

end of thread, other threads:[~2018-03-05 19:35 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-12 23:04 [PATCH] pci: use kstrtobool over ad hoc string parsing Kenny Ballou
2018-02-19 20:56 ` Kenny Ballou
2018-02-19 21:10   ` Bjorn Helgaas
2018-02-28  3:32 ` Bjorn Helgaas
2018-03-02 23:47   ` Kenny Ballou
2018-03-05 14:28     ` Bjorn Helgaas
2018-03-05 15:15       ` Kenny Ballou
2018-03-05 19:35         ` Bjorn Helgaas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).