clk: Simplify __of_clk_get_hw_from_provider()
PATCH 1/1 clk: Simplify __of_clk_get_hw_from_provider()
__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.
--- drivers/clk/clk.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-)
drivers/clk/clk.c +6 -11
@@ -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,
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Quoted 10 lines · Stephen Boyd
__of_clk_get_hw_from_provider()is confusing because it will returnEPROBE_DEFERif 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.
Quoted 2 lines
Reported-by Masahiro Yamada <[email protected]>Signed-off-by Stephen Boyd <[email protected]>
Stephen Boyd
AppliedQuoted 10 lines · Stephen Boyd
__of_clk_get_hw_from_provider()is confusing because it will returnEPROBE_DEFERif 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.
Quoted 3 lines
Reported-by Masahiro Yamada <[email protected]>Signed-off-by Stephen Boyd <[email protected]>---
Applied to clk-next
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project