Re: [PATCH v3 5/5] console: Introduce ->exit() callback

From: Sergey Senozhatsky
Date: Wed Jan 29 2020 - 08:41:48 EST


On (20/01/28 11:44), Andy Shevchenko wrote:
> > If the console was not registered (hence not enabled) is it still required
> > to call ->exit()? Is there a requirement that ->exit() should handle such
> > cases?
>
> This is a good point. The ->exit() purpose is to keep balance for whatever
> happened at ->setup().
>
> But ->setup() is being called either when we have has_preferred == false or
> when we got no matching we call it for all such consoles, till it returns an
> error (can you elaborate the logic behind it?).

->match() does alias matching and ->setup(). If alias matching failed,
exact name match takes place. We don't call ->setup() for all consoles,
but only for those that have exact name match:

if (strcmp(c->name, newcon->name) != 0)
continue;

As to why we don't stop sooner in that loop - I need to to do some
archaeology. We need to have CON_CONSDEV at proper place, which is
IIRC the last matching console.

Pretty much every time we tried to change the logic we ended up
reverting the changes.

> In both cases we will get the console to have CON_ENABLED flag set.

And there are sneaky consoles that have CON_ENABLED before we even
register them.

-ss