try_enable_preferred_console() used to be always called because it
had several hidden effects, namely:
- enabled Braille consoles which were ignored by "preferred_dev_console"
because they were not associated with /dev/console.
- returned success when a console was pre-enabled using CON_ENABLED
flag.
- returned success when a console was enabled by default because
try_enable_default_console() did not return success.
The first two hidden effects were removed in previous patches. Remove
the last one so that try_enable_preferred_console() can be called only
when any non-Braille console is preferred.
Signed-off-by: Petr Mladek <pmladek@suse.com>
---
kernel/printk/printk.c | 25 ++++++++++++++-----------
1 file changed, 14 insertions(+), 11 deletions(-)
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index db91be780de9..462d870feaf2 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -3975,18 +3975,23 @@ static int try_enable_braille_console(struct console *newcon)
}
/* Try to enable the console unconditionally */
-static void try_enable_default_console(struct console *newcon)
+static int try_enable_default_console(struct console *newcon)
{
+ int err;
+
if (newcon->index < 0)
newcon->index = 0;
- if (console_call_setup(newcon, NULL) != 0)
- return;
+ err = console_call_setup(newcon, NULL);
+ if (err)
+ return err;
newcon->flags |= CON_ENABLED;
if (newcon->device)
newcon->flags |= CON_CONSDEV;
+
+ return 0;
}
/* Return the starting sequence number for a newly registered console. */
@@ -4156,17 +4161,15 @@ void register_console(struct console *newcon)
if (preferred_dev_console < 0) {
if (hlist_empty(&console_list) || !console_first()->device ||
console_first()->flags & CON_BOOT) {
- try_enable_default_console(newcon);
+ err = try_enable_default_console(newcon);
}
+ } else {
+ err = try_enable_preferred_console(newcon, true);
+
+ if (err == -ENOENT)
+ err = try_enable_preferred_console(newcon, false);
}
- /* See if this console matches one we selected on the command line */
- err = try_enable_preferred_console(newcon, true);
-
- /* If not, try to match against the platform default(s) */
- if (err == -ENOENT)
- err = try_enable_preferred_console(newcon, false);
-
/*
* Some consoles, such as pstore and netconsole, can be enabled even
* without matching. Accept them at this stage when they had a chance
--
2.52.0