clk: return probe defer when DT clock not yet ready
authorJean-Francois Moine <moinejf@free.fr>
Mon, 25 Nov 2013 18:47:04 +0000 (19:47 +0100)
committerMike Turquette <mturquette@linaro.org>
Tue, 25 Feb 2014 01:14:56 +0000 (17:14 -0800)
At probe time, a clock device may not be ready when some other device
wants to use it.

This patch lets the functions clk_get/devm_clk_get return a probe defer
when the clock is defined in the DT but not yet available.

Signed-off-by: Jean-Francois Moine <moinejf@free.fr>
Reviewed-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Tested-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mike Turquette <mturquette@linaro.org>
drivers/clk/clk.c
drivers/clk/clkdev.c

index f30e6af90332b53b903688d04cbad7af1db15c9b..cc2ca9aebe02cfa4710e1f5f2e8bb7f6bc74591e 100644 (file)
@@ -2466,7 +2466,7 @@ EXPORT_SYMBOL_GPL(of_clk_del_provider);
 struct clk *__of_clk_get_from_provider(struct of_phandle_args *clkspec)
 {
        struct of_clk_provider *provider;
-       struct clk *clk = ERR_PTR(-ENOENT);
+       struct clk *clk = ERR_PTR(-EPROBE_DEFER);
 
        /* Check if we have such a provider in our array */
        list_for_each_entry(provider, &of_clk_providers, link) {
index 48f67218247cb0cb44cfa92b8ed4903a0f193531..a360b2eca5cbff29c793c2100f97b81b22b74f3b 100644 (file)
@@ -167,6 +167,8 @@ struct clk *clk_get(struct device *dev, const char *con_id)
                clk = of_clk_get_by_name(dev->of_node, con_id);
                if (!IS_ERR(clk))
                        return clk;
+               if (PTR_ERR(clk) == -EPROBE_DEFER)
+                       return clk;
        }
 
        return clk_get_sys(dev_id, con_id);