]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
printk: Make console_is_usable() available to nbcon.c
authorJohn Ogness <john.ogness@linutronix.de>
Tue, 20 Aug 2024 06:29:42 +0000 (08:35 +0206)
committerPetr Mladek <pmladek@suse.com>
Wed, 21 Aug 2024 12:56:23 +0000 (14:56 +0200)
Move console_is_usable() as-is into internal.h so that it can
be used by nbcon printing functions as well.

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

index ccb916688178f85937c4d068bebaf71bf72d932e..5d9deb56b582ff1d86a94faa394a529c86ad8cc8 100644 (file)
@@ -84,6 +84,36 @@ void nbcon_seq_force(struct console *con, u64 seq);
 bool nbcon_alloc(struct console *con);
 void nbcon_free(struct console *con);
 
+/*
+ * Check if the given console is currently capable and allowed to print
+ * records.
+ *
+ * Requires the console_srcu_read_lock.
+ */
+static inline bool console_is_usable(struct console *con)
+{
+       short flags = console_srcu_read_flags(con);
+
+       if (!(flags & CON_ENABLED))
+               return false;
+
+       if ((flags & CON_SUSPENDED))
+               return false;
+
+       if (!con->write)
+               return false;
+
+       /*
+        * Console drivers may assume that per-cpu resources have been
+        * allocated. So unless they're explicitly marked as being able to
+        * cope (CON_ANYTIME) don't call them until this CPU is officially up.
+        */
+       if (!cpu_online(raw_smp_processor_id()) && !(flags & CON_ANYTIME))
+               return false;
+
+       return true;
+}
+
 #else
 
 #define PRINTK_PREFIX_MAX      0
@@ -104,6 +134,8 @@ 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; }
+
 #endif /* CONFIG_PRINTK */
 
 extern struct printk_buffers printk_shared_pbufs;
index 4cd2c50dd06dfa195b42d6c55a74f0e51cb9f73f..b9c8fff9a4939397231ea02a5bc3bf91bce15b2b 100644 (file)
@@ -2767,36 +2767,6 @@ int is_console_locked(void)
 }
 EXPORT_SYMBOL(is_console_locked);
 
-/*
- * Check if the given console is currently capable and allowed to print
- * records.
- *
- * Requires the console_srcu_read_lock.
- */
-static inline bool console_is_usable(struct console *con)
-{
-       short flags = console_srcu_read_flags(con);
-
-       if (!(flags & CON_ENABLED))
-               return false;
-
-       if ((flags & CON_SUSPENDED))
-               return false;
-
-       if (!con->write)
-               return false;
-
-       /*
-        * Console drivers may assume that per-cpu resources have been
-        * allocated. So unless they're explicitly marked as being able to
-        * cope (CON_ANYTIME) don't call them until this CPU is officially up.
-        */
-       if (!cpu_online(raw_smp_processor_id()) && !(flags & CON_ANYTIME))
-               return false;
-
-       return true;
-}
-
 static void __console_unlock(void)
 {
        console_locked = 0;