]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
printk: Track nbcon consoles
authorJohn Ogness <john.ogness@linutronix.de>
Tue, 20 Aug 2024 06:29:54 +0000 (08:35 +0206)
committerPetr Mladek <pmladek@suse.com>
Wed, 21 Aug 2024 12:56:25 +0000 (14:56 +0200)
Add a global flag @have_nbcon_console to identify if any nbcon
consoles are registered. This will be used in follow-up commits
to preserve legacy behavior when no nbcon consoles are registered.

Signed-off-by: John Ogness <john.ogness@linutronix.de>
Reviewed-by: Petr Mladek <pmladek@suse.com>
Link: https://lore.kernel.org/r/20240820063001.36405-29-john.ogness@linutronix.de
Signed-off-by: Petr Mladek <pmladek@suse.com>
kernel/printk/printk.c

index b3ddcf39a53cec83470fd0e43e49de40d6f67c27..e30107d216a5f7c88e487831e36b4f7e8d6f0718 100644 (file)
@@ -470,6 +470,11 @@ static DEFINE_MUTEX(syslog_lock);
  */
 static bool have_legacy_console;
 
+/*
+ * Specifies if an nbcon console is registered.
+ */
+static bool have_nbcon_console;
+
 /*
  * Specifies if a boot console is registered. If boot consoles are present,
  * nbcon consoles cannot print simultaneously and must be synchronized by
@@ -3638,6 +3643,7 @@ void register_console(struct console *newcon)
        init_seq = get_init_console_seq(newcon, bootcon_registered);
 
        if (newcon->flags & CON_NBCON) {
+               have_nbcon_console = true;
                nbcon_seq_force(newcon, init_seq);
        } else {
                have_legacy_console = true;
@@ -3718,6 +3724,7 @@ static int unregister_console_locked(struct console *console)
 {
        bool use_device_lock = (console->flags & CON_NBCON) && console->write_atomic;
        bool found_legacy_con = false;
+       bool found_nbcon_con = false;
        bool found_boot_con = false;
        unsigned long flags;
        struct console *c;
@@ -3785,13 +3792,18 @@ static int unregister_console_locked(struct console *console)
        for_each_console(c) {
                if (c->flags & CON_BOOT)
                        found_boot_con = true;
-               if (!(c->flags & CON_NBCON))
+
+               if (c->flags & CON_NBCON)
+                       found_nbcon_con = true;
+               else
                        found_legacy_con = true;
        }
        if (!found_boot_con)
                have_boot_console = found_boot_con;
        if (!found_legacy_con)
                have_legacy_console = found_legacy_con;
+       if (!found_nbcon_con)
+               have_nbcon_console = found_nbcon_con;
 
        return res;
 }