[PATCH 2/2] clk: ccf: invoke ops provided by clk directly

Yang Xiwen via B4 Relay devnull+forbidden405.outlook.com at kernel.org
Sun Jul 23 23:16:55 CEST 2023


From: Yang Xiwen <forbidden405 at outlook.com>

Invoking clk_enable() or clk_disable() in clk->ops context causes a
recursion, results in a clock being enabled twice.

Signed-off-by: Yang Xiwen <forbidden405 at outlook.com>
---
 drivers/clk/clk.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index a5a3461b66..bd455e44a4 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -10,7 +10,6 @@
 #include <clk.h>
 #include <clk-uclass.h>
 #include <log.h>
-#include <dm/device.h>
 #include <dm/uclass.h>
 #include <dm/lists.h>
 #include <dm/device-internal.h>
@@ -115,11 +114,18 @@ int ccf_clk_set_parent(struct clk *clk, struct clk *parent)
 static int ccf_clk_endisable(struct clk *clk, bool enable)
 {
 	struct clk *c;
+	const struct clk_ops *ops = clk_dev_ops(clk->dev);
 	int err = clk_get_by_id(clk->id, &c);
 
 	if (err)
 		return err;
-	return enable ? clk_enable(c) : clk_disable(c);
+
+	if (enable && ops->enable)
+		return ops->enable(c);
+	else if (!enable && ops->disable)
+		return ops->disable(c);
+
+	return 0;
 }
 
 int ccf_clk_enable(struct clk *clk)

-- 
2.34.1



More information about the U-Boot mailing list