Re: [PATCH 1/2] tty: serial: uartlite: Disable clocks in case of errors
From: Greg KH <gregkh@linuxfoundation.org>
Date: 2021-05-25 08:16:00
On Tue, May 25, 2021 at 01:34:03PM +0530, Shubhrajyoti Datta wrote:
quoted hunk ↗ jump to hunk
In case the uart registration fails the clocks are left enabled. Disable the clock in case of errors. Signed-off-by: Shubhrajyoti Datta <redacted> --- drivers/tty/serial/uartlite.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)diff --git a/drivers/tty/serial/uartlite.c b/drivers/tty/serial/uartlite.c index f42ccc4..39ea495 100644 --- a/drivers/tty/serial/uartlite.c +++ b/drivers/tty/serial/uartlite.c@@ -799,7 +799,7 @@ static int ulite_probe(struct platform_device *pdev) ret = uart_register_driver(&ulite_uart_driver); if (ret < 0) { dev_err(&pdev->dev, "Failed to register driver\n"); - return ret; + goto err_out_clk_disable; } }@@ -808,6 +808,10 @@ static int ulite_probe(struct platform_device *pdev) clk_disable(pdata->clk); return ret; + +err_out_clk_disable: + clk_disable_unprepare(pdata->clk);
Why not put this above in your error code? Also, are you sure that you are calling uart_register_driver() in the correct place? Shouldn't everything be set up before it is called? You have more logic after it is called, what happens if your device is opened before the uart_register_driver() call returns? thanks, greg k-h