[PATCH 5/6] tty: serial: propagate uart_configure_port failure to uart_add_one_port
Praveen Talari <[email protected]> Thu, 09 Jul 2026 11:55:17 +0530
| Newsgroups | org.kernel.vger.linux-omap,org.infradead.lists.linux-arm-kernel,org.infradead.lists.linux-mediatek,org.kernel.vger.linux-arm-msm,org.kernel.vger.linux-kernel,org.kernel.vger.linux-mips,org.kernel.vger.linux-samsung-soc,org.kernel.vger.linux-serial |
|---|---|
| Message-ID | <20260709-add_return_check_for_uart_change_pm-v1-5-e85c6ffa8ec4@oss.qualcomm.com> |
uart_configure_port() was declared void, so the uart_change_pm(ON) failure introduced in the previous patch used a bare return that silently dropped the error and allowed port registration to proceed regardless. Update serial_core_add_one_port() to check the return value and return immediately on failure. This propagates up through uart_add_one_port() to the driver's probe function, allowing the driver to handle or report the failure rather than silently registering a port that could not be initialised. Signed-off-by: Praveen Talari <[email protected]> --- drivers/tty/serial/serial_core.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index e624a67a9395..6cb9e870ba86 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -2526,7 +2526,7 @@ uart_report_port(struct uart_driver *drv, struct uart_port *port) port->uartclk / 8, port->uartclk / 4); } -static void +static int uart_configure_port(struct uart_driver *drv, struct uart_state *state, struct uart_port *port) { @@ -2536,7 +2536,7 @@ uart_configure_port(struct uart_driver *drv, struct uart_state *state, * If there isn't a port here, don't do anything further. */ if (!port->iobase && !port->mapbase && !port->membase) - return; + return 0; /* * Now do the auto configuration stuff. Note that config_port @@ -2559,6 +2559,8 @@ uart_configure_port(struct uart_driver *drv, struct uart_state *state, } if (port->type != PORT_UNKNOWN) { + int ret; + uart_report_port(drv, port); /* Synchronize with possible boot console. */ @@ -2566,11 +2568,12 @@ uart_configure_port(struct uart_driver *drv, struct uart_state *state, console_lock(); /* Power up port for set_mctrl() */ - if (uart_change_pm(state, UART_PM_STATE_ON)) { + ret = uart_change_pm(state, UART_PM_STATE_ON); + if (ret) { dev_err(port->dev, "failed to power up port\n"); if (uart_console(port)) console_unlock(); - return; + return ret; } /* @@ -2613,6 +2616,8 @@ uart_configure_port(struct uart_driver *drv, struct uart_state *state, dev_err(port->dev, "failed to power down port\n"); } } + + return 0; } #ifdef CONFIG_CONSOLE_POLL @@ -3094,6 +3099,7 @@ static int serial_core_add_one_port(struct uart_driver *drv, struct uart_port *u struct tty_port *port; struct device *tty_dev; int num_groups; + int ret; if (uport->line >= drv->nr) return -EINVAL; @@ -3135,7 +3141,10 @@ static int serial_core_add_one_port(struct uart_driver *drv, struct uart_port *u * immediately after. */ tty_port_link_device(port, drv->tty_driver, uport->line); - uart_configure_port(drv, state, uport); + + ret = uart_configure_port(drv, state, uport); + if (ret) + return ret; port->console = uart_console(uport); -- 2.34.1