Skip to content

Commit de61a1a

Browse files
jognesspmladek
authored andcommitted
tty: nfcon: use console_is_registered()
Currently CON_ENABLED is being (mis)used to identify if the console has been registered. This is not reliable because it can be set even though registration failed or it can be unset, even though the console is registered. Use console_is_registered() instead. Signed-off-by: John Ogness <john.ogness@linutronix.de> Reviewed-by: Petr Mladek <pmladek@suse.com> Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org> Acked-by: Geert Uytterhoeven <geert@linux-m68k.org> Signed-off-by: Petr Mladek <pmladek@suse.com> Link: https://lore.kernel.org/r/20221116162152.193147-24-john.ogness@linutronix.de
1 parent 452b9b2 commit de61a1a

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

arch/m68k/emu/nfcon.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ static void nfcon_write(struct console *con, const char *str,
4949
static struct tty_driver *nfcon_device(struct console *con, int *index)
5050
{
5151
*index = 0;
52-
return (con->flags & CON_ENABLED) ? nfcon_tty_driver : NULL;
52+
return console_is_registered(con) ? nfcon_tty_driver : NULL;
5353
}
5454

5555
static struct console nf_console = {
@@ -107,6 +107,11 @@ static int __init nf_debug_setup(char *arg)
107107

108108
stderr_id = nf_get_id("NF_STDERR");
109109
if (stderr_id) {
110+
/*
111+
* The console will be enabled when debug=nfcon is specified
112+
* as a kernel parameter. Since this is a non-standard way
113+
* of enabling consoles, it must be explicitly enabled.
114+
*/
110115
nf_console.flags |= CON_ENABLED;
111116
register_console(&nf_console);
112117
}
@@ -151,7 +156,7 @@ static int __init nfcon_init(void)
151156

152157
nfcon_tty_driver = driver;
153158

154-
if (!(nf_console.flags & CON_ENABLED))
159+
if (!console_is_registered(&nf_console))
155160
register_console(&nf_console);
156161

157162
return 0;

0 commit comments

Comments
 (0)