diff options
Diffstat (limited to 'drivers/tty/serial/stm32-usart.c')
-rw-r--r-- | drivers/tty/serial/stm32-usart.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/drivers/tty/serial/stm32-usart.c b/drivers/tty/serial/stm32-usart.c index 026982259714..17c2f3276888 100644 --- a/drivers/tty/serial/stm32-usart.c +++ b/drivers/tty/serial/stm32-usart.c @@ -518,7 +518,7 @@ static void stm32_set_mctrl(struct uart_port *port, unsigned int mctrl) static unsigned int stm32_get_mctrl(struct uart_port *port) { struct stm32_port *stm32_port = to_stm32_port(port); - int ret; + unsigned int ret; /* This routine is used to get signals of: DCD, DSR, RI, and CTS */ ret = TIOCM_CAR | TIOCM_DSR | TIOCM_CTS; @@ -988,24 +988,32 @@ static int stm32_init_port(struct stm32_port *stm32port, stm32port->port.uartclk = clk_get_rate(stm32port->clk); if (!stm32port->port.uartclk) { - clk_disable_unprepare(stm32port->clk); ret = -EINVAL; + goto err_clk; } stm32port->gpios = mctrl_gpio_init(&stm32port->port, 0); - if (IS_ERR(stm32port->gpios)) - return PTR_ERR(stm32port->gpios); + if (IS_ERR(stm32port->gpios)) { + ret = PTR_ERR(stm32port->gpios); + goto err_clk; + } /* Both CTS/RTS gpios and "st,hw-flow-ctrl" should not be specified */ if (stm32port->hw_flow_control) { if (mctrl_gpio_to_gpiod(stm32port->gpios, UART_GPIO_CTS) || mctrl_gpio_to_gpiod(stm32port->gpios, UART_GPIO_RTS)) { dev_err(&pdev->dev, "Conflicting RTS/CTS config\n"); - return -EINVAL; + ret = -EINVAL; + goto err_clk; } } return ret; + +err_clk: + clk_disable_unprepare(stm32port->clk); + + return ret; } static struct stm32_port *stm32_of_get_stm32_port(struct platform_device *pdev) |