From 36674f6bf87dcfab8cd221cff05a521f43956e0e Mon Sep 17 00:00:00 2001 From: Daniel Leung Date: Wed, 13 May 2020 17:08:02 -0700 Subject: [PATCH] serial: ns16550: return error when init fails The init function returns successful even if the first configuration function call fails. This may leave a non-usable UART to be discoverable with device_get_binding() which will definitely result in lots of head scratching. So change the init function to return properly. Signed-off-by: Daniel Leung --- drivers/serial/uart_ns16550.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/serial/uart_ns16550.c b/drivers/serial/uart_ns16550.c index 8a9536f98e2..afa8f89f74f 100644 --- a/drivers/serial/uart_ns16550.c +++ b/drivers/serial/uart_ns16550.c @@ -469,7 +469,12 @@ static int uart_ns16550_config_get(struct device *dev, struct uart_config *cfg) */ static int uart_ns16550_init(struct device *dev) { - uart_ns16550_configure(dev, &DEV_DATA(dev)->uart_config); + int ret; + + ret = uart_ns16550_configure(dev, &DEV_DATA(dev)->uart_config); + if (ret != 0) { + return ret; + } #ifdef CONFIG_UART_INTERRUPT_DRIVEN DEV_CFG(dev)->devconf.irq_config_func(dev);