Thread (20 messages) 20 messages, 5 authors, 2024-08-22
STALE698d

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

From: Lei Liu <hidden>
Date: 2024-08-22 03:41:43
Also in: linux-mips, linux-serial, linux-tegra, lkml
Subsystem: arm/sti architecture, the rest, tty layer and serial drivers · Maintainers: Patrice Chotard, Linus Torvalds, Greg Kroah-Hartman, Jiri Slaby

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 <redacted>
---
 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

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help