From patchwork Sun Apr 12 11:37:33 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiko Stuebner X-Patchwork-Id: 6202801 Return-Path: X-Original-To: patchwork-linux-rockchip@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 81FC69F1AC for ; Sun, 12 Apr 2015 11:38:03 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 99D742026F for ; Sun, 12 Apr 2015 11:38:02 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BBDC1200E0 for ; Sun, 12 Apr 2015 11:38:01 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YhGDB-0003X9-DU; Sun, 12 Apr 2015 11:38:01 +0000 Received: from gloria.sntech.de ([95.129.55.99]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YhGD9-0003R2-Sj for linux-rockchip@lists.infradead.org; Sun, 12 Apr 2015 11:38:00 +0000 Received: from ip92344031.dynamic.kabel-deutschland.de ([146.52.64.49] helo=diego.localnet) by gloria.sntech.de with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1YhGCk-0004xd-7y; Sun, 12 Apr 2015 13:37:34 +0200 From: Heiko =?ISO-8859-1?Q?St=FCbner?= To: Mike Turquette , Stephen Boyd Subject: [PATCH v2 1/2] clk: track the orphan status of clocks and their children Date: Sun, 12 Apr 2015 13:37:33 +0200 Message-ID: <2713774.ah3QzH8epf@diego> User-Agent: KMail/4.14.1 (Linux/3.16.0-4-amd64; KDE/4.14.2; x86_64; ; ) In-Reply-To: <75204537.lSvovFhEiG@diego> References: <75204537.lSvovFhEiG@diego> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150412_043800_105093_521C6C07 X-CRM114-Status: GOOD ( 12.29 ) X-Spam-Score: -0.0 (/) Cc: linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org, linux@arm.linux.org.uk, dianders@chromium.org, linux-clk@vger.kernel.org X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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 f85c8e2..a9fa5ab 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; @@ -1433,18 +1434,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_update_orphan_status(struct clk_core *clk, int is_orphan) +{ + struct clk_core *child; + + clk->orphan = is_orphan; + + hlist_for_each_entry(child, &clk->children, child_node) + clk_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_update_orphan_status(clk, becomes_orphan); } else { hlist_add_head(&clk->child_node, &clk_orphan_list); + if (!was_orphan) + clk_update_orphan_status(clk, 1); } clk->parent = new_parent; @@ -2348,13 +2371,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 = 0; + } else { hlist_add_head(&clk->child_node, &clk_orphan_list); + clk->orphan = 1; + } /* * Set clk's accuracy. The preferred method is to use