]> git.baikalelectronics.ru Git - kernel.git/commit
clk: clk_core_get() can also return NULL
authorStephen Boyd <sboyd@kernel.org>
Wed, 8 Dec 2021 04:15:33 +0000 (20:15 -0800)
committerStephen Boyd <sboyd@kernel.org>
Fri, 10 Dec 2021 01:15:47 +0000 (17:15 -0800)
commit0098141b14f964b1e187a79bf403a44e988d1773
tree0e395c30ff024020c7bca082bc520bb9406202db
parentee1b78658266178dd101d1cac71eb3036a4276b1
clk: clk_core_get() can also return NULL

Nothing stops a clk controller from registering an OF clk provider
before registering those clks with the clk framework. This is not great
but we deal with it in the clk framework by refusing to hand out struct
clk pointers when 'hw->core' is NULL, the indication that clk_register()
has been called.

Within clk_core_fill_parent_index() we considered this case when a
clk_hw pointer is referenced directly by filling in the parent cache
with an -EPROBE_DEFER pointer when the core pointer is NULL. When we
lookup a parent with clk_core_get() we don't care about the return value
being NULL though, because that was considered largely impossible, but
it's been proven now that it can be NULL if two clk providers are
probing in parallel and the parent provider has been registered before
the clk has. Let's check for NULL here as well and treat it the same as
direct clk_hw references.

Signed-off-by: Stephen Boyd <sboyd@kernel.org>
Link: https://lore.kernel.org/r/20211208041534.3928718-1-sboyd@kernel.org
drivers/clk/clk.c