From patchwork Mon May 19 17:22:50 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Sylwester Nawrocki/Kernel \\(PLT\\) /SRPOL/Staff Engineer/Samsung Electronics" X-Patchwork-Id: 4204721 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 C85629F32B for ; Mon, 19 May 2014 17:27:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EE428201F2 for ; Mon, 19 May 2014 17:27:40 +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 14CEC201E7 for ; Mon, 19 May 2014 17:27:40 +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 1WmRJh-0004T7-8O; Mon, 19 May 2014 17:25:37 +0000 Received: from mailout1.samsung.com ([203.254.224.24]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WmRJe-0004Hs-3I for linux-arm-kernel@lists.infradead.org; Mon, 19 May 2014 17:25:34 +0000 Received: from epcpsbgm2.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0N5U00KEL0DZVJA0@mailout1.samsung.com> for linux-arm-kernel@lists.infradead.org; Tue, 20 May 2014 02:25:11 +0900 (KST) X-AuditID: cbfee61b-b7fbb6d000001be3-74-537a3e76cf88 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id D3.B1.07139.67E3A735; Tue, 20 May 2014 02:25:11 +0900 (KST) Received: from amdc1344.digital.local ([106.116.147.32]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0N5U00B010A9ZE00@mmp1.samsung.com>; Tue, 20 May 2014 02:25:10 +0900 (KST) From: Sylwester Nawrocki To: linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, mturquette@linaro.org Subject: [PATCH/RFC V6 1/2] clk: Add of_clk_get_by_clkspec() helper Date: Mon, 19 May 2014 19:22:50 +0200 Message-id: <1400520171-6698-2-git-send-email-s.nawrocki@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1400520171-6698-1-git-send-email-s.nawrocki@samsung.com> References: <1400520171-6698-1-git-send-email-s.nawrocki@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrKLMWRmVeSWpSXmKPExsVy+t9jAd1yu6pggx2LWC3mHznHatH/ZiGr xYE/Oxgtzja9YbfY9Pgaq8XlXXPYLG5f5rVYe+Quu8XS6xeZLJ5OuMhmMWH6WhaL1r1H2C0O v2lntZgx+SWbxfoZr1kc+D3WzFvD6NHS3MPmcbmvl8lj06pONo871/aweWxeUu/Rt2UVo8fn TXIBHFFcNimpOZllqUX6dglcGb/XX2EtmCla0XiwroHxiGAXIyeHhICJxLLt89ghbDGJC/fW s3UxcnEICSxilGh6eJEVwulgkvi6rp0NpIpNwFCi92gfI4gtIhArseHZXkaQImaB3UwS6z8d Aepg5xAWcJZYWAZSwiKgKnG//yUriM0r4Cox7cEjpi5GDqBlChJzJtmAhDkF3CSevpnGChIW Aio598BjAiPvAkaGVYyiqQXJBcVJ6blGesWJucWleel6yfm5mxjBgftMegfjqgaLQ4wCHIxK PLwHxKuChVgTy4orcw8xSnAwK4nwupkAhXhTEiurUovy44tKc1KLDzFKc7AoifMebLUOFBJI TyxJzU5NLUgtgskycXBKNTAqPXduTI5mj+D0+iD121PPYMN9H33lkDficXNuSl7OjNy38Nnm P3MD9F5umX9TmHPfLnu2BG6ZZXcXWPxz/O0rf7huZkuejojUGVt93TMV821TeT682Dl3ZYyZ asSVuoOyX2s9z4dcX6R+z2D9WlaN8zL7H2x8dlHw1sW3aUb3C2bd9Zry+w2DEktxRqKhFnNR cSIAB2426lgCAAA= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140519_102534_312256_94331B89 X-CRM114-Status: GOOD ( 14.52 ) X-Spam-Score: -5.7 (-----) Cc: mark.rutland@arm.com, linux@arm.linux.org.uk, pawel.moll@arm.com, t.figa@samsung.com, sw0312.kim@samsung.com, linux-kernel@vger.kernel.org, kyungmin.park@samsung.com, robh+dt@kernel.org, Sylwester Nawrocki , galak@codeaurora.org, grant.likely@linaro.org, m.szyprowski@samsung.com 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=-2.5 required=5.0 tests=BAYES_00,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 This patch adds of_clk_get_by_clkspec() helper function, which does only a struct clk lookup from the clock providers. It is used in the subsequent patch where parsing of a clock from device tree and the lookup from providers needed to be split. Signed-off-by: Sylwester Nawrocki --- Changes since v5: - dropped of_clk_get_by_property(), added of_clk_get_by_clkspec(). Changes since v4: - none. Changes since v3: - added missing 'static inline' to the function stub definition. Changes since v2: - moved the function declaration from drivers/clk/clk.h to include/linux/clk.h Changes since v1: - s/of_clk_get_list_entry/of_clk_get_by_property. --- drivers/clk/clk.h | 1 + drivers/clk/clkdev.c | 34 +++++++++++++++++++++++++++------- 2 files changed, 28 insertions(+), 7 deletions(-) -- 1.7.9.5 diff --git a/drivers/clk/clk.h b/drivers/clk/clk.h index 795cc9f..c798138 100644 --- a/drivers/clk/clk.h +++ b/drivers/clk/clk.h @@ -10,6 +10,7 @@ */ #if defined(CONFIG_OF) && defined(CONFIG_COMMON_CLK) +struct clk *of_clk_get_by_clkspec(struct of_phandle_args *clkspec); struct clk *__of_clk_get_from_provider(struct of_phandle_args *clkspec); void of_clk_lock(void); void of_clk_unlock(void); diff --git a/drivers/clk/clkdev.c b/drivers/clk/clkdev.c index a360b2e..f890b90 100644 --- a/drivers/clk/clkdev.c +++ b/drivers/clk/clkdev.c @@ -27,6 +27,32 @@ static LIST_HEAD(clocks); static DEFINE_MUTEX(clocks_mutex); #if defined(CONFIG_OF) && defined(CONFIG_COMMON_CLK) + +/** + * of_clk_get_by_clkspec() - Lookup a clock form a clock provider + * @clkspec: pointer to a clock specifier data structure + * + * This function looks up a struct clk from the registered list of clock + * providers, an input is a clock specifier data structure as returned + * from the of_parse_phandle_with_args() function call. + */ +struct clk *of_clk_get_by_clkspec(struct of_phandle_args *clkspec) +{ + struct clk *clk; + + if (!clkspec) + return ERR_PTR(-EINVAL); + + of_clk_lock(); + clk = __of_clk_get_from_provider(clkspec); + + if (!IS_ERR(clk) && !__clk_get(clk)) + clk = ERR_PTR(-ENOENT); + + of_clk_unlock(); + return clk; +} + struct clk *of_clk_get(struct device_node *np, int index) { struct of_phandle_args clkspec; @@ -41,13 +67,7 @@ struct clk *of_clk_get(struct device_node *np, int index) if (rc) return ERR_PTR(rc); - of_clk_lock(); - clk = __of_clk_get_from_provider(&clkspec); - - if (!IS_ERR(clk) && !__clk_get(clk)) - clk = ERR_PTR(-ENOENT); - - of_clk_unlock(); + clk = of_clk_get_by_clkspec(&clkspec); of_node_put(clkspec.np); return clk; }