From patchwork Thu Apr 2 15:34:11 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiko Stuebner X-Patchwork-Id: 6150361 Return-Path: X-Original-To: patchwork-linux-rockchip@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C410BBF4A6 for ; Thu, 2 Apr 2015 15:37:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0748520306 for ; Thu, 2 Apr 2015 15:37:00 +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 7FFFF203AC for ; Thu, 2 Apr 2015 15:36:57 +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 1YdhAt-0000Gx-Ak; Thu, 02 Apr 2015 15:36:55 +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 1Ydh8l-0006UW-UU; Thu, 02 Apr 2015 15:34:45 +0000 Received: from ip92344031.dynamic.kabel-deutschland.de ([146.52.64.49] helo=diego.lan) by gloria.sntech.de with esmtpsa (TLS1.1:RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1Ydh8N-0000Sn-0t; Thu, 02 Apr 2015 17:34:19 +0200 From: Heiko Stuebner To: mturquette@linaro.org Subject: [PATCH 2/4] clk: add clk_is_orphan() to check if a clocks inherits from an orphan clock Date: Thu, 2 Apr 2015 17:34:11 +0200 Message-Id: <1427988853-9549-3-git-send-email-heiko@sntech.de> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1427988853-9549-1-git-send-email-heiko@sntech.de> References: <1427988853-9549-1-git-send-email-heiko@sntech.de> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150402_083444_189380_A13F48AB X-CRM114-Status: GOOD ( 12.00 ) X-Spam-Score: -0.0 (/) Cc: linux@arm.linux.org.uk, Heiko Stuebner , linux-kernel@vger.kernel.org, dianders@chromium.org, linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.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: , MIME-Version: 1.0 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 There are cases where it is helpful to know if the full clock path can be trusted or if there is a parent clock missing somewhere in the parent-path. We keep it confined to the ccf area for now, if later users outside the ccf surface it can be made more publically available. Signed-off-by: Heiko Stuebner --- drivers/clk/clk.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 512323f..476f491 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -2271,6 +2271,44 @@ bool clk_is_match(const struct clk *p, const struct clk *q) EXPORT_SYMBOL_GPL(clk_is_match); /** + * __clk_is_orphan - check if a clock or its parent is an orphan + * + * Walks up the clock parents until it reaches a root-clock or + * a clock contained in the orphan list. Returns true if there is + * an orphan in the parent-path otherwise false. + */ +static bool __clk_is_orphan(struct clk_core *clk) +{ + struct clk_core *orphan; + + if (clk->flags & CLK_IS_ROOT) + return false; + + hlist_for_each_entry(orphan, &clk_orphan_list, child_node) { + if (clk == orphan) + return true; + } + + if (clk->num_parents) + return __clk_is_orphan(clk->parent); + + return false; +} + +static bool clk_is_orphan(struct clk *clk) +{ + bool ret; + + if (!clk) + return false; + + clk_prepare_lock(); + ret = __clk_is_orphan(clk->core); + clk_prepare_unlock(); + return ret; +} + +/** * __clk_init - initialize the data structures in a struct clk * @dev: device initializing this clk, placeholder for now * @clk: clk being initialized