Skip to content

Commit 4cc7ecb

Browse files
keestorvalds
authored andcommitted
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>
1 parent a81a5a1 commit 4cc7ecb

File tree

8 files changed

+15
-53
lines changed

8 files changed

+15
-53
lines changed

arch/powerpc/kernel/rtasd.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ static unsigned int rtas_error_log_buffer_max;
4949
static unsigned int event_scan;
5050
static unsigned int rtas_event_scan_rate;
5151

52-
static int full_rtas_msgs = 0;
52+
static bool full_rtas_msgs;
5353

5454
/* Stop logging to nvram after first fatal error */
5555
static int logging_enabled; /* Until we initialize everything,
@@ -592,11 +592,6 @@ __setup("surveillance=", surveillance_setup);
592592

593593
static int __init rtasmsgs_setup(char *str)
594594
{
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);
601596
}
602597
__setup("rtasmsgs=", rtasmsgs_setup);

arch/powerpc/platforms/pseries/hotplug-cpu.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,20 +47,14 @@ static DEFINE_PER_CPU(enum cpu_state_vals, current_state) = CPU_STATE_OFFLINE;
4747

4848
static enum cpu_state_vals default_offline_state = CPU_STATE_OFFLINE;
4949

50-
static int cede_offline_enabled __read_mostly = 1;
50+
static bool cede_offline_enabled __read_mostly = true;
5151

5252
/*
5353
* Enable/disable cede_offline when available.
5454
*/
5555
static int __init setup_cede_offline(char *str)
5656
{
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);
6458
}
6559

6660
__setup("cede_offline=", setup_cede_offline);

arch/s390/kernel/time.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1432,7 +1432,7 @@ device_initcall(etr_init_sysfs);
14321432
/*
14331433
* Server Time Protocol (STP) code.
14341434
*/
1435-
static int stp_online;
1435+
static bool stp_online;
14361436
static struct stp_sstpi stp_info;
14371437
static void *stp_page;
14381438

@@ -1443,11 +1443,7 @@ static struct timer_list stp_timer;
14431443

14441444
static int __init early_parse_stp(char *p)
14451445
{
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);
14511447
}
14521448
early_param("stp", early_parse_stp);
14531449

arch/s390/kernel/topology.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ static void set_topology_timer(void);
3737
static void topology_work_fn(struct work_struct *work);
3838
static struct sysinfo_15_1_x *tl_info;
3939

40-
static int topology_enabled = 1;
40+
static bool topology_enabled = true;
4141
static DECLARE_WORK(topology_work, topology_work_fn);
4242

4343
/*
@@ -444,10 +444,7 @@ static const struct cpumask *cpu_book_mask(int cpu)
444444

445445
static int __init early_parse_topology(char *p)
446446
{
447-
if (strncmp(p, "off", 3))
448-
return 0;
449-
topology_enabled = 0;
450-
return 0;
447+
return kstrtobool(p, &topology_enabled);
451448
}
452449
early_param("topology", early_parse_topology);
453450

arch/x86/kernel/aperture_64.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -227,19 +227,11 @@ static u32 __init search_agp_bridge(u32 *order, int *valid_agp)
227227
return 0;
228228
}
229229

230-
static int gart_fix_e820 __initdata = 1;
230+
static bool gart_fix_e820 __initdata = true;
231231

232232
static int __init parse_gart_mem(char *p)
233233
{
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);
243235
}
244236
early_param("gart_fix_e820", parse_gart_mem);
245237

include/linux/tick.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ enum tick_dep_bits {
111111
#define TICK_DEP_MASK_CLOCK_UNSTABLE (1 << TICK_DEP_BIT_CLOCK_UNSTABLE)
112112

113113
#ifdef CONFIG_NO_HZ_COMMON
114-
extern int tick_nohz_enabled;
114+
extern bool tick_nohz_enabled;
115115
extern int tick_nohz_tick_stopped(void);
116116
extern void tick_nohz_idle_enter(void);
117117
extern void tick_nohz_idle_exit(void);

kernel/time/hrtimer.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ static inline ktime_t hrtimer_update_base(struct hrtimer_cpu_base *base)
515515
/*
516516
* High resolution timer enabled ?
517517
*/
518-
static int hrtimer_hres_enabled __read_mostly = 1;
518+
static bool hrtimer_hres_enabled __read_mostly = true;
519519
unsigned int hrtimer_resolution __read_mostly = LOW_RES_NSEC;
520520
EXPORT_SYMBOL_GPL(hrtimer_resolution);
521521

@@ -524,13 +524,7 @@ EXPORT_SYMBOL_GPL(hrtimer_resolution);
524524
*/
525525
static int __init setup_hrtimer_hres(char *str)
526526
{
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);
534528
}
535529

536530
__setup("highres=", setup_hrtimer_hres);

kernel/time/tick-sched.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -486,20 +486,14 @@ void __init tick_nohz_init(void)
486486
/*
487487
* NO HZ enabled ?
488488
*/
489-
int tick_nohz_enabled __read_mostly = 1;
489+
bool tick_nohz_enabled __read_mostly = true;
490490
unsigned long tick_nohz_active __read_mostly;
491491
/*
492492
* Enable / Disable tickless mode
493493
*/
494494
static int __init setup_tick_nohz(char *str)
495495
{
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);
503497
}
504498

505499
__setup("nohz=", setup_tick_nohz);

0 commit comments

Comments
 (0)