Skip to content

Commit 372488c

Browse files
tititiou36gregkh
authored andcommitted
usb: core: Use kstrtobool() instead of strtobool()
strtobool() is the same as kstrtobool(). However, the latter is more used within the kernel. In order to remove strtobool() and slightly simplify kstrtox.h, switch to the other function name. While at it, include the corresponding header file (<linux/kstrtox.h>) Signed-off-by: Christophe JAILLET <[email protected]> Link: https://lore.kernel.org/r/f01ef2ddaf12a6412127611617786adc1234e0b4.1667336095.git.christophe.jaillet@wanadoo.fr Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 7a09c12 commit 372488c

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

drivers/usb/core/port.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* Author: Lan Tianyu <[email protected]>
88
*/
99

10+
#include <linux/kstrtox.h>
1011
#include <linux/slab.h>
1112
#include <linux/pm_qos.h>
1213
#include <linux/component.h>
@@ -63,7 +64,7 @@ static ssize_t disable_store(struct device *dev, struct device_attribute *attr,
6364
bool disabled;
6465
int rc;
6566

66-
rc = strtobool(buf, &disabled);
67+
rc = kstrtobool(buf, &disabled);
6768
if (rc)
6869
return rc;
6970

drivers/usb/core/sysfs.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414

1515
#include <linux/kernel.h>
16+
#include <linux/kstrtox.h>
1617
#include <linux/string.h>
1718
#include <linux/usb.h>
1819
#include <linux/usb/hcd.h>
@@ -505,7 +506,7 @@ static ssize_t usb2_hardware_lpm_store(struct device *dev,
505506
if (ret < 0)
506507
return -EINTR;
507508

508-
ret = strtobool(buf, &value);
509+
ret = kstrtobool(buf, &value);
509510

510511
if (!ret) {
511512
udev->usb2_hw_lpm_allowed = value;
@@ -975,7 +976,7 @@ static ssize_t interface_authorized_default_store(struct device *dev,
975976
int rc = count;
976977
bool val;
977978

978-
if (strtobool(buf, &val) != 0)
979+
if (kstrtobool(buf, &val) != 0)
979980
return -EINVAL;
980981

981982
if (val)
@@ -1176,7 +1177,7 @@ static ssize_t interface_authorized_store(struct device *dev,
11761177
struct usb_interface *intf = to_usb_interface(dev);
11771178
bool val;
11781179

1179-
if (strtobool(buf, &val) != 0)
1180+
if (kstrtobool(buf, &val) != 0)
11801181
return -EINVAL;
11811182

11821183
if (val)

0 commit comments

Comments
 (0)