Commit 4cc7ecb7f2a60e8deb783b8fbf7c1ae467acb920
Committed by
Linus Torvalds
1 parent
a81a5a17d4
param: convert some "on"/"off" users to strtobool
This changes several users of manual "on"/"off" parsing to use strtobool. Some side-effects: - these uses will now parse y/n/1/0 meaningfully too - the early_param uses will now bubble up parse errors Signed-off-by: Kees Cook <keescook@chromium.org> Acked-by: Heiko Carstens <heiko.carstens@de.ibm.com> Acked-by: Michael Ellerman <mpe@ellerman.id.au> Cc: Amitkumar Karwar <akarwar@marvell.com> Cc: Andy Shevchenko <andy.shevchenko@gmail.com> Cc: Daniel Borkmann <daniel@iogearbox.net> Cc: Joe Perches <joe@perches.com> Cc: Kalle Valo <kvalo@codeaurora.org> Cc: Martin Schwidefsky <schwidefsky@de.ibm.com> Cc: Nishant Sarmukadam <nishants@marvell.com> Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk> Cc: Steve French <sfrench@samba.org> Cc: Stephen Rothwell <sfr@canb.auug.org.au> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Showing 8 changed files with 15 additions and 53 deletions Side-by-side Diff
arch/powerpc/kernel/rtasd.c
... | ... | @@ -49,7 +49,7 @@ |
49 | 49 | static unsigned int event_scan; |
50 | 50 | static unsigned int rtas_event_scan_rate; |
51 | 51 | |
52 | -static int full_rtas_msgs = 0; | |
52 | +static bool full_rtas_msgs; | |
53 | 53 | |
54 | 54 | /* Stop logging to nvram after first fatal error */ |
55 | 55 | static int logging_enabled; /* Until we initialize everything, |
... | ... | @@ -592,12 +592,7 @@ |
592 | 592 | |
593 | 593 | static int __init rtasmsgs_setup(char *str) |
594 | 594 | { |
595 | - if (strcmp(str, "on") == 0) | |
596 | - full_rtas_msgs = 1; | |
597 | - else if (strcmp(str, "off") == 0) | |
598 | - full_rtas_msgs = 0; | |
599 | - | |
600 | - return 1; | |
595 | + return (kstrtobool(str, &full_rtas_msgs) == 0); | |
601 | 596 | } |
602 | 597 | __setup("rtasmsgs=", rtasmsgs_setup); |
arch/powerpc/platforms/pseries/hotplug-cpu.c
... | ... | @@ -47,20 +47,14 @@ |
47 | 47 | |
48 | 48 | static enum cpu_state_vals default_offline_state = CPU_STATE_OFFLINE; |
49 | 49 | |
50 | -static int cede_offline_enabled __read_mostly = 1; | |
50 | +static bool cede_offline_enabled __read_mostly = true; | |
51 | 51 | |
52 | 52 | /* |
53 | 53 | * Enable/disable cede_offline when available. |
54 | 54 | */ |
55 | 55 | static int __init setup_cede_offline(char *str) |
56 | 56 | { |
57 | - if (!strcmp(str, "off")) | |
58 | - cede_offline_enabled = 0; | |
59 | - else if (!strcmp(str, "on")) | |
60 | - cede_offline_enabled = 1; | |
61 | - else | |
62 | - return 0; | |
63 | - return 1; | |
57 | + return (kstrtobool(str, &cede_offline_enabled) == 0); | |
64 | 58 | } |
65 | 59 | |
66 | 60 | __setup("cede_offline=", setup_cede_offline); |
arch/s390/kernel/time.c
... | ... | @@ -1432,7 +1432,7 @@ |
1432 | 1432 | /* |
1433 | 1433 | * Server Time Protocol (STP) code. |
1434 | 1434 | */ |
1435 | -static int stp_online; | |
1435 | +static bool stp_online; | |
1436 | 1436 | static struct stp_sstpi stp_info; |
1437 | 1437 | static void *stp_page; |
1438 | 1438 | |
... | ... | @@ -1443,11 +1443,7 @@ |
1443 | 1443 | |
1444 | 1444 | static int __init early_parse_stp(char *p) |
1445 | 1445 | { |
1446 | - if (strncmp(p, "off", 3) == 0) | |
1447 | - stp_online = 0; | |
1448 | - else if (strncmp(p, "on", 2) == 0) | |
1449 | - stp_online = 1; | |
1450 | - return 0; | |
1446 | + return kstrtobool(p, &stp_online); | |
1451 | 1447 | } |
1452 | 1448 | early_param("stp", early_parse_stp); |
1453 | 1449 |
arch/s390/kernel/topology.c
... | ... | @@ -37,7 +37,7 @@ |
37 | 37 | static void topology_work_fn(struct work_struct *work); |
38 | 38 | static struct sysinfo_15_1_x *tl_info; |
39 | 39 | |
40 | -static int topology_enabled = 1; | |
40 | +static bool topology_enabled = true; | |
41 | 41 | static DECLARE_WORK(topology_work, topology_work_fn); |
42 | 42 | |
43 | 43 | /* |
... | ... | @@ -444,10 +444,7 @@ |
444 | 444 | |
445 | 445 | static int __init early_parse_topology(char *p) |
446 | 446 | { |
447 | - if (strncmp(p, "off", 3)) | |
448 | - return 0; | |
449 | - topology_enabled = 0; | |
450 | - return 0; | |
447 | + return kstrtobool(p, &topology_enabled); | |
451 | 448 | } |
452 | 449 | early_param("topology", early_parse_topology); |
453 | 450 |
arch/x86/kernel/aperture_64.c
... | ... | @@ -227,19 +227,11 @@ |
227 | 227 | return 0; |
228 | 228 | } |
229 | 229 | |
230 | -static int gart_fix_e820 __initdata = 1; | |
230 | +static bool gart_fix_e820 __initdata = true; | |
231 | 231 | |
232 | 232 | static int __init parse_gart_mem(char *p) |
233 | 233 | { |
234 | - if (!p) | |
235 | - return -EINVAL; | |
236 | - | |
237 | - if (!strncmp(p, "off", 3)) | |
238 | - gart_fix_e820 = 0; | |
239 | - else if (!strncmp(p, "on", 2)) | |
240 | - gart_fix_e820 = 1; | |
241 | - | |
242 | - return 0; | |
234 | + return kstrtobool(p, &gart_fix_e820); | |
243 | 235 | } |
244 | 236 | early_param("gart_fix_e820", parse_gart_mem); |
245 | 237 |
include/linux/tick.h
... | ... | @@ -111,7 +111,7 @@ |
111 | 111 | #define TICK_DEP_MASK_CLOCK_UNSTABLE (1 << TICK_DEP_BIT_CLOCK_UNSTABLE) |
112 | 112 | |
113 | 113 | #ifdef CONFIG_NO_HZ_COMMON |
114 | -extern int tick_nohz_enabled; | |
114 | +extern bool tick_nohz_enabled; | |
115 | 115 | extern int tick_nohz_tick_stopped(void); |
116 | 116 | extern void tick_nohz_idle_enter(void); |
117 | 117 | extern void tick_nohz_idle_exit(void); |
kernel/time/hrtimer.c
... | ... | @@ -515,7 +515,7 @@ |
515 | 515 | /* |
516 | 516 | * High resolution timer enabled ? |
517 | 517 | */ |
518 | -static int hrtimer_hres_enabled __read_mostly = 1; | |
518 | +static bool hrtimer_hres_enabled __read_mostly = true; | |
519 | 519 | unsigned int hrtimer_resolution __read_mostly = LOW_RES_NSEC; |
520 | 520 | EXPORT_SYMBOL_GPL(hrtimer_resolution); |
521 | 521 | |
... | ... | @@ -524,13 +524,7 @@ |
524 | 524 | */ |
525 | 525 | static int __init setup_hrtimer_hres(char *str) |
526 | 526 | { |
527 | - if (!strcmp(str, "off")) | |
528 | - hrtimer_hres_enabled = 0; | |
529 | - else if (!strcmp(str, "on")) | |
530 | - hrtimer_hres_enabled = 1; | |
531 | - else | |
532 | - return 0; | |
533 | - return 1; | |
527 | + return (kstrtobool(str, &hrtimer_hres_enabled) == 0); | |
534 | 528 | } |
535 | 529 | |
536 | 530 | __setup("highres=", setup_hrtimer_hres); |
kernel/time/tick-sched.c
... | ... | @@ -486,20 +486,14 @@ |
486 | 486 | /* |
487 | 487 | * NO HZ enabled ? |
488 | 488 | */ |
489 | -int tick_nohz_enabled __read_mostly = 1; | |
489 | +bool tick_nohz_enabled __read_mostly = true; | |
490 | 490 | unsigned long tick_nohz_active __read_mostly; |
491 | 491 | /* |
492 | 492 | * Enable / Disable tickless mode |
493 | 493 | */ |
494 | 494 | static int __init setup_tick_nohz(char *str) |
495 | 495 | { |
496 | - if (!strcmp(str, "off")) | |
497 | - tick_nohz_enabled = 0; | |
498 | - else if (!strcmp(str, "on")) | |
499 | - tick_nohz_enabled = 1; | |
500 | - else | |
501 | - return 0; | |
502 | - return 1; | |
496 | + return (kstrtobool(str, &tick_nohz_enabled) == 0); | |
503 | 497 | } |
504 | 498 | |
505 | 499 | __setup("nohz=", setup_tick_nohz); |