From patchwork Tue Sep 24 10:56:46 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Francois Moine X-Patchwork-Id: 2933321 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 5C97F9F288 for ; Tue, 24 Sep 2013 10:55:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1C0492042A for ; Tue, 24 Sep 2013 10:55:05 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B2A8A20421 for ; Tue, 24 Sep 2013 10:55:03 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VOQGi-0008CG-Pc; Tue, 24 Sep 2013 10:55:00 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VOQGg-0003Bj-AQ; Tue, 24 Sep 2013 10:54:58 +0000 Received: from smtp6-g21.free.fr ([2a01:e0c:1:1599::15]) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VOQGc-0003B2-9I for linux-arm-kernel@lists.infradead.org; Tue, 24 Sep 2013 10:54:55 +0000 Received: from armhf (unknown [IPv6:2a01:e35:2f5c:9de0:212:bfff:fe1e:9ce4]) by smtp6-g21.free.fr (Postfix) with ESMTP id A2A1F823A2; Tue, 24 Sep 2013 12:54:14 +0200 (CEST) Date: Tue, 24 Sep 2013 12:56:46 +0200 From: Jean-Francois Moine To: Liam Girdwood , Mark Brown Subject: [PATCH v3 1/2] ASoC: kirkwood: clk: probe defer when clock not yet ready Message-ID: <20130924125646.68d3f7b4@armhf> X-Mailer: Claws Mail 3.9.2 (GTK+ 2.24.21; arm-unknown-linux-gnueabihf) Mime-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130924_065455_265664_562359BC X-CRM114-Status: GOOD ( 18.92 ) X-Spam-Score: 1.5 (+) Cc: devicetree@vger.kernel.org, alsa-devel@alsa-project.org, Mike Turquette , Takashi Iwai , Rob Herring , Jaroslav Kysela , Grant Likely , Russell King , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,FREEMAIL_FROM, KHOP_BIG_TO_CC,RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=ham 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 At probe time, a clock device may not be ready when some other device wants to use it. This patch lets the functions clk_get/devm_clk_get return a probe defer when the clock is defined in the DT but not yet available. It also fixes an erroneous call to clk_get_sys() when __clk_get() fails. Signed-off-by: Jean-Francois Moine --- v2: fix __clk_get() failure (from Russell King) Note: the associated patch v2 2/2 is unchanged and not resent --- drivers/clk/clk.c | 2 +- drivers/clk/clkdev.c | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index a004769..582abc8 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -2181,7 +2181,7 @@ EXPORT_SYMBOL_GPL(of_clk_del_provider); struct clk *of_clk_get_from_provider(struct of_phandle_args *clkspec) { struct of_clk_provider *provider; - struct clk *clk = ERR_PTR(-ENOENT); + struct clk *clk = ERR_PTR(-EPROBE_DEFER); /* Check if we have such a provider in our array */ mutex_lock(&of_clk_lock); diff --git a/drivers/clk/clkdev.c b/drivers/clk/clkdev.c index 442a313..1f402b9 100644 --- a/drivers/clk/clkdev.c +++ b/drivers/clk/clkdev.c @@ -157,7 +157,12 @@ struct clk *clk_get(struct device *dev, const char *con_id) if (dev) { clk = of_clk_get_by_name(dev->of_node, con_id); - if (!IS_ERR(clk) && __clk_get(clk)) + if (!IS_ERR(clk)) { + if (!__clk_get(clk)) + clk = ERR_PTR(-ENOENT); + return clk; + } + if (PTR_ERR(clk) == -EPROBE_DEFER) return clk; }