Linux clock framework development
 help / color / mirror / Atom feed
* [PATCH] clk: fixed: handle failed clk setup
@ 2023-04-14 12:52 Emil Abildgaard Svendsen
       [not found] ` <a45ff881c83827189be308e2a8e4e13a.sboyd@kernel.org>
       [not found] ` <48bd83b09adf698976fd10f71463a553.sboyd@kernel.org>
  0 siblings, 2 replies; 8+ messages in thread
From: Emil Abildgaard Svendsen @ 2023-04-14 12:52 UTC (permalink / raw)
  To: Michael Turquette, Stephen Boyd
  Cc: Emil Abildgaard Svendsen, linux-clk@vger.kernel.org

When initializing clock providers "of_clk_init" will try and init
parents first. But if parent clock is provided by a platform driver it
can't. Then clocks will be forced on and OF_POPULATED flag will be set
blindly. So if setup failes e.g. with -EPROBE_DEFER the clock will not
be probed later on.

This patch will clear the OF_POPULATED falg if clock setup failes.

Signed-off-by: Emil Svendsen <emas@bang-olufsen.dk>
---
 drivers/clk/clk-fixed-factor.c | 19 +++++++++++--------
 drivers/clk/clk-fixed-rate.c   | 11 ++++++++++-
 2 files changed, 21 insertions(+), 9 deletions(-)

diff --git a/drivers/clk/clk-fixed-factor.c b/drivers/clk/clk-fixed-factor.c
index f734e34735a9..d00837daca9e 100644
--- a/drivers/clk/clk-fixed-factor.c
+++ b/drivers/clk/clk-fixed-factor.c
@@ -268,14 +268,8 @@ static struct clk_hw *_of_fixed_factor_clk_setup(struct device_node *node)
 
 	hw = __clk_hw_register_fixed_factor(NULL, node, clk_name, NULL, NULL, 0,
 					    0, mult, div, false);
-	if (IS_ERR(hw)) {
-		/*
-		 * Clear OF_POPULATED flag so that clock registration can be
-		 * attempted again from probe function.
-		 */
-		of_node_clear_flag(node, OF_POPULATED);
+	if (IS_ERR(hw))
 		return ERR_CAST(hw);
-	}
 
 	ret = of_clk_add_hw_provider(node, of_clk_hw_simple_get, hw);
 	if (ret) {
@@ -292,7 +286,16 @@ static struct clk_hw *_of_fixed_factor_clk_setup(struct device_node *node)
  */
 void __init of_fixed_factor_clk_setup(struct device_node *node)
 {
-	_of_fixed_factor_clk_setup(node);
+	struct clk_hw *hw;
+
+	hw = _of_fixed_factor_clk_setup(node);
+	if (IS_ERR(hw)) {
+		/*
+		 * Clear OF_POPULATED flag so that clock registration can be
+		 * attempted again from probe function.
+		 */
+		of_node_clear_flag(node, OF_POPULATED);
+	}
 }
 CLK_OF_DECLARE(fixed_factor_clk, "fixed-factor-clock",
 		of_fixed_factor_clk_setup);
diff --git a/drivers/clk/clk-fixed-rate.c b/drivers/clk/clk-fixed-rate.c
index 7d775954e26d..e69f4285759e 100644
--- a/drivers/clk/clk-fixed-rate.c
+++ b/drivers/clk/clk-fixed-rate.c
@@ -192,7 +192,16 @@ static struct clk_hw *_of_fixed_clk_setup(struct device_node *node)
  */
 void __init of_fixed_clk_setup(struct device_node *node)
 {
-	_of_fixed_clk_setup(node);
+	struct clk_hw *hw;
+
+	hw = _of_fixed_clk_setup(node);
+	if (IS_ERR(hw)) {
+		/*
+		 * Clear OF_POPULATED flag so that clock registration can be
+		 * attempted again from probe function.
+		 */
+		of_node_clear_flag(node, OF_POPULATED);
+	}
 }
 CLK_OF_DECLARE(fixed_clk, "fixed-clock", of_fixed_clk_setup);
 
-- 
2.34.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-10-31  9:18 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-14 12:52 [PATCH] clk: fixed: handle failed clk setup Emil Abildgaard Svendsen
     [not found] ` <a45ff881c83827189be308e2a8e4e13a.sboyd@kernel.org>
2023-10-24 14:54   ` Emil Abildgaard Svendsen
     [not found]     ` <6ae70c7185bc8806299915181b282b19.sboyd@kernel.org>
2023-10-25  9:34       ` Emil Abildgaard Svendsen
     [not found]         ` <ce50bcdaf831faa5dc63f5e505bde1f8.sboyd@kernel.org>
2023-10-26  9:40           ` Emil Abildgaard Svendsen
     [not found]             ` <1b3144e39af5c852f33891f313e72079.sboyd@kernel.org>
2023-10-27  8:56               ` Emil Abildgaard Svendsen
     [not found]                 ` <ef68b9e7704ce5f8a02a7067703b000c.sboyd@kernel.org>
2023-10-31  9:18                   ` Emil Abildgaard Svendsen
     [not found] ` <48bd83b09adf698976fd10f71463a553.sboyd@kernel.org>
2023-04-19  7:41   ` Emil Abildgaard Svendsen
2023-10-25  9:47   ` Emil Abildgaard Svendsen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox