From patchwork Mon Nov 25 18:47:04 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: 3610231 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 3AC20BF418 for ; Sat, 8 Feb 2014 13:26:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6F79A2012F for ; Sat, 8 Feb 2014 13:26:01 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (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 5FC5B2010F for ; Sat, 8 Feb 2014 13:26:00 +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 1WC7uU-0000SE-Tm; Sat, 08 Feb 2014 13:25:31 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WC7uS-00049G-Fd; Sat, 08 Feb 2014 13:25:28 +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 1WC7uO-00048q-8I for linux-arm-kernel@lists.infradead.org; Sat, 08 Feb 2014 13:25:25 +0000 Received: from localhost (unknown [IPv6:2a01:e35:2f5c:9de0:212:bfff:fe1e:9ce4]) by smtp1-g21.free.fr (Postfix) with ESMTP id 2A26694003E; Sat, 8 Feb 2014 14:24:45 +0100 (CET) X-Mailbox-Line: From ef032fdeb6199f421275c74a4583c0804e57fb22 Mon Sep 17 00:00:00 2001 From: Jean-Francois Moine Date: Mon, 25 Nov 2013 19:47:04 +0100 Subject: [PATCH RESEND v3] clk: return probe defer when DT clock not yet ready To: Mike Turquette , linux-arm-kernel@lists.infradead.org Message-Id: <20140208132446.2A26694003E@smtp1-g21.free.fr> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140208_082524_987696_C638108B X-CRM114-Status: GOOD ( 12.43 ) X-Spam-Score: 1.5 (+) Cc: Grant Likely , devicetree@vger.kernel.org, Rob Herring , Russell King , linux-kernel@vger.kernel.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: , MIME-Version: 1.0 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.3 required=5.0 tests=BAYES_00, DATE_IN_PAST_96_XX, FREEMAIL_FROM,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. Signed-off-by: Jean-Francois Moine Reviewed-by: Sylwester Nawrocki Tested-by: Sylwester Nawrocki --- resend v3: - base kernel 3.14.0-rc1 - __clk_get() failure is fixed resend v2: remove ASoc from subject (thank you, Mark) resend: - patch subject change from [PATCH v3 1/2] ASoC: kirkwood: clk: probe defer when clock not yet ready - base kernel 3.13.0-rc1 v2: fix __clk_get() failure (from Russell King) --- drivers/clk/clk.c | 2 +- drivers/clk/clkdev.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 5517944..32d84e9 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -2472,7 +2472,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 */ list_for_each_entry(provider, &of_clk_providers, link) { diff --git a/drivers/clk/clkdev.c b/drivers/clk/clkdev.c index 48f6721..a360b2e 100644 --- a/drivers/clk/clkdev.c +++ b/drivers/clk/clkdev.c @@ -167,6 +167,8 @@ struct clk *clk_get(struct device *dev, const char *con_id) clk = of_clk_get_by_name(dev->of_node, con_id); if (!IS_ERR(clk)) return clk; + if (PTR_ERR(clk) == -EPROBE_DEFER) + return clk; } return clk_get_sys(dev_id, con_id);