From patchwork Wed Jul 18 03:52:22 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Guo X-Patchwork-Id: 1208401 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id BAFE740071 for ; Wed, 18 Jul 2012 03:36:12 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1SrKzd-0007P6-I9; Wed, 18 Jul 2012 03:32:05 +0000 Received: from va3ehsobe006.messaging.microsoft.com ([216.32.180.16] helo=va3outboundpool.messaging.microsoft.com) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1SrKz9-0007OM-SC for linux-arm-kernel@lists.infradead.org; Wed, 18 Jul 2012 03:31:37 +0000 Received: from mail116-va3-R.bigfish.com (10.7.14.242) by VA3EHSOBE014.bigfish.com (10.7.40.64) with Microsoft SMTP Server id 14.1.225.23; Wed, 18 Jul 2012 03:31:22 +0000 Received: from mail116-va3 (localhost [127.0.0.1]) by mail116-va3-R.bigfish.com (Postfix) with ESMTP id E30C840130; Wed, 18 Jul 2012 03:31:22 +0000 (UTC) X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null); IPV:NLI; H:mail.freescale.net; RD:none; EFVD:NLI X-SpamScore: 0 X-BigFish: VS0(zzzz1202hzz8275bh8275dhz2dh87h2a8h668h839hd24he5bhe96hf0ah107ah) X-FB-DOMAIN-IP-MATCH: fail Received: from mail116-va3 (localhost.localdomain [127.0.0.1]) by mail116-va3 (MessageSwitch) id 1342582280168937_4388; Wed, 18 Jul 2012 03:31:20 +0000 (UTC) Received: from VA3EHSMHS026.bigfish.com (unknown [10.7.14.239]) by mail116-va3.bigfish.com (Postfix) with ESMTP id 1B9CA1C004B; Wed, 18 Jul 2012 03:31:20 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by VA3EHSMHS026.bigfish.com (10.7.99.36) with Microsoft SMTP Server (TLS) id 14.1.225.23; Wed, 18 Jul 2012 03:31:20 +0000 Received: from az84smr01.freescale.net (10.64.34.197) by 039-SN1MMR1-002.039d.mgd.msft.net (10.84.1.15) with Microsoft SMTP Server (TLS) id 14.2.298.5; Tue, 17 Jul 2012 22:31:19 -0500 Received: from S2100-06.ap.freescale.net (S2100-06.ap.freescale.net [10.192.242.65]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id q6I3VEr9029768; Tue, 17 Jul 2012 20:31:17 -0700 From: Shawn Guo To: Mike Turquette Subject: [PATCH v2 1/2] clk: fix clk_get on of_clk_get_by_name return check Date: Wed, 18 Jul 2012 11:52:22 +0800 Message-ID: <1342583543-20404-2-git-send-email-shawn.guo@linaro.org> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1342583543-20404-1-git-send-email-shawn.guo@linaro.org> References: <1342583543-20404-1-git-send-email-shawn.guo@linaro.org> MIME-Version: 1.0 X-OriginatorOrg: sigmatel.com X-Spam-Note: CRM114 invocation failed X-Spam-Score: -4.2 (----) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-4.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [216.32.180.16 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Shawn Guo , Mike Turquette , linux-arm-kernel@lists.infradead.org, Rob Herring X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org The commit 766e6a4 (clk: add DT clock binding support) plugs device tree clk lookup of_clk_get_by_name into clk_get, and fall on non-DT lookup clk_get_sys if DT lookup fails. The return check on of_clk_get_by_name takes (clk != NULL) as a successful DT lookup. But it's not the case. For any system that does not define clk lookup in device tree, ERR_PTR(-ENOENT) will be returned, and consequently, all the client drivers calling clk_get in their probe functions will fail to probe with error code -ENOENT returned. Fix the issue by checking of_clk_get_by_name return with !IS_ERR(clk), and update of_clk_get and of_clk_get_by_name for !CONFIG_OF build correspondingly. Signed-off-by: Shawn Guo Acked-by: Rob Herring Tested-by: Marek Vasut Tested-by: Lauri Hintsala --- drivers/clk/clkdev.c | 2 +- include/linux/clk.h | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/clk/clkdev.c b/drivers/clk/clkdev.c index 20649b3..69085e0 100644 --- a/drivers/clk/clkdev.c +++ b/drivers/clk/clkdev.c @@ -157,7 +157,7 @@ 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 (clk && __clk_get(clk)) + if (!IS_ERR(clk) && __clk_get(clk)) return clk; } diff --git a/include/linux/clk.h b/include/linux/clk.h index 9e9b875..6283e2e 100644 --- a/include/linux/clk.h +++ b/include/linux/clk.h @@ -12,6 +12,7 @@ #ifndef __LINUX_CLK_H #define __LINUX_CLK_H +#include #include #include @@ -370,12 +371,12 @@ struct clk *of_clk_get_from_provider(struct of_phandle_args *clkspec); #else static inline struct clk *of_clk_get(struct device_node *np, int index) { - return NULL; + return ERR_PTR(-ENOENT); } static inline struct clk *of_clk_get_by_name(struct device_node *np, const char *name) { - return NULL; + return ERR_PTR(-ENOENT); } #endif