Skip to content

Commit a5a763b

Browse files
AndreKalbSmapmladek
authored andcommitted
printk: Set console_set_on_cmdline=1 when __add_preferred_console() is called with user_specified == true
In case of using console="" or console=null set console_set_on_cmdline=1 to disable "stdout-path" node from DT. We basically need to set it every time when __add_preferred_console() is called with parameter 'user_specified' set. Therefore we can move setting it into a helper function that is called from __add_preferred_console(). Suggested-by: Petr Mladek <[email protected]> Signed-off-by: Andre Kalb <[email protected]> Reviewed-by: Petr Mladek <[email protected]> Reviewed-by: Sergey Senozhatsky <[email protected]> Signed-off-by: Petr Mladek <[email protected]> Link: https://lore.kernel.org/r/YgzU4ho8l6XapyG2@pc6682
1 parent 96b02f2 commit a5a763b

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

kernel/printk/printk.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2323,6 +2323,20 @@ asmlinkage __visible void early_printk(const char *fmt, ...)
23232323
}
23242324
#endif
23252325

2326+
static void set_user_specified(struct console_cmdline *c, bool user_specified)
2327+
{
2328+
if (!user_specified)
2329+
return;
2330+
2331+
/*
2332+
* @c console was defined by the user on the command line.
2333+
* Do not clear when added twice also by SPCR or the device tree.
2334+
*/
2335+
c->user_specified = true;
2336+
/* At least one console defined by the user on the command line. */
2337+
console_set_on_cmdline = 1;
2338+
}
2339+
23262340
static int __add_preferred_console(char *name, int idx, char *options,
23272341
char *brl_options, bool user_specified)
23282342
{
@@ -2339,8 +2353,7 @@ static int __add_preferred_console(char *name, int idx, char *options,
23392353
if (strcmp(c->name, name) == 0 && c->index == idx) {
23402354
if (!brl_options)
23412355
preferred_console = i;
2342-
if (user_specified)
2343-
c->user_specified = true;
2356+
set_user_specified(c, user_specified);
23442357
return 0;
23452358
}
23462359
}
@@ -2350,7 +2363,7 @@ static int __add_preferred_console(char *name, int idx, char *options,
23502363
preferred_console = i;
23512364
strlcpy(c->name, name, sizeof(c->name));
23522365
c->options = options;
2353-
c->user_specified = user_specified;
2366+
set_user_specified(c, user_specified);
23542367
braille_set_options(c, brl_options);
23552368

23562369
c->index = idx;
@@ -2416,7 +2429,6 @@ static int __init console_setup(char *str)
24162429
*s = 0;
24172430

24182431
__add_preferred_console(buf, idx, options, brl_options, true);
2419-
console_set_on_cmdline = 1;
24202432
return 1;
24212433
}
24222434
__setup("console=", console_setup);

0 commit comments

Comments
 (0)