From patchwork Thu Mar 27 12:16:18 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: 3897801 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 E1B11BF540 for ; Thu, 27 Mar 2014 12:20:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 164E32021C for ; Thu, 27 Mar 2014 12:20:17 +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 216122021A for ; Thu, 27 Mar 2014 12:20:16 +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 1WT9I2-0003eP-0M; Thu, 27 Mar 2014 12:20:10 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WT9Hz-00047t-Ig; Thu, 27 Mar 2014 12:20:07 +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 1WT9Hv-00046y-3p for linux-arm-kernel@lists.infradead.org; Thu, 27 Mar 2014 12:20:05 +0000 Received: from epcpsbgm2.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0N3300369GWQSDA0@mailout3.samsung.com> for linux-arm-kernel@lists.infradead.org; Thu, 27 Mar 2014 21:19:39 +0900 (KST) X-AuditID: cbfee61b-b7f456d000006dfd-b7-5334175a6a6b Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 9A.D4.28157.A5714335; Thu, 27 Mar 2014 21:19:38 +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 <0N3300DCRGRCTL60@mmp1.samsung.com>; Thu, 27 Mar 2014 21:19:38 +0900 (KST) From: Sylwester Nawrocki To: mturquette@linaro.org Subject: [PATCH RFC v3 1/2] clk: Add function parsing arbitrary clock list DT property Date: Thu, 27 Mar 2014 13:16:18 +0100 Message-id: <1395922579-28547-2-git-send-email-s.nawrocki@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1395922579-28547-1-git-send-email-s.nawrocki@samsung.com> References: <1395922579-28547-1-git-send-email-s.nawrocki@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrLLMWRmVeSWpSXmKPExsVy+t9jAd0ocZNgg82tZhbzj5xjteh/s5DV 4sCfHYwWzYvXs1mcbXrDbrHp8TVWi8u75rBZ3L7Ma7H2yF12i6XXLzJZPJ1wkc2ide8RdovD b9pZLWZMfslmsX7GaxYHfo8189YwerQ097B5XO7rZfLYtKqTzePOtT1sHvvnrmH32Lyk3qNv yypGj8+b5AI4o7hsUlJzMstSi/TtErgy9vR0MBXMkKiY9OEfcwPjO+EuRk4OCQETiW+t/ewQ tpjEhXvr2UBsIYFFjBLbGqy6GLmA7A4miQmnfrCAJNgEDCV6j/YxgtgiApISDz5PZwEpYhZo Z5ZYO2UTWJGwQIRE+8InYJNYBFQlVj2dDWbzCrhJfD13H2gbB9A2BYk5k2xAwpwC7hK731xh gVjsJvHk2H/GCYy8CxgZVjGKphYkFxQnpeca6RUn5haX5qXrJefnbmIEB/Iz6R2MqxosDjEK cDAq8fDuuG8ULMSaWFZcmXuIUYKDWUmE97awSbAQb0piZVVqUX58UWlOavEhRmkOFiVx3oOt 1oFCAumJJanZqakFqUUwWSYOTqkGRrbo/S5aT1IeWtR3u096x6ZzrjfhiK3I54PVrMEbdK/I df9+8tNK86RHgNY9r+cLKzuL5nPs/Lww8ITU902WihoB6pv+ZpRt7HitpHf8jNhBnWuFU3/v l7/15iaf1d+q197zywW7G3js7xUa+YY0PGj7u1Qg8vCM2HsJsecvff95YMLH4o1zXiuxFGck GmoxFxUnAgAK6SPHYAIAAA== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140327_082003_379353_1279347E X-CRM114-Status: GOOD ( 11.84 ) X-Spam-Score: -7.3 (-------) Cc: mark.rutland@arm.com, devicetree@vger.kernel.org, linux@arm.linux.org.uk, gregkh@linuxfoundation.org, 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, linux-arm-kernel@lists.infradead.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=-4.6 required=5.0 tests=BAYES_00, 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_by_property() function added by this patch is similar to of_clk_get(), except it allows to pass name of a DT property containing list of phandles and clock specifiers. For of_clk_get() this has been hard coded to "clocks". Signed-off-by: Sylwester Nawrocki --- 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/clkdev.c | 25 +++++++++++++++++++++---- include/linux/clk.h | 7 +++++++ 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/drivers/clk/clkdev.c b/drivers/clk/clkdev.c index a360b2e..1d41540 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_by_property() - 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_by_property(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_by_property); + +struct clk *of_clk_get(struct device_node *np, int index) +{ + return of_clk_get_by_property(np, "clocks", index); +} EXPORT_SYMBOL(of_clk_get); /** diff --git a/include/linux/clk.h b/include/linux/clk.h index 0dd9114..f71235b 100644 --- a/include/linux/clk.h +++ b/include/linux/clk.h @@ -383,6 +383,8 @@ struct of_phandle_args; #if defined(CONFIG_OF) && defined(CONFIG_COMMON_CLK) struct clk *of_clk_get(struct device_node *np, int index); +struct clk *of_clk_get_by_property(struct device_node *np, + const char *list_name, int index); struct clk *of_clk_get_by_name(struct device_node *np, const char *name); struct clk *of_clk_get_from_provider(struct of_phandle_args *clkspec); #else @@ -395,6 +397,11 @@ static inline struct clk *of_clk_get_by_name(struct device_node *np, { return ERR_PTR(-ENOENT); } +struct clk *of_clk_get_by_property(struct device_node *np, + const char *list_name, int index) +{ + return ERR_PTR(-ENOENT); +} #endif #endif