From patchwork Sat Sep 21 10:00:06 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: 2922141 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 0AD80BFF05 for ; Sat, 21 Sep 2013 09:59:09 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 15978204CE for ; Sat, 21 Sep 2013 09:59:08 +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 35E0B204AB for ; Sat, 21 Sep 2013 09:59:07 +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 1VNJxg-0001AP-AX; Sat, 21 Sep 2013 09:58:48 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VNJxY-0004sY-DP; Sat, 21 Sep 2013 09:58:40 +0000 Received: from smtp1-g21.free.fr ([2a01:e0c:1:1599::10]) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VNJxS-0004qz-M7 for linux-arm-kernel@lists.infradead.org; Sat, 21 Sep 2013 09:58:38 +0000 Received: from armhf (unknown [IPv6:2a01:e35:2f5c:9de0:212:bfff:fe1e:9ce4]) by smtp1-g21.free.fr (Postfix) with ESMTP id 3DE0F940186; Sat, 21 Sep 2013 11:57:45 +0200 (CEST) Date: Sat, 21 Sep 2013 12:00:06 +0200 From: Jean-Francois Moine To: Liam Girdwood , Mark Brown Subject: [PATCH v2 1/2] ASoC: kirkwood: clk: probe defer when clock not yet ready Message-ID: <20130921120006.47b00fe7@armhf> X-Mailer: Claws Mail 3.9.2 (GTK+ 2.24.20; arm-unknown-linux-gnueabihf) Mime-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130921_055838_040761_DEC6BF13 X-CRM114-Status: GOOD ( 17.88 ) 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=-1.4 required=5.0 tests=BAYES_00,FREEMAIL_FROM, KHOP_BIG_TO_CC,RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=no 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. Signed-off-by: Jean-Francois Moine --- drivers/clk/clk.c | 2 +- drivers/clk/clkdev.c | 9 +++++++-- 2 files changed, 8 insertions(+), 3 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..f8b28d9 100644 --- a/drivers/clk/clkdev.c +++ b/drivers/clk/clkdev.c @@ -157,8 +157,13 @@ 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)) - return clk; + if (!IS_ERR(clk)) { + if (__clk_get(clk)) + return clk; + } else { + if (PTR_ERR(clk) == -EPROBE_DEFER) + return clk; + } } return clk_get_sys(dev_id, con_id);