]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
printk: Let console_is_usable() handle nbcon
authorJohn Ogness <john.ogness@linutronix.de>
Tue, 20 Aug 2024 06:29:43 +0000 (08:35 +0206)
committerPetr Mladek <pmladek@suse.com>
Wed, 21 Aug 2024 12:56:24 +0000 (14:56 +0200)
The nbcon consoles use a different printing callback. For nbcon
consoles, check for the write_atomic() callback instead of
write().

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

index 5d9deb56b582ff1d86a94faa394a529c86ad8cc8..448a5fcd5228cab16ebc609645e46b257ac5e7ae 100644 (file)
@@ -86,6 +86,8 @@ void nbcon_free(struct console *con);
 
 /*
  * Check if the given console is currently capable and allowed to print
+ * records. Note that this function does not consider the current context,
+ * which can also play a role in deciding if @con can be used to print
  * records.
  *
  * Requires the console_srcu_read_lock.
@@ -100,8 +102,13 @@ static inline bool console_is_usable(struct console *con)
        if ((flags & CON_SUSPENDED))
                return false;
 
-       if (!con->write)
-               return false;
+       if (flags & CON_NBCON) {
+               if (!con->write_atomic)
+                       return false;
+       } else {
+               if (!con->write)
+                       return false;
+       }
 
        /*
         * Console drivers may assume that per-cpu resources have been