Re: [PATCH 6/9] serial: core: prevent irrelevant I/O infos display for UPIO_BUS

From: Ilpo Järvinen

Date: Fri Apr 24 2026 - 06:52:09 EST


On Thu, 23 Apr 2026, Hugo Villeneuve wrote:

> From: Hugo Villeneuve <hvilleneuve@xxxxxxxxxxxx>
>
> It doesn't make sense to display irrelevant MMIO or legacy I/O information
> for serial devices on I2C or SPI busses. Now that we have a separate I/O
> type for these types of devices, prevent display of I/O information for
> them. Using uart_iotype_*() functions to do so also addresses the now
> invalid check for "iotype >= UPIO_MEM".
>
> Signed-off-by: Hugo Villeneuve <hvilleneuve@xxxxxxxxxxxx>
> ---
> drivers/tty/serial/serial_core.c | 50 ++++++++++++++++++----------------------
> 1 file changed, 22 insertions(+), 28 deletions(-)
>
> diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
> index 0bfdb69817e4259681fbc4658c9a68200aa2b65f..42559eda6fc134de77c3a7b850d565ebdc89e216 100644
> --- a/drivers/tty/serial/serial_core.c
> +++ b/drivers/tty/serial/serial_core.c
> @@ -2011,13 +2011,18 @@ static void uart_line_info(struct seq_file *m, struct uart_state *state)
> if (!uport)
> return;
>
> - mmio = uport->iotype >= UPIO_MEM;
> - seq_printf(m, "%u: uart:%s %s%08llX irq:%u",
> - uport->line, uart_type(uport),
> - mmio ? "mmio:0x" : "port:",
> - mmio ? (unsigned long long)uport->mapbase
> - : (unsigned long long)uport->iobase,
> - uport->irq);
> + seq_printf(m, "%u: uart:%s", uport->line, uart_type(uport));
> +
> + mmio = uart_iotype_mmio(uport->iotype);
> +
> + if (mmio || uart_iotype_legacy_io(uport->iotype)) {
> + seq_printf(m, " %s%08llX",
> + mmio ? "mmio:0x" : "port:",
> + mmio ? (unsigned long long)uport->mapbase
> + : (unsigned long long)uport->iobase);

This should align to ?

> + }
> +
> + seq_printf(m, "irq:%u", uport->irq);
>
> if (uport->type == PORT_UNKNOWN) {
> seq_putc(m, '\n');
> @@ -2482,31 +2487,20 @@ EXPORT_SYMBOL(uart_resume_port);
> static inline void
> uart_report_port(struct uart_driver *drv, struct uart_port *port)
> {
> - char address[64];
> + char address[64] = "";
>
> - switch (port->iotype) {
> - case UPIO_PORT:
> - snprintf(address, sizeof(address), "I/O 0x%lx", port->iobase);
> - break;
> - case UPIO_HUB6:
> + if (uart_iotype_mmio(port->iotype))
> snprintf(address, sizeof(address),
> - "I/O 0x%lx offset 0x%x", port->iobase, port->hub6);
> - break;
> - case UPIO_MEM:
> - case UPIO_MEM16:
> - case UPIO_MEM32:
> - case UPIO_MEM32BE:
> - case UPIO_AU:
> - case UPIO_TSI:
> - snprintf(address, sizeof(address),
> - "MMIO 0x%llx", (unsigned long long)port->mapbase);
> - break;
> - default:
> - strscpy(address, "*unknown*", sizeof(address));
> - break;
> + " at MMIO 0x%llx", (unsigned long long)port->mapbase);
> + else if (uart_iotype_legacy_io(port->iotype)) {
> + if (port->iotype == UPIO_PORT)
> + snprintf(address, sizeof(address), " at I/O 0x%lx", port->iobase);
> + else if (port->iotype == UPIO_HUB6)
> + snprintf(address, sizeof(address),
> + " at I/O 0x%lx offset 0x%x", port->iobase, port->hub6);

Please use scnprintf() so we could perhaps one day get rid of snprintf()
entirely.

> }
>
> - pr_info("%s%s%s at %s (irq = %u, base_baud = %u) is a %s\n",
> + pr_info("%s%s%s%s (irq = %u, base_baud = %u) is a %s\n",
> port->dev ? dev_name(port->dev) : "",
> port->dev ? ": " : "",
> port->name,
>
>

--
i.