summaryrefslogtreecommitdiffstats
path: root/kernel/printk
diff options
context:
space:
mode:
authorJohn Ogness <john.ogness@linutronix.de>2022-11-16 17:27:33 +0106
committerPetr Mladek <pmladek@suse.com>2022-12-02 11:25:01 +0100
commit1fd4224a6b641f1949e27bf350b5b1c1e47e2ccc (patch)
treeb448d2573cb65c80b2541b6636753c6a8595aa94 /kernel/printk
parent8cb15f7f492f85d695a6f4d12044c47230f69d96 (diff)
downloadlinux-1fd4224a6b641f1949e27bf350b5b1c1e47e2ccc.tar.bz2
console: introduce console_is_registered()
Currently it is not possible for drivers to detect if they have already successfully registered their console. Several drivers have multiple paths that lead to console registration. To avoid attempting a 2nd registration (which leads to a WARN), drivers are implementing their own solution. Introduce console_is_registered() so drivers can easily identify if their console is currently registered. A _locked() variant is also provided if the caller is already holding the console_list_lock. Signed-off-by: John Ogness <john.ogness@linutronix.de> Reviewed-by: Petr Mladek <pmladek@suse.com> Signed-off-by: Petr Mladek <pmladek@suse.com> Link: https://lore.kernel.org/r/20221116162152.193147-22-john.ogness@linutronix.de
Diffstat (limited to 'kernel/printk')
-rw-r--r--kernel/printk/printk.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 101d08d9dc88..e58a6ccb945c 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -3443,7 +3443,7 @@ static int unregister_console_locked(struct console *console)
/* Disable it unconditionally */
console_srcu_write_flags(console, console->flags & ~CON_ENABLED);
- if (hlist_unhashed(&console->node)) {
+ if (!console_is_registered_locked(console)) {
console_unlock();
return -ENODEV;
}