linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] clk: Simplify __of_clk_get_hw_from_provider()
@ 2016-08-25 20:35 Stephen Boyd
  2016-08-26  8:52 ` Sylwester Nawrocki
  2016-08-26 19:28 ` Stephen Boyd
  0 siblings, 2 replies; 3+ messages in thread
From: Stephen Boyd @ 2016-08-25 20:35 UTC (permalink / raw)
  To: Michael Turquette, Stephen Boyd; +Cc: Masahiro Yamada, linux-kernel, linux-clk

__of_clk_get_hw_from_provider() is confusing because it will
return EPROBE_DEFER if there isn't a ->get() or ->get_hw()
function pointer in a provider. That's just a bug though, and we
used to NULL pointer exception when ->get() was missing anyway,
so let's make this more obvious that they're not optional. The
assumption is that most providers will implement ->get_hw() so we
only fallback to the ->get() function if necessary. This
clarifies the intent and removes any possibility of probe defer
happening if clk providers are buggy.

Reported-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
---
 drivers/clk/clk.c | 17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 71cc56712666..d3d26148cdfb 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -3174,19 +3174,14 @@ __of_clk_get_hw_from_provider(struct of_clk_provider *provider,
 			      struct of_phandle_args *clkspec)
 {
 	struct clk *clk;
-	struct clk_hw *hw = ERR_PTR(-EPROBE_DEFER);
 
-	if (provider->get_hw) {
-		hw = provider->get_hw(clkspec, provider->data);
-	} else if (provider->get) {
-		clk = provider->get(clkspec, provider->data);
-		if (!IS_ERR(clk))
-			hw = __clk_get_hw(clk);
-		else
-			hw = ERR_CAST(clk);
-	}
+	if (provider->get_hw)
+		return provider->get_hw(clkspec, provider->data);
 
-	return hw;
+	clk = provider->get(clkspec, provider->data);
+	if (IS_ERR(clk))
+		return ERR_CAST(clk);
+	return __clk_get_hw(clk);
 }
 
 struct clk *__of_clk_get_from_provider(struct of_phandle_args *clkspec,
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project

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

* Re: [PATCH] clk: Simplify __of_clk_get_hw_from_provider()
  2016-08-25 20:35 [PATCH] clk: Simplify __of_clk_get_hw_from_provider() Stephen Boyd
@ 2016-08-26  8:52 ` Sylwester Nawrocki
  2016-08-26 19:28 ` Stephen Boyd
  1 sibling, 0 replies; 3+ messages in thread
From: Sylwester Nawrocki @ 2016-08-26  8:52 UTC (permalink / raw)
  To: Stephen Boyd, Michael Turquette; +Cc: Masahiro Yamada, linux-kernel, linux-clk

On 08/25/2016 10:35 PM, Stephen Boyd wrote:
> __of_clk_get_hw_from_provider() is confusing because it will
> return EPROBE_DEFER if there isn't a ->get() or ->get_hw()
> function pointer in a provider. That's just a bug though, and we
> used to NULL pointer exception when ->get() was missing anyway,
> so let's make this more obvious that they're not optional. The
> assumption is that most providers will implement ->get_hw() so we
> only fallback to the ->get() function if necessary. This
> clarifies the intent and removes any possibility of probe defer
> happening if clk providers are buggy.
> 
> Reported-by: Masahiro Yamada <yamada.masahiro@socionext.com>
> Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>

Reviewed-by: Sylwester Nawrocki <s.nawrocki@samsung.com>

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

* Re: [PATCH] clk: Simplify __of_clk_get_hw_from_provider()
  2016-08-25 20:35 [PATCH] clk: Simplify __of_clk_get_hw_from_provider() Stephen Boyd
  2016-08-26  8:52 ` Sylwester Nawrocki
@ 2016-08-26 19:28 ` Stephen Boyd
  1 sibling, 0 replies; 3+ messages in thread
From: Stephen Boyd @ 2016-08-26 19:28 UTC (permalink / raw)
  To: Michael Turquette; +Cc: Masahiro Yamada, linux-kernel, linux-clk

On 08/25, Stephen Boyd wrote:
> __of_clk_get_hw_from_provider() is confusing because it will
> return EPROBE_DEFER if there isn't a ->get() or ->get_hw()
> function pointer in a provider. That's just a bug though, and we
> used to NULL pointer exception when ->get() was missing anyway,
> so let's make this more obvious that they're not optional. The
> assumption is that most providers will implement ->get_hw() so we
> only fallback to the ->get() function if necessary. This
> clarifies the intent and removes any possibility of probe defer
> happening if clk providers are buggy.
> 
> Reported-by: Masahiro Yamada <yamada.masahiro@socionext.com>
> Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
> ---

Applied to clk-next

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

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

end of thread, other threads:[~2016-08-26 19:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-25 20:35 [PATCH] clk: Simplify __of_clk_get_hw_from_provider() Stephen Boyd
2016-08-26  8:52 ` Sylwester Nawrocki
2016-08-26 19:28 ` Stephen Boyd

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).