[PATCH v2 04/15] serial: core: use uart_iotype_*() to simplify uart_line_info()

From: Hugo Villeneuve

Date: Tue Apr 28 2026 - 13:59:55 EST


From: Hugo Villeneuve <hvilleneuve@xxxxxxxxxxxx>

Make use of new functions uart_iotype_mmio() and uart_iotype_legacy_io()
to simplify and improve code readability. This will prevent displaying
irrelevant information for future IO types (ex: UPIO_BUS), while also
addressing the (eventually) invalid check for "iotype >= UPIO_MEM".

This also allows us to remove the confusing cast to (unsigned long long)
for iobase which is defined as an unsigned long, and use %pa to display the
mapbase pointer, as it is done in earlycon_print_info().

Signed-off-by: Hugo Villeneuve <hvilleneuve@xxxxxxxxxxxx>
---
On 32-bit cpu:
no changes.
On 64-bit cpu:
# cat /proc/tty/driver/sci
before
serinfo:1.0 driver revision:
0: uart:scif mmio:0x1004B800 irq:35 tx:11192 rx:37 RTS|CTS|DTR|DSR|CD
after:
serinfo:1.0 driver revision:
0: uart:scif mmio:0x000000001004b800 irq:35 tx:11339 rx:35 RTS|CTS|DTR|DSR|CD
---
drivers/tty/serial/serial_core.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index 06a774f93652d65bc8e0f1ed912aa3e5c95e2bfa..c5ef2dd00a9c9ad57c4010c05daea34fd2053676 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -2004,7 +2004,6 @@ static void uart_line_info(struct seq_file *m, struct uart_state *state)
struct uart_port *uport;
char stat_buf[32];
unsigned int status;
- int mmio;

guard(mutex)(&port->mutex);

@@ -2012,13 +2011,14 @@ 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));
+
+ if (uart_iotype_mmio(uport->iotype))
+ seq_printf(m, " mmio:%pa", &uport->mapbase);
+ else if (uart_iotype_legacy_io(uport->iotype))
+ seq_printf(m, " port:%08lX", uport->iobase);
+
+ seq_printf(m, " irq:%u", uport->irq);

if (uport->type == PORT_UNKNOWN) {
seq_putc(m, '\n');

--
2.47.3