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

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

From: Lei Liu <hidden>
Date: 2024-08-22 03:40:18
Also in: linux-mips, linux-serial, linux-tegra, lkml
Subsystem: 8250/16?50 (and clone uarts) serial driver, the rest, tty layer and serial drivers · Maintainers: Greg Kroah-Hartman, Linus Torvalds, 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/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

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