Linux clock framework development
 help / color / mirror / Atom feed
From: Emil Abildgaard Svendsen <EMAS@bang-olufsen.dk>
To: Michael Turquette <mturquette@baylibre.com>,
	Stephen Boyd <sboyd@kernel.org>
Cc: Emil Abildgaard Svendsen <EMAS@bang-olufsen.dk>,
	"linux-clk@vger.kernel.org" <linux-clk@vger.kernel.org>
Subject: [PATCH] clk: fixed: handle failed clk setup
Date: Fri, 14 Apr 2023 12:52:16 +0000	[thread overview]
Message-ID: <20230414125207.33722-1-emas@bang-olufsen.dk> (raw)

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

             reply	other threads:[~2023-04-14 12:52 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-14 12:52 Emil Abildgaard Svendsen [this message]
     [not found] ` <48bd83b09adf698976fd10f71463a553.sboyd@kernel.org>
2023-04-19  7:41   ` [PATCH] clk: fixed: handle failed clk setup Emil Abildgaard Svendsen
2023-10-25  9:47   ` 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230414125207.33722-1-emas@bang-olufsen.dk \
    --to=emas@bang-olufsen.dk \
    --cc=linux-clk@vger.kernel.org \
    --cc=mturquette@baylibre.com \
    --cc=sboyd@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox