Skip to content

Commit bebd87a

Browse files
jognesspmladek
authored andcommitted
printk: Track nbcon consoles
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 <[email protected]> Reviewed-by: Petr Mladek <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Petr Mladek <[email protected]>
1 parent 6001306 commit bebd87a

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

kernel/printk/printk.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,11 @@ static DEFINE_MUTEX(syslog_lock);
470470
*/
471471
static bool have_legacy_console;
472472

473+
/*
474+
* Specifies if an nbcon console is registered.
475+
*/
476+
static bool have_nbcon_console;
477+
473478
/*
474479
* Specifies if a boot console is registered. If boot consoles are present,
475480
* nbcon consoles cannot print simultaneously and must be synchronized by
@@ -3638,6 +3643,7 @@ void register_console(struct console *newcon)
36383643
init_seq = get_init_console_seq(newcon, bootcon_registered);
36393644

36403645
if (newcon->flags & CON_NBCON) {
3646+
have_nbcon_console = true;
36413647
nbcon_seq_force(newcon, init_seq);
36423648
} else {
36433649
have_legacy_console = true;
@@ -3718,6 +3724,7 @@ static int unregister_console_locked(struct console *console)
37183724
{
37193725
bool use_device_lock = (console->flags & CON_NBCON) && console->write_atomic;
37203726
bool found_legacy_con = false;
3727+
bool found_nbcon_con = false;
37213728
bool found_boot_con = false;
37223729
unsigned long flags;
37233730
struct console *c;
@@ -3785,13 +3792,18 @@ static int unregister_console_locked(struct console *console)
37853792
for_each_console(c) {
37863793
if (c->flags & CON_BOOT)
37873794
found_boot_con = true;
3788-
if (!(c->flags & CON_NBCON))
3795+
3796+
if (c->flags & CON_NBCON)
3797+
found_nbcon_con = true;
3798+
else
37893799
found_legacy_con = true;
37903800
}
37913801
if (!found_boot_con)
37923802
have_boot_console = found_boot_con;
37933803
if (!found_legacy_con)
37943804
have_legacy_console = found_legacy_con;
3805+
if (!found_nbcon_con)
3806+
have_nbcon_console = found_nbcon_con;
37953807

37963808
return res;
37973809
}

0 commit comments

Comments
 (0)