[PATCH 5/6] tty: serial: propagate uart_configure_port failure to uart_add_one_port
Praveen Talari
praveen.talari at oss.qualcomm.com
Wed Jul 8 23:25:17 PDT 2026
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 <praveen.talari at oss.qualcomm.com>
---
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
More information about the Linux-mediatek
mailing list