From: Dong Aisheng <aisheng.dong@nxp.com>
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH V2 1/4] clk: bulk: add of_clk_bulk_get()
Date: Wed, 21 Mar 2018 02:54:51 +0000 [thread overview]
Message-ID: <1521600894-29919-2-git-send-email-aisheng.dong@nxp.com> (raw)
In-Reply-To: <1521600894-29919-1-git-send-email-aisheng.dong@nxp.com>
'clock-names' property is optional in DT, so of_clk_bulk_get() is
introduced here to handle this for DT users without 'clock-names'
specified. Later clk_bulk_get_all() will be implemented on top of
it and this API will be kept private until someone proves they need
it because they don't have a struct device pointer.
Cc: Stephen Boyd <sboyd@codeaurora.org>
Cc: Michael Turquette <mturquette@baylibre.com>
Cc: Russell King <linux@arm.linux.org.uk>
Reported-by: Shawn Guo <shawnguo@kernel.org>
Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
---
drivers/clk/clk-bulk.c | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/drivers/clk/clk-bulk.c b/drivers/clk/clk-bulk.c
index 4c10456..4b357b2 100644
--- a/drivers/clk/clk-bulk.c
+++ b/drivers/clk/clk-bulk.c
@@ -19,6 +19,38 @@
#include <linux/clk.h>
#include <linux/device.h>
#include <linux/export.h>
+#include <linux/of.h>
+
+#if defined(CONFIG_OF) && defined(CONFIG_COMMON_CLK)
+static int __must_check of_clk_bulk_get(struct device_node *np, int num_clks,
+ struct clk_bulk_data *clks)
+{
+ int ret;
+ int i;
+
+ for (i = 0; i < num_clks; i++)
+ clks[i].clk = NULL;
+
+ for (i = 0; i < num_clks; i++) {
+ clks[i].clk = of_clk_get(np, i);
+ if (IS_ERR(clks[i].clk)) {
+ ret = PTR_ERR(clks[i].clk);
+ pr_err("%pOF: Failed to get clk index: %d ret: %d\n",
+ np, i, ret);
+ clks[i].clk = NULL;
+ goto err;
+ }
+ }
+
+ return 0;
+
+err:
+ clk_bulk_put(i, clks);
+
+ return ret;
+}
+EXPORT_SYMBOL(of_clk_bulk_get);
+#endif
void clk_bulk_put(int num_clks, struct clk_bulk_data *clks)
{
--
2.7.4
next prev parent reply other threads:[~2018-03-21 2:54 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-21 2:54 [PATCH V2 0/4] clk: new APIs to handle all available clocks Dong Aisheng
2018-03-21 2:54 ` Dong Aisheng [this message]
2018-03-21 2:54 ` [PATCH V2 2/4] clk: add new APIs to operate on " Dong Aisheng
2018-03-21 2:54 ` [PATCH V2 3/4] clk: add managed version of clk_bulk_get_all Dong Aisheng
2018-03-23 6:49 ` kbuild test robot
2018-05-25 9:51 ` A.s. Dong
2018-03-21 2:54 ` [PATCH V2 4/4] video: simplefb: switch to use clk_bulk API to simplify clock operations Dong Aisheng
2018-03-23 5:28 ` kbuild test robot
2018-03-25 16:29 ` kbuild test robot
2018-03-21 3:19 ` [PATCH V2 0/4] clk: new APIs to handle all available clocks Dong Aisheng
2018-03-21 3:19 ` [PATCH V2 1/4] clk: bulk: add of_clk_bulk_get() Dong Aisheng
2018-03-23 16:53 ` Stephen Boyd
2018-05-25 9:48 ` A.s. Dong
2018-03-21 3:19 ` [PATCH V2 2/4] clk: add new APIs to operate on all available clocks Dong Aisheng
2018-03-23 16:56 ` Stephen Boyd
2018-05-25 9:49 ` A.s. Dong
2018-03-21 3:19 ` [PATCH V2 3/4] clk: add managed version of clk_bulk_get_all Dong Aisheng
2018-03-21 3:19 ` [PATCH V2 4/4] video: simplefb: switch to use clk_bulk API to simplify clock operations Dong Aisheng
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1521600894-29919-2-git-send-email-aisheng.dong@nxp.com \
--to=aisheng.dong@nxp.com \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).