[PATCH v7 14/17] printk: Update Braille options when preferred more times

From: Petr Mladek

Date: Wed Nov 11 2026 - 10:54:56 EST


The current behavior is not consistent when the same console driver
is preferred several times as Braille or non-Braille console.

In particular, preferred_dev_console is not updated when @brl_options
are passed. But @brl_options are stored only it is a new entry in
preferred_consoles[].

It is even more hairy because preferred_console[] entry is considered
a Braille entry only when .brl->options are defined.

Make the behavior consistent and always update pc->brl_options when
@brl_options are passed and they were not defined yet.

Signed-off-by: Petr Mladek <pmladek@xxxxxxxx>
---
kernel/printk/braille.h | 7 ++++---
kernel/printk/printk.c | 12 +++++++++---
2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/kernel/printk/braille.h b/kernel/printk/braille.h
index e9790c28027d..7a845caf4082 100644
--- a/kernel/printk/braille.h
+++ b/kernel/printk/braille.h
@@ -5,9 +5,10 @@
#ifdef CONFIG_A11Y_BRAILLE_CONSOLE

static inline void
-braille_set_options(struct preferred_console *pc, char *brl_options)
+braille_update_options(struct preferred_console *pc, char *brl_options)
{
- pc->brl_options = brl_options;
+ if (!pc->brl_options || !pc->brl_options[0])
+ pc->brl_options = brl_options;
}

static inline bool
@@ -35,7 +36,7 @@ _braille_unregister_console(struct console *console);
#else

static inline void
-braille_set_options(struct preferred_console *pc, char *brl_options)
+braille_update_options(struct preferred_console *pc, char *brl_options)
{
}

diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 617414d419b1..d1481ae6c729 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -2647,10 +2647,16 @@ static int add_or_update_preferred_console(unsigned int i,
* Historically, the preferred options are stored only by the first
* caller who prefers the particular console.
*/
- if (is_new_entry) {
+ if (is_new_entry)
pc->options = options;
- braille_set_options(pc, brl_options);
- }
+
+ /*
+ * Allow to override normal console with the Braille variant,
+ * for example when ttyS0 is preferred via SPCR brl,ttyS0
+ * via the command line.
+ */
+ if (brl_options)
+ braille_update_options(pc, brl_options);

if (brl_options)
want_braille_console = true;
--
2.56.0