]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
printk: Add @flags argument for console_is_usable()
authorJohn Ogness <john.ogness@linutronix.de>
Tue, 20 Aug 2024 06:29:44 +0000 (08:35 +0206)
committerPetr Mladek <pmladek@suse.com>
Wed, 21 Aug 2024 12:56:24 +0000 (14:56 +0200)
The caller of console_is_usable() usually needs @console->flags
for its own checks. Rather than having console_is_usable() read
its own copy, make the caller pass in the @flags. This also
ensures that the caller saw the same @flags value.

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

index 448a5fcd5228cab16ebc609645e46b257ac5e7ae..fe8d84d78f1cac3ea02d6b0e0d862943c801bfc1 100644 (file)
@@ -89,13 +89,9 @@ void nbcon_free(struct console *con);
  * 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.
  */
-static inline bool console_is_usable(struct console *con)
+static inline bool console_is_usable(struct console *con, short flags)
 {
-       short flags = console_srcu_read_flags(con);
-
        if (!(flags & CON_ENABLED))
                return false;
 
@@ -141,7 +137,7 @@ static inline void nbcon_seq_force(struct console *con, u64 seq) { }
 static inline bool nbcon_alloc(struct console *con) { return false; }
 static inline void nbcon_free(struct console *con) { }
 
-static inline bool console_is_usable(struct console *con) { return false; }
+static inline bool console_is_usable(struct console *con, short flags) { return false; }
 
 #endif /* CONFIG_PRINTK */
 
index b9c8fff9a4939397231ea02a5bc3bf91bce15b2b..ffb56c2150b0c4b89a1af273ae624d06628edb13 100644 (file)
@@ -3012,9 +3012,10 @@ static bool console_flush_all(bool do_cond_resched, u64 *next_seq, bool *handove
 
                cookie = console_srcu_read_lock();
                for_each_console_srcu(con) {
+                       short flags = console_srcu_read_flags(con);
                        bool progress;
 
-                       if (!console_is_usable(con))
+                       if (!console_is_usable(con, flags))
                                continue;
                        any_usable = true;
 
@@ -3925,7 +3926,7 @@ static bool __pr_flush(struct console *con, int timeout_ms, bool reset_on_progre
                         * that they make forward progress, so only increment
                         * @diff for usable consoles.
                         */
-                       if (!console_is_usable(c))
+                       if (!console_is_usable(c, flags))
                                continue;
 
                        if (flags & CON_NBCON) {