The Braille console reuses the framework for handling consoles preferred
via the command line. However, it is a special-purpose interface that
neither receives standard printk messages nor associates with
/dev/console.
Currently, the "preferred_dev_console" variable can point to a Braille
console entry in the "preferred_consoles[]" array. This occurs if an
entry was first created for a non-Braille console, but a later 'console='
parameter redefined it as a Braille console.
Since a Braille console will only ever be enabled as such, it should not
be tracked as the primary system console. Adjust the logic to ensure
"preferred_dev_console" continues to point to the previously designated
normal console instead.
Signed-off-by: Petr Mladek <pmladek@suse.com>
---
kernel/printk/printk.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 279b36ef90bd..eb224eaace64 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -365,6 +365,7 @@ static int console_locked;
static struct preferred_console preferred_consoles[MAX_PREFERRED_CONSOLES];
static int preferred_dev_console = -1;
+static int preferred_dev_console_prev = -1;
static bool want_braille_console;
int console_set_on_cmdline;
EXPORT_SYMBOL(console_set_on_cmdline);
@@ -2555,10 +2556,23 @@ static int update_preferred_console(int i, const char *name, const short idx,
braille_update_options(pc, brl_options);
- if (brl_options)
+ if (brl_options) {
want_braille_console = true;
- else
+ /*
+ * This console name will always get enabled as Braille
+ * console. It takes special code paths in register_console().
+ * Do not treat it as a normal preferred_console.
+ */
+ if (preferred_dev_console == i)
+ preferred_dev_console = preferred_dev_console_prev;
+ } else {
+ /*
+ * Only the VisioBraille device is supported at the moment.
+ * One level history should be enough.
+ */
+ preferred_dev_console_prev = preferred_dev_console;
preferred_dev_console = i;
+ }
/*
* @c console was defined by the user on the command line.
--
2.52.0