summary refs log tree commit diff
path: root/kernel/printk
diff options
context:
space:
mode:
authorAndre Kalb <andre.kalb@sma.de>2022-02-16 11:41:38 +0100
committerPetr Mladek <pmladek@suse.com>2022-02-21 15:52:08 +0100
commita5a763b2b26678f1e01b2d031819b175d8f14555 (patch)
treefbad2042c0abcaf53998c5647bf678213ca344ae /kernel/printk
parent96b02f2fbde29a08ac7239fd9ba87ff870cf8a94 (diff)
downloadlinux-a5a763b2b26678f1e01b2d031819b175d8f14555.tar.gz
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 <pmladek@suse.com>
Signed-off-by: Andre Kalb <andre.kalb@sma.de>
Reviewed-by: Petr Mladek <pmladek@suse.com>
Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Signed-off-by: Petr Mladek <pmladek@suse.com>
Link: https://lore.kernel.org/r/YgzU4ho8l6XapyG2@pc6682
Diffstat (limited to 'kernel/printk')
-rw-r--r--kernel/printk/printk.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 25dce8b74791..266cc974b0e3 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -2323,6 +2323,20 @@ asmlinkage __visible void early_printk(const char *fmt, ...)
 }
 #endif
 
+static void set_user_specified(struct console_cmdline *c, bool user_specified)
+{
+	if (!user_specified)
+		return;
+
+	/*
+	 * @c console was defined by the user on the command line.
+	 * Do not clear when added twice also by SPCR or the device tree.
+	 */
+	c->user_specified = true;
+	/* At least one console defined by the user on the command line. */
+	console_set_on_cmdline = 1;
+}
+
 static int __add_preferred_console(char *name, int idx, char *options,
 				   char *brl_options, bool user_specified)
 {
@@ -2339,8 +2353,7 @@ static int __add_preferred_console(char *name, int idx, char *options,
 		if (strcmp(c->name, name) == 0 && c->index == idx) {
 			if (!brl_options)
 				preferred_console = i;
-			if (user_specified)
-				c->user_specified = true;
+			set_user_specified(c, user_specified);
 			return 0;
 		}
 	}
@@ -2350,7 +2363,7 @@ static int __add_preferred_console(char *name, int idx, char *options,
 		preferred_console = i;
 	strlcpy(c->name, name, sizeof(c->name));
 	c->options = options;
-	c->user_specified = user_specified;
+	set_user_specified(c, user_specified);
 	braille_set_options(c, brl_options);
 
 	c->index = idx;
@@ -2416,7 +2429,6 @@ static int __init console_setup(char *str)
 	*s = 0;
 
 	__add_preferred_console(buf, idx, options, brl_options, true);
-	console_set_on_cmdline = 1;
 	return 1;
 }
 __setup("console=", console_setup);