[PATCH 2/8] tty: 8250_tegra: Use devm_clk_get_enabled() helpers

Lei Liu
2024-08-22T03:40:18Z

The devm_clk_get_enabled() helpers:
- call devm_clk_get()
- call clk_prepare_enable() and register what is needed in order to
call clk_disable_unprepare() when needed, as a managed resource.

This simplifies the code and avoids calls to clk_disable_unprepare().

Signed-off-by: Lei Liu <liulei.rjpt@vivo.com>
---
drivers/tty/serial/8250/8250_tegra.c | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_tegra.c b/drivers/tty/serial/8250/8250_tegra.c
index 60a80d00d251..a38a4eb3235b 100644
--- a/drivers/tty/serial/8250/8250_tegra.c
+++ b/drivers/tty/serial/8250/8250_tegra.c
@@ -86,16 +86,12 @@ static int tegra_uart_probe(struct platform_device *pdev)
return PTR_ERR(uart->rst);

if (!port->uartclk) {
- uart->clk = devm_clk_get(&pdev->dev, NULL);
+ uart->clk = devm_clk_get_enabled(&pdev->dev, NULL);
if (IS_ERR(uart->clk)) {
dev_err(&pdev->dev, "failed to get clock!\n");
return -ENODEV;
}

- ret = clk_prepare_enable(uart->clk);
- if (ret < 0)
- return ret;
-
port->uartclk = clk_get_rate(uart->clk);
}

@@ -115,7 +111,6 @@ static int tegra_uart_probe(struct platform_device *pdev)
err_ctrl_assert:
reset_control_assert(uart->rst);
err_clkdisable:
- clk_disable_unprepare(uart->clk);

return ret;
}
@@ -126,7 +121,6 @@ static void tegra_uart_remove(struct platform_device *pdev)

serial8250_unregister_port(uart->line);
reset_control_assert(uart->rst);
- clk_disable_unprepare(uart->clk);
}

#ifdef CONFIG_PM_SLEEP
--
2.34.1