[PATCH v2 3/6] serial: vt8500: Look up console ports with uart_console_port()
From: Alexey Charkov
Date: Thu Nov 12 2026 - 10:39:28 EST
Ask the serial core for the console's port, which it registers before
the console, and drop the private vt8500_uart_ports[] array that only
mirrors the core state and gets in the way.
The helper also range-checks the console index, which makes the checks
in the console callbacks redundant.
Signed-off-by: Alexey Charkov <alchark@xxxxxxxxx>
---
drivers/tty/serial/vt8500_serial.c | 31 ++++++++++---------------------
1 file changed, 10 insertions(+), 21 deletions(-)
diff --git a/drivers/tty/serial/vt8500_serial.c b/drivers/tty/serial/vt8500_serial.c
index a7f167a73416..4abd4a8d5ef3 100644
--- a/drivers/tty/serial/vt8500_serial.c
+++ b/drivers/tty/serial/vt8500_serial.c
@@ -444,7 +444,6 @@ static int vt8500_verify_port(struct uart_port *port,
return 0;
}
-static struct vt8500_port *vt8500_uart_ports[VT8500_MAX_PORTS];
static struct uart_driver vt8500_uart_driver;
#ifdef CONFIG_SERIAL_VT8500_CONSOLE
@@ -472,46 +471,38 @@ static void vt8500_console_putchar(struct uart_port *port, unsigned char c)
static void vt8500_console_write(struct console *co, const char *s,
unsigned int count)
{
- struct vt8500_port *vt8500_port = vt8500_uart_ports[co->index];
+ struct uart_port *port = uart_console_port(co);
unsigned long ier;
- BUG_ON(co->index < 0 || co->index >= vt8500_uart_driver.nr);
+ ier = vt8500_read(port, VT8500_URIER);
+ vt8500_write(port, VT8500_URIER, 0);
- ier = vt8500_read(&vt8500_port->uart, VT8500_URIER);
- vt8500_write(&vt8500_port->uart, VT8500_URIER, 0);
-
- uart_console_write(&vt8500_port->uart, s, count,
- vt8500_console_putchar);
+ uart_console_write(port, s, count, vt8500_console_putchar);
/*
* Finally, wait for transmitter to become empty
* and switch back to FIFO
*/
- wait_for_xmitr(&vt8500_port->uart);
- vt8500_write(&vt8500_port->uart, VT8500_URIER, ier);
+ wait_for_xmitr(port);
+ vt8500_write(port, VT8500_URIER, ier);
}
static int __init vt8500_console_setup(struct console *co, char *options)
{
- struct vt8500_port *vt8500_port;
+ struct uart_port *port;
int baud = 9600;
int bits = 8;
int parity = 'n';
int flow = 'n';
- if (unlikely(co->index >= vt8500_uart_driver.nr || co->index < 0))
- return -ENXIO;
-
- vt8500_port = vt8500_uart_ports[co->index];
-
- if (!vt8500_port)
+ port = uart_console_port(co);
+ if (!port)
return -ENODEV;
if (options)
uart_parse_options(options, &baud, &parity, &bits, &flow);
- return uart_set_options(&vt8500_port->uart,
- co, baud, parity, bits, flow);
+ return uart_set_options(port, co, baud, parity, bits, flow);
}
static struct console vt8500_console = {
@@ -683,8 +674,6 @@ static int vt8500_serial_probe(struct platform_device *pdev)
snprintf(vt8500_port->name, sizeof(vt8500_port->name),
"VT8500 UART%d", pdev->id);
- vt8500_uart_ports[port] = vt8500_port;
-
uart_add_one_port(&vt8500_uart_driver, &vt8500_port->uart);
platform_set_drvdata(pdev, vt8500_port);
--
2.56.0