Skip to content

Commit a8bc8cc

Browse files
tititiou36gregkh
authored andcommitted
usb: gadget: 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/09bc980d8432a4b5f7d88388ec0df5b085583139.1667336095.git.christophe.jaillet@wanadoo.fr Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 372488c commit a8bc8cc

File tree

5 files changed

+13
-8
lines changed

5 files changed

+13
-8
lines changed

drivers/usb/gadget/configfs.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include <linux/module.h>
44
#include <linux/slab.h>
55
#include <linux/device.h>
6+
#include <linux/kstrtox.h>
67
#include <linux/nls.h>
78
#include <linux/usb/composite.h>
89
#include <linux/usb/gadget_configfs.h>
@@ -800,7 +801,7 @@ static ssize_t os_desc_use_store(struct config_item *item, const char *page,
800801
bool use;
801802

802803
mutex_lock(&gi->lock);
803-
ret = strtobool(page, &use);
804+
ret = kstrtobool(page, &use);
804805
if (!ret) {
805806
gi->use_os_desc = use;
806807
ret = len;

drivers/usb/gadget/function/f_mass_storage.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@
176176
#include <linux/fcntl.h>
177177
#include <linux/file.h>
178178
#include <linux/fs.h>
179+
#include <linux/kstrtox.h>
179180
#include <linux/kthread.h>
180181
#include <linux/sched/signal.h>
181182
#include <linux/limits.h>
@@ -3387,7 +3388,7 @@ static ssize_t fsg_opts_stall_store(struct config_item *item, const char *page,
33873388
return -EBUSY;
33883389
}
33893390

3390-
ret = strtobool(page, &stall);
3391+
ret = kstrtobool(page, &stall);
33913392
if (!ret) {
33923393
opts->common->can_stall = stall;
33933394
ret = len;

drivers/usb/gadget/function/storage_common.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <linux/blkdev.h>
2424
#include <linux/file.h>
2525
#include <linux/fs.h>
26+
#include <linux/kstrtox.h>
2627
#include <linux/usb/composite.h>
2728

2829
#include "storage_common.h"
@@ -396,7 +397,7 @@ ssize_t fsg_store_ro(struct fsg_lun *curlun, struct rw_semaphore *filesem,
396397
ssize_t rc;
397398
bool ro;
398399

399-
rc = strtobool(buf, &ro);
400+
rc = kstrtobool(buf, &ro);
400401
if (rc)
401402
return rc;
402403

@@ -419,7 +420,7 @@ ssize_t fsg_store_nofua(struct fsg_lun *curlun, const char *buf, size_t count)
419420
bool nofua;
420421
int ret;
421422

422-
ret = strtobool(buf, &nofua);
423+
ret = kstrtobool(buf, &nofua);
423424
if (ret)
424425
return ret;
425426

@@ -470,7 +471,7 @@ ssize_t fsg_store_cdrom(struct fsg_lun *curlun, struct rw_semaphore *filesem,
470471
bool cdrom;
471472
int ret;
472473

473-
ret = strtobool(buf, &cdrom);
474+
ret = kstrtobool(buf, &cdrom);
474475
if (ret)
475476
return ret;
476477

@@ -493,7 +494,7 @@ ssize_t fsg_store_removable(struct fsg_lun *curlun, const char *buf,
493494
bool removable;
494495
int ret;
495496

496-
ret = strtobool(buf, &removable);
497+
ret = kstrtobool(buf, &removable);
497498
if (ret)
498499
return ret;
499500

drivers/usb/gadget/function/u_serial.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <linux/export.h>
2525
#include <linux/module.h>
2626
#include <linux/console.h>
27+
#include <linux/kstrtox.h>
2728
#include <linux/kthread.h>
2829
#include <linux/workqueue.h>
2930
#include <linux/kfifo.h>
@@ -1070,7 +1071,7 @@ ssize_t gserial_set_console(unsigned char port_num, const char *page, size_t cou
10701071
bool enable;
10711072
int ret;
10721073

1073-
ret = strtobool(page, &enable);
1074+
ret = kstrtobool(page, &enable);
10741075
if (ret)
10751076
return ret;
10761077

drivers/usb/gadget/legacy/serial.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
#include <linux/kernel.h>
1111
#include <linux/device.h>
12+
#include <linux/kstrtox.h>
1213
#include <linux/module.h>
1314
#include <linux/tty.h>
1415
#include <linux/tty_flip.h>
@@ -109,7 +110,7 @@ static int enable_set(const char *s, const struct kernel_param *kp)
109110
if (!s) /* called for no-arg enable == default */
110111
return 0;
111112

112-
ret = strtobool(s, &do_enable);
113+
ret = kstrtobool(s, &do_enable);
113114
if (ret || enable == do_enable)
114115
return ret;
115116

0 commit comments

Comments
 (0)