Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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.

Reported-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>

+6 -11
+6 -11
drivers/clk/clk.c
··· 3174 3174 struct of_phandle_args *clkspec) 3175 3175 { 3176 3176 struct clk *clk; 3177 - struct clk_hw *hw = ERR_PTR(-EPROBE_DEFER); 3178 3177 3179 - if (provider->get_hw) { 3180 - hw = provider->get_hw(clkspec, provider->data); 3181 - } else if (provider->get) { 3182 - clk = provider->get(clkspec, provider->data); 3183 - if (!IS_ERR(clk)) 3184 - hw = __clk_get_hw(clk); 3185 - else 3186 - hw = ERR_CAST(clk); 3187 - } 3178 + if (provider->get_hw) 3179 + return provider->get_hw(clkspec, provider->data); 3188 3180 3189 - return hw; 3181 + clk = provider->get(clkspec, provider->data); 3182 + if (IS_ERR(clk)) 3183 + return ERR_CAST(clk); 3184 + return __clk_get_hw(clk); 3190 3185 } 3191 3186 3192 3187 struct clk *__of_clk_get_from_provider(struct of_phandle_args *clkspec,