clk: prevent orphan clocks from being used

A patch from »clk: improve handling of orphan clocks« in state Mainline for linux-kernel

From: Heiko Stuebner <heiko@...> Date: Sun, 12 Apr 2015 01:52:51 +0200

Commit-Message

Orphan clocks or children of orphan clocks don't have rate information at all and can produce strange results if they're allowed to be used and the parent becomes available later on. So using the newly introduced orphan status bit defer __of_clk_get_from_provider calls for orphan clocks. Signed-off-by: Heiko Stuebner <heiko@...> Cc: Boris Brezillon <boris.brezillon@...> Cc: Alex Elder <elder@...> Cc: Alexandre Belloni <alexandre.belloni@...> Cc: Stephen Warren <swarren@...> Cc: Max Filippov <jcmvbkbc@...> Cc: kernel@pengutronix.de Cc: Zhangfei Gao <zhangfei.gao@...> Cc: Santosh Shilimkar <ssantosh@...> Cc: Chao Xie <chao.xie@...> Cc: Jason Cooper <jason@...> Cc: Stefan Wahren <stefan.wahren@...> Cc: Andrew Bresticker <abrestic@...> Cc: Robert Jarzmik <robert.jarzmik@...> Cc: Georgi Djakov <georgi.djakov@...> Cc: Sylwester Nawrocki <s.nawrocki@...> Cc: Geert Uytterhoeven <geert+renesas@...> Cc: Barry Song <baohua@...> Cc: Dinh Nguyen <dinguyen@...> Cc: Viresh Kumar <viresh.linux@...> Cc: Gabriel FERNANDEZ <gabriel.fernandez@...> Cc: emilio@elopez.com.ar Cc: Peter De Schrijver <pdeschrijver@...> Cc: Tero Kristo <t-kristo@...> Cc: Ulf Hansson <ulf.hansson@...> Cc: Pawel Moll <pawel.moll@...> Cc: Michal Simek <michal.simek@...>

Patch-Comment

drivers/clk/clk.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)

Statistics

  • 13 lines added
  • 0 lines removed

Changes

------------------------------ drivers/clk/clk.c -------------------------------
index 341904f..27d2d4b 100644
@@ -2226,6 +2226,14 @@ bool clk_is_match(const struct clk *p, const struct clk *q)
}
EXPORT_SYMBOL_GPL(clk_is_match);
+static bool clk_is_orphan(const struct clk *clk)
+{
+ if (!clk)
+ return false;
+
+ return clk->core->orphan;
+}
+
/**
* __clk_init - initialize the data structures in a struct clk
* @dev: device initializing this clk, placeholder for now
@@ -2968,6 +2976,11 @@ struct clk *__of_clk_get_from_provider(struct of_phandle_args *clkspec,
if (provider->node == clkspec->np)
clk = provider->get(clkspec, provider->data);
if (!IS_ERR(clk)) {
+ if (clk_is_orphan(clk)) {
+ clk = ERR_PTR(-EPROBE_DEFER);
+ break;
+ }
+
clk = __clk_create_clk(__clk_get_hw(clk), dev_id,
con_id);
 
 

Recent Patches

About Us

Sed lacus. Donec lectus. Nullam pretium nibh ut turpis. Nam bibendum. In nulla tortor, elementum vel, tempor at, varius non, purus. Mauris vitae nisl nec metus placerat consectetuer.

Read More...