[PATCH 01/14] clk: introduce clk init op

Sascha Hauer s.hauer at pengutronix.de
Tue May 18 04:49:16 PDT 2021


Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 drivers/clk/clk.c   | 12 ++++++++++++
 include/linux/clk.h |  1 +
 2 files changed, 13 insertions(+)

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index b04d44593b..fb5bf57e4b 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -261,6 +261,7 @@ struct clk *clk_get_parent(struct clk *clk)
 int clk_register(struct clk *clk)
 {
 	struct clk *c;
+	int ret;
 
 	list_for_each_entry(c, &clks, list) {
 		if (!strcmp(c->name, clk->name)) {
@@ -274,10 +275,21 @@ int clk_register(struct clk *clk)
 
 	list_add_tail(&clk->list, &clks);
 
+	if (clk->ops->init) {
+		ret = clk->ops->init(clk);
+		if (ret)
+			goto out;
+	}
+
 	if (clk->flags & CLK_IS_CRITICAL)
 		clk_enable(clk);
 
 	return 0;
+out:
+	list_del(&clk->list);
+	free(clk->parents);
+
+	return ret;
 }
 
 int clk_is_enabled(struct clk *clk)
diff --git a/include/linux/clk.h b/include/linux/clk.h
index c49fe9a54c..5d05ffd1b3 100644
--- a/include/linux/clk.h
+++ b/include/linux/clk.h
@@ -336,6 +336,7 @@ static inline void clk_put(struct clk *clk)
 #define CLK_GATE_HIWORD_MASK	(1 << 1)
 
 struct clk_ops {
+	int 		(*init)(struct clk *clk);
 	int		(*enable)(struct clk *clk);
 	void		(*disable)(struct clk *clk);
 	int		(*is_enabled)(struct clk *clk);
-- 
2.29.2




More information about the barebox mailing list