Re: [PATCH v4 3/4] serial: core: Handle serial console options

From: Andy Shevchenko
Date: Tue Dec 05 2023 - 11:06:55 EST


On Tue, Dec 05, 2023 at 09:32:35AM +0200, Tony Lindgren wrote:
> In order to start moving the serial console quirks out of console_setup(),
> let's add parsing for the quirks to the serial core layer. We can use
> add_preferred_console_match() to handle the quirks.
>
> At this point we can't drop the quirks from console_setup() because it
> would confuse add_preferred_console(). And try_enable_default_console()
> would get called before try_enable_preferred_console().
>
> Note that eventually we may want to set up driver specific console quirk
> handling for the serial port device drivers to use. But we need to figure
> out which driver(s) need to call the quirk. So for now, we just handle the
> sparc quirk directly.

...

> +static int serial_base_add_sparc_console(struct uart_driver *drv,
> + struct uart_port *port)
> +{
> + const char *name = NULL;
> + int ret;
> +
> + switch (port->line) {
> + case 0:
> + name = "ttya";
> + break;
> + case 1:
> + name = "ttyb";
> + break;
> + default:
> + return 0;
> + }

> + ret = add_preferred_console_match(name, drv->dev_name, port->line);
> + if (ret && ret != -ENOENT)
> + return ret;
> +
> + return 0;

return serial_base_add_one_prefcon(...);

?

> +}

...

> + if (!strncmp(drv->dev_name, "ttyS", 4)) {

str_has_prefix()

> + }

--
With Best Regards,
Andy Shevchenko