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

From: Petr Mladek
Date: Tue Nov 23 2021 - 05:21:20 EST


On Tue 2021-11-23 11:10:18, Sergey Senozhatsky wrote:
> 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@xxxxxxxx>
>
> Reviewed-by: Sergey Senozhatsky <senozhatsky@xxxxxxxxxxxx>
>
> [..]
> > -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().

Yes, this is one of the confusing things that this patchset is trying to solve.

The result of this patchset is that preferred_console will be used
only for consoles that are explicitely preferred via the command line,
device tree, or SPCR.

The variable @has_preferred_console is renamed to @need_default_console
in 2nd patch and completely removed in 4th patch.

Anyway, thanks for review.

Best Regards,
Petr