Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932453AbbDVUx3 (ORCPT ); Wed, 22 Apr 2015 16:53:29 -0400 Received: from gloria.sntech.de ([95.129.55.99]:51583 "EHLO gloria.sntech.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757847AbbDVUxX (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 1/2] clk: track the orphan status of clocks and their children Date: Wed, 22 Apr 2015 22:53:05 +0200 Message-Id: <1429735986-18592-2-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: 4061 Lines: 121 While children of orphan clocks are not carried in the orphan-list itself, they're nevertheless orphans in their own right as they also don't have an input-rate available. To ease tracking if a clock is an orphan or has an orphan in its parent path introduce an orphan field into struct clk and update it and the fields in child-clocks when a clock gets added or removed from the orphan-list. Suggested-by: Stephen Boyd 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 | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index b2361d4..341904f 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -62,6 +62,7 @@ struct clk_core { struct clk_core *new_parent; struct clk_core *new_child; unsigned long flags; + bool orphan; unsigned int enable_count; unsigned int prepare_count; unsigned long accuracy; @@ -1401,18 +1402,40 @@ static int clk_fetch_parent_index(struct clk_core *clk, return -EINVAL; } +/* + * Update the orphan status of @clk and all its children. + */ +static void clk_core_update_orphan_status(struct clk_core *clk, bool is_orphan) +{ + struct clk_core *child; + + clk->orphan = is_orphan; + + hlist_for_each_entry(child, &clk->children, child_node) + clk_core_update_orphan_status(child, is_orphan); +} + static void clk_reparent(struct clk_core *clk, struct clk_core *new_parent) { + bool was_orphan = clk->orphan; + hlist_del(&clk->child_node); if (new_parent) { + bool becomes_orphan = new_parent->orphan; + /* avoid duplicate POST_RATE_CHANGE notifications */ if (new_parent->new_child == clk) new_parent->new_child = NULL; hlist_add_head(&clk->child_node, &new_parent->children); + + if (was_orphan != becomes_orphan) + clk_core_update_orphan_status(clk, becomes_orphan); } else { hlist_add_head(&clk->child_node, &clk_orphan_list); + if (!was_orphan) + clk_core_update_orphan_status(clk, true); } clk->parent = new_parent; @@ -2302,13 +2325,17 @@ static int __clk_init(struct device *dev, struct clk *clk_user) * clocks and re-parent any that are children of the clock currently * being clk_init'd. */ - if (clk->parent) + if (clk->parent) { hlist_add_head(&clk->child_node, &clk->parent->children); - else if (clk->flags & CLK_IS_ROOT) + clk->orphan = clk->parent->orphan; + } else if (clk->flags & CLK_IS_ROOT) { hlist_add_head(&clk->child_node, &clk_root_list); - else + clk->orphan = false; + } else { hlist_add_head(&clk->child_node, &clk_orphan_list); + clk->orphan = true; + } /* * Set clk's accuracy. The preferred method is to use -- 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/