[PATCH 7/8] tty: st-asc: Use devm_clk_get_enabled() helpers

Lei Liu
2024-08-22T03:41:43Z

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/st-asc.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/tty/serial/st-asc.c b/drivers/tty/serial/st-asc.c
index f91753a40a69..df666766d50e 100644
--- a/drivers/tty/serial/st-asc.c
+++ b/drivers/tty/serial/st-asc.c
@@ -706,17 +706,13 @@ static int asc_init_port(struct asc_port *ascport,

spin_lock_init(&port->lock);

- ascport->clk = devm_clk_get(&pdev->dev, NULL);
+ ascport->clk = devm_clk_get_enabled(&pdev->dev, NULL);

if (WARN_ON(IS_ERR(ascport->clk)))
return -EINVAL;
- /* ensure that clk rate is correct by enabling the clk */
- ret = clk_prepare_enable(ascport->clk);
- if (ret)
- return ret;
+
ascport->port.uartclk = clk_get_rate(ascport->clk);
WARN_ON(ascport->port.uartclk == 0);
- clk_disable_unprepare(ascport->clk);

ascport->pinctrl = devm_pinctrl_get(&pdev->dev);
if (IS_ERR(ascport->pinctrl)) {
--
2.34.1