Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932223AbbDVUx1 (ORCPT ); Wed, 22 Apr 2015 16:53:27 -0400 Received: from gloria.sntech.de ([95.129.55.99]:51582 "EHLO gloria.sntech.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752360AbbDVUxX (ORCPT ); Wed, 22 Apr 2015 16:53:23 -0400 From: Heiko Stuebner To: mturquette@linaro.org, sboyd@codeaurora.org Cc: dianders@chromium.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Heiko Stuebner , Boris Brezillon , Alex Elder , Alexandre Belloni , Stephen Warren , Max Filippov , kernel@pengutronix.de, Zhangfei Gao , Santosh Shilimkar , Chao Xie , Jason Cooper , Stefan Wahren , Andrew Bresticker , Robert Jarzmik , Georgi Djakov , Sylwester Nawrocki , Geert Uytterhoeven , Barry Song , Dinh Nguyen , Viresh Kumar , Gabriel FERNANDEZ , emilio@elopez.com.ar, Peter De Schrijver , Tero Kristo , Ulf Hansson , Pawel Moll , Michal Simek Subject: [PATCH v3 2/2] clk: prevent orphan clocks from being used Date: Wed, 22 Apr 2015 22:53:06 +0200 Message-Id: <1429735986-18592-3-git-send-email-heiko@sntech.de> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1429735986-18592-1-git-send-email-heiko@sntech.de> References: <1429735986-18592-1-git-send-email-heiko@sntech.de> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2638 Lines: 77 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 Cc: Boris Brezillon Cc: Alex Elder Cc: Alexandre Belloni Cc: Stephen Warren Cc: Max Filippov Cc: kernel@pengutronix.de Cc: Zhangfei Gao Cc: Santosh Shilimkar Cc: Chao Xie Cc: Jason Cooper Cc: Stefan Wahren Cc: Andrew Bresticker Cc: Robert Jarzmik Cc: Georgi Djakov Cc: Sylwester Nawrocki Cc: Geert Uytterhoeven Cc: Barry Song Cc: Dinh Nguyen Cc: Viresh Kumar Cc: Gabriel FERNANDEZ Cc: emilio@elopez.com.ar Cc: Peter De Schrijver Cc: Tero Kristo Cc: Ulf Hansson Cc: Pawel Moll Cc: Michal Simek --- drivers/clk/clk.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 341904f..27d2d4b 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -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); -- 2.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/