From patchwork Mon Mar 31 16:41:55 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: 3916601 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 8D295BF540 for ; Mon, 31 Mar 2014 16:44:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 93FBF2017D for ; Mon, 31 Mar 2014 16:43:59 +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 923BB20165 for ; Mon, 31 Mar 2014 16:43:58 +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 1WUfJ4-0002Lg-R3; Mon, 31 Mar 2014 16:43:31 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WUfIt-0008AO-Up; Mon, 31 Mar 2014 16:43:19 +0000 Received: from mailout1.samsung.com ([203.254.224.24]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WUfIr-00088A-1m for linux-arm-kernel@lists.infradead.org; Mon, 31 Mar 2014 16:43:18 +0000 Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0N3B0032N7RH6C70@mailout1.samsung.com> for linux-arm-kernel@lists.infradead.org; Tue, 01 Apr 2014 01:42:54 +0900 (KST) X-AuditID: cbfee61a-b7fb26d00000724f-36-53399b0d8199 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 70.6F.29263.D0B99335; Tue, 01 Apr 2014 01:42:53 +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 <0N3B00DP07Q4P470@mmp1.samsung.com>; Tue, 01 Apr 2014 01:42:53 +0900 (KST) From: Sylwester Nawrocki To: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH RFC v4 1/2] clk: Add function parsing arbitrary clock list DT property Date: Mon, 31 Mar 2014 18:41:55 +0200 Message-id: <1396284116-19178-2-git-send-email-s.nawrocki@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1396284116-19178-1-git-send-email-s.nawrocki@samsung.com> References: <1396284116-19178-1-git-send-email-s.nawrocki@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrILMWRmVeSWpSXmKPExsVy+t9jAV3e2ZbBBhPem1jMP3KO1aL/zUJW iwN/djBaNC9ez2ZxtukNu0XnxCXsFpseX2O1uLxrDpvF7cu8FmuP3GW3WHr9IpPF0wkX2Sxa 9x5ht/i7fROLxeE37awWMya/ZLNYP+M1i4Ogx5p5axg9Wpp72Dwu9/UyeczumMnqsWlVJ5vH nWt72Dz2z13D7rF5Sb1H/18Dj74tqxg9Pm+SC+CO4rJJSc3JLEst0rdL4Mo4vv8pa8E/iYqb +86zNTAeEOli5OSQEDCReHV8NxOELSZx4d56ti5GLg4hgUWMEpffnWeHcDqYJP68m8MIUsUm YCjRe7QPzBYRsJHo2XKSEaSIWWA+s8TxJyfYQBLCAhESZ26tYAaxWQRUJXb294A18Aq4SZx4 cJO1i5EDaJ2CxJxJNiBhTgF3iUXbvoKVCAGVzH26iXkCI+8CRoZVjKKpBckFxUnpuYZ6xYm5 xaV56XrJ+bmbGMEB/0xqB+PKBotDjAIcjEo8vBbllsFCrIllxZW5hxglOJiVRHiPTAcK8aYk VlalFuXHF5XmpBYfYpTmYFES5z3Qah0oJJCeWJKanZpakFoEk2Xi4JRqYEz3lW4ueTh/ZX9H A9uNZ53bg+Tawiar2ySu3H6tsJH78tKex2tEdrj+DJ6pmpK5K/5Gdgr/vQsLHlqvb+Vjlnqk 135hk1j4xKuLjwgtPS+kbHkmUzWIj2++cKDx2kUTF1pxX/poxcC4gFvo7m32yTqnWOvex4qZ Xm8tPHVJUmch37+Ut9dczJRYijMSDbWYi4oTAVvA/N90AgAA X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140331_124317_307291_9087DD00 X-CRM114-Status: GOOD ( 12.42 ) X-Spam-Score: -7.5 (-------) Cc: mark.rutland@arm.com, mturquette@linaro.org, gregkh@linuxfoundation.org, t.figa@samsung.com, sw0312.kim@samsung.com, kyungmin.park@samsung.com, robh+dt@kernel.org, laurent.pinchart@ideasonboard.com, Sylwester Nawrocki , galak@codeaurora.org, grant.likely@linaro.org, linux@arm.linux.org.uk, s.hauer@pengutronix.de, 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.8 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 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/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 fb5e097..f3811d3 100644 --- a/include/linux/clk.h +++ b/include/linux/clk.h @@ -397,6 +397,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 @@ -409,6 +411,11 @@ static inline struct clk *of_clk_get_by_name(struct device_node *np, { return ERR_PTR(-ENOENT); } +static inline struct clk *of_clk_get_by_property(struct device_node *np, + const char *list_name, int index) +{ + return ERR_PTR(-ENOENT); +} #endif #endif