[PATCH 2/9] serial: core: use uart_iotype_*() to simplify code
From: Hugo Villeneuve
Date: Thu Apr 23 2026 - 16:15:38 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.
Signed-off-by: Hugo Villeneuve <hvilleneuve@xxxxxxxxxxxx>
---
drivers/tty/serial/serial_core.c | 24 +++++++++---------------
1 file changed, 9 insertions(+), 15 deletions(-)
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index b1cf45a8fc854cd97e349ff077d83b42e3ef8b16..fc273f8f9e75de89dca1ac1aca3589567bcf8a18 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -3221,23 +3221,17 @@ bool uart_match_port(const struct uart_port *port1,
{
if (port1->iotype != port2->iotype)
return false;
-
- switch (port1->iotype) {
- case UPIO_PORT:
- return port1->iobase == port2->iobase;
- case UPIO_HUB6:
- return port1->iobase == port2->iobase &&
- port1->hub6 == port2->hub6;
- case UPIO_MEM:
- case UPIO_MEM16:
- case UPIO_MEM32:
- case UPIO_MEM32BE:
- case UPIO_AU:
- case UPIO_TSI:
+ else if (uart_iotype_mmio(port1->iotype))
return port1->mapbase == port2->mapbase;
- default:
+ else if (uart_iotype_legacy_io(port1->iotype))
+ if (port1->iobase != port2->iobase)
+ return false;
+ else if (port1->iotype == UPIO_HUB6 && port1->hub6 != port2->hub6)
+ return false;
+ else
+ return true;
+ else
return false;
- }
}
EXPORT_SYMBOL(uart_match_port);
--
2.47.3