From patchwork Sun Apr 12 11:38:08 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiko Stuebner X-Patchwork-Id: 6202821 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 9FE8F9F1AC for ; Sun, 12 Apr 2015 11:38:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D0A3220272 for ; Sun, 12 Apr 2015 11:38:35 +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 E4C6D200E0 for ; Sun, 12 Apr 2015 11:38:34 +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 1YhGDi-0003ex-Kr; Sun, 12 Apr 2015 11:38:34 +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 1YhGDg-0003ZG-W4 for linux-rockchip@lists.infradead.org; Sun, 12 Apr 2015 11:38:33 +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 1YhGDJ-0004y0-AI; Sun, 12 Apr 2015 13:38:09 +0200 From: Heiko =?ISO-8859-1?Q?St=FCbner?= To: Mike Turquette , Stephen Boyd Subject: [PATCH v2 2/2] clk: prevent orphan clocks from being used Date: Sun, 12 Apr 2015 13:38:08 +0200 Message-ID: <178607342.OcAukPVBgb@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_043833_224277_B24BA2C2 X-CRM114-Status: UNSURE ( 8.68 ) X-CRM114-Notice: Please train this message. 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 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 --- drivers/clk/clk.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index a9fa5ab..b977701 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -2272,6 +2272,17 @@ 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; + + if (!clk->core) + return false; + + return clk->core->orphan; +} + /** * __clk_init - initialize the data structures in a struct clk * @dev: device initializing this clk, placeholder for now @@ -3009,6 +3020,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);