From patchwork Wed Feb 19 16:58:42 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: 3682471 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 25DF1BF13A for ; Wed, 19 Feb 2014 17:00:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0F2CB201ED for ; Wed, 19 Feb 2014 17:00:52 +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 0C84E201D5 for ; Wed, 19 Feb 2014 17:00:51 +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 1WGAVa-0007l4-9U; Wed, 19 Feb 2014 17:00:30 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WGAVT-0000Sg-NB; Wed, 19 Feb 2014 17:00:23 +0000 Received: from mailout3.samsung.com ([203.254.224.33]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WGAVR-0000Q1-12 for linux-arm-kernel@lists.infradead.org; Wed, 19 Feb 2014 17:00:22 +0000 Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0N19001LD5VXX8A0@mailout3.samsung.com> for linux-arm-kernel@lists.infradead.org; Thu, 20 Feb 2014 01:59:57 +0900 (KST) X-AuditID: cbfee61a-b7fb26d00000724f-c5-5304e30d02d2 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id FB.F3.29263.D03E4035; Thu, 20 Feb 2014 01:59:57 +0900 (KST) Received: from amdc1344.digital.local ([106.116.147.32]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0N19001665U6CW20@mmp2.samsung.com>; Thu, 20 Feb 2014 01:59:57 +0900 (KST) From: Sylwester Nawrocki To: linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org Subject: [PATCH RFC v1 1/3] clk: Add function to parse an arbitrary clocks list property Date: Wed, 19 Feb 2014 17:58:42 +0100 Message-id: <1392829124-25705-2-git-send-email-s.nawrocki@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1392829124-25705-1-git-send-email-s.nawrocki@samsung.com> References: <1392829124-25705-1-git-send-email-s.nawrocki@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrPLMWRmVeSWpSXmKPExsVy+t9jQV3exyzBBv/e6VvMP3KO1aL/zUJW iwN/djBanG16w26x6fE1Vovbl3kt1h65y26x9PpFJounEy6yWbTuPcJucfhNO6vFjMkv2SzW z3jN4sDrsWbeGkaPluYeNo/Lfb1MHptWdbJ53Lm2h81j85J6j74tqxg9Pm+SC+CI4rJJSc3J LEst0rdL4Mo4c2gLc8E94YrvCxezNDDOFehi5OSQEDCRmP5tOyOELSZx4d56ti5GLg4hgemM EqfPb2OCcDqYJE7u+sAKUsUmYCjRe7QPrENEwEWi88E6FpAiZoF5TBKX2o8ygSSEBaIkZh0+ zgxiswioSny89QfM5hVwkzgy8z2QzQG0TkFiziQbkDCngLvEo7srwFqFgEoaTp9incDIu4CR YRWjaGpBckFxUnquoV5xYm5xaV66XnJ+7iZGcLA+k9rBuLLB4hCjAAejEg8vxx2WYCHWxLLi ytxDjBIczEoivHPuA4V4UxIrq1KL8uOLSnNSiw8xSnOwKInzHmi1DhQSSE8sSc1OTS1ILYLJ MnFwSjUwav+skK+RmNU/Z4NKleZzS2WHH6IhnMHbjAKLkk8/S+EUuMr6edvmif4ajCqzJl+4 xdIhlJWybM+xRZPb2kMaD/jNfDp7+sJtb6dpCdi/XfHxuT5fTcSWl08C25JF+e8GxhpvfiHo xfxfe6K2o1lMj9D+2Ma1Gz6lsvh9tDpjzLc8l12Uj2WhEktxRqKhFnNRcSIAq5j7fVICAAA= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140219_120021_298939_28586F24 X-CRM114-Status: GOOD ( 11.52 ) X-Spam-Score: -4.6 (----) Cc: mark.rutland@arm.com, linux@arm.linux.org.uk, t.figa@samsung.com, sw0312.kim@samsung.com, kyungmin.park@samsung.com, robh+dt@kernel.org, Sylwester Nawrocki , galak@codeaurora.org, grant.likely@linaro.org, mturquette@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=-1.9 required=5.0 tests=BAYES_00,KHOP_BIG_TO_CC, RCVD_IN_DNSWL_MED, 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 The of_clk_get_list_entry() function is like of_clk_get() except it allows to pass name of a DT property containing list of phandles and clock specifiers. For of_clk_get() it has been hard coded to "clocks". Signed-off-by: Sylwester Nawrocki Acked-by: Kyungmin Park --- drivers/clk/clk.h | 3 +++ drivers/clk/clkdev.c | 25 +++++++++++++++++++++---- 2 files changed, 24 insertions(+), 4 deletions(-) -- 1.7.9.5 diff --git a/drivers/clk/clk.h b/drivers/clk/clk.h index 795cc9f..dd9def1 100644 --- a/drivers/clk/clk.h +++ b/drivers/clk/clk.h @@ -10,7 +10,10 @@ */ #if defined(CONFIG_OF) && defined(CONFIG_COMMON_CLK) + struct clk *__of_clk_get_from_provider(struct of_phandle_args *clkspec); void of_clk_lock(void); void of_clk_unlock(void); +struct clk *of_clk_get_list_entry(struct device_node *np, + const char *list_name, int index); #endif diff --git a/drivers/clk/clkdev.c b/drivers/clk/clkdev.c index a360b2e..465662e 100644 --- a/drivers/clk/clkdev.c +++ b/drivers/clk/clkdev.c @@ -27,17 +27,28 @@ static LIST_HEAD(clocks); static DEFINE_MUTEX(clocks_mutex); #if defined(CONFIG_OF) && defined(CONFIG_COMMON_CLK) -struct clk *of_clk_get(struct device_node *np, int index) +/** + * of_clk_get_list_entry() - Parse and lookup a clock referenced by a device node + * @np: pointer to clock consumer node + * @list_name: name of the clock list property + * @index: index to the clock list + * + * This function parses the @list_name property and together with @index + * value indicating an entry of the list uses it to look up the struct clk + * from the registered list of clock providers. + */ +struct clk *of_clk_get_list_entry(struct device_node *np, + const char *list_name, int index) { struct of_phandle_args clkspec; struct clk *clk; int rc; - if (index < 0) + if (index < 0 || !list_name) return ERR_PTR(-EINVAL); - rc = of_parse_phandle_with_args(np, "clocks", "#clock-cells", index, - &clkspec); + rc = of_parse_phandle_with_args(np, list_name, "#clock-cells", + index, &clkspec); if (rc) return ERR_PTR(rc); @@ -51,6 +62,12 @@ struct clk *of_clk_get(struct device_node *np, int index) of_node_put(clkspec.np); return clk; } +EXPORT_SYMBOL(of_clk_get_list_entry); + +struct clk *of_clk_get(struct device_node *np, int index) +{ + return of_clk_get_list_entry(np, "clocks", index); +} EXPORT_SYMBOL(of_clk_get); /**