From patchwork Mon Mar 3 18:22:10 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: 3756211 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 2DD049F376 for ; Mon, 3 Mar 2014 18:23:15 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 21F33203E6 for ; Mon, 3 Mar 2014 18:23:14 +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 2768A203DF for ; Mon, 3 Mar 2014 18:23:12 +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 1WKXVy-0001kC-RJ; Mon, 03 Mar 2014 18:22:58 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WKXVw-0000Si-O1; Mon, 03 Mar 2014 18:22:56 +0000 Received: from mailout4.samsung.com ([203.254.224.34]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WKXVt-0000R9-Cy for linux-arm-kernel@lists.infradead.org; Mon, 03 Mar 2014 18:22:55 +0000 Received: from epcpsbgm2.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout4.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0N1V00GE5HPGR290@mailout4.samsung.com> for linux-arm-kernel@lists.infradead.org; Tue, 04 Mar 2014 03:22:28 +0900 (KST) X-AuditID: cbfee61b-b7f456d000006dfd-fd-5314c864b795 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 36.34.28157.468C4135; Tue, 04 Mar 2014 03:22:28 +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 <0N1V00KQYHP3NX40@mmp1.samsung.com>; Tue, 04 Mar 2014 03:22:28 +0900 (KST) From: Sylwester Nawrocki To: linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org Subject: [RFC PATCH v2 1/2] clk: Add function parsing arbitrary clock list DT property Date: Mon, 03 Mar 2014 19:22:10 +0100 Message-id: <1393870930-20971-1-git-send-email-s.nawrocki@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1393870533-20845-1-git-send-email-s.nawrocki@samsung.com> References: <1393870533-20845-1-git-send-email-s.nawrocki@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrNLMWRmVeSWpSXmKPExsVy+t9jAd2UEyLBBlcuCVjMP3KO1aL/zUJW iwN/djBaNC9ez2ZxtukNu8Wmx9dYLS7vmsNmcfsyr8XaI3fZLZZev8hk8XTCRTaL1r1H2C0O v2lntZgx+SWbxfoZr1kc+D3WzFvD6NHS3MPmcbmvl8lj06pONo871/aweeyfu4bdY/OSeo++ LasYPT5vkgvgjOKySUnNySxLLdK3S+DKmDH7NlvBdZGK4+tYGxj/CnQxcnBICJhI9JyU72Lk BDLFJC7cW8/WxcjFISSwiFHi96P17BBOB5PEyg3b2UCq2AQMJXqP9jGC2CICLhKdD9axgNjM AreYJKaclAKxhQUiJDZ+nQYWZxFQldjYuwPM5hVwk+j/18cCsVhBYs4kG5Awp4C7xOyjncwg thBQycuZF9knMPIuYGRYxSiaWpBcUJyUnmukV5yYW1yal66XnJ+7iREcxM+kdzCuarA4xCjA wajEw+swRSRYiDWxrLgy9xCjBAezkghvRA1QiDclsbIqtSg/vqg0J7X4EKM0B4uSOO/BVutA IYH0xJLU7NTUgtQimCwTB6dUA2Pody5WtRvTZLd0K1nur97bXSiWfC+nnemDzYd98e+Ob1gT 5lO7VPjHfE6N7MdHJjgn2j+7JWD291h+6tXg0CdX0zPtF4gUpciv0vZ32sD/QniTts3zjlW+ /fnrZ/V9aFzIenqSa8V/bqGt1xVmNG88tC1hDkvH8mnNFbt3X1zjd7z7U/fagy1KLMUZiYZa zEXFiQDzTZZtXgIAAA== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140303_132253_753173_46FC18A7 X-CRM114-Status: GOOD ( 12.38 ) X-Spam-Score: -3.9 (---) Cc: mark.rutland@arm.com, mturquette@linaro.org, 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.linux.org.uk, 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.2 required=5.0 tests=BAYES_00,KHOP_BIG_TO_CC, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=no 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 Acked-by: Kyungmin Park --- Changes since v1: - s/of_clk_get_list_entry/of_clk_get_by_property. --- drivers/clk/clk.h | 3 +++ drivers/clk/clkdev.c | 25 +++++++++++++++++++++---- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/drivers/clk/clk.h b/drivers/clk/clk.h index 795cc9f..666bc50 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_by_property(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..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); /**