Re: [PATCH 1/5] printk/console: Split out code that enables default console

Sergey Senozhatsky
2021-11-23T02:10:26Z

On (21/11/22 14:26), Petr Mladek wrote:
> Put the code enabling a console by default into a separate function
> called try_enable_default_console().
>
> Rename try_enable_new_console() to try_enable_preferred_console() to
> make the purpose of the different variants more clear.
>
> It is a code refactoring without any functional change.
>
> Signed-off-by: Petr Mladek <pmladek@suse.com>

Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org>

[..]
> -static int try_enable_new_console(struct console *newcon, bool user_specified)
> +static int try_enable_preferred_console(struct console *newcon,
> + bool user_specified)
> {
> struct console_cmdline *c;
> int i, err;
> @@ -2909,6 +2910,23 @@ static int try_enable_new_console(struct console *newcon, bool user_specified)
> return -ENOENT;
> }
>
> +/* Try to enable the console unconditionally */
> +static void try_enable_default_console(struct console *newcon)
> +{
> + if (newcon->index < 0)
> + newcon->index = 0;
> +
> + if (newcon->setup && newcon->setup(newcon, NULL) != 0)
> + return;
> +
> + newcon->flags |= CON_ENABLED;
> +
> + if (newcon->device) {
> + newcon->flags |= CON_CONSDEV;
> + has_preferred_console = true;
> + }
> +}

try_enable_default_console() also sets preferred_console, as well as
try_enable_preferred_console().