All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dong Aisheng <aisheng.dong@nxp.com>
To: linux-clk@vger.kernel.org
Cc: linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, sboyd@kernel.org,
	mturquette@baylibre.com, shawnguo@kernel.org, linux-imx@nxp.com,
	Dong Aisheng <aisheng.dong@nxp.com>,
	Stephen Boyd <sboyd@codeaurora.org>,
	Russell King <linux@arm.linux.org.uk>
Subject: [PATCH V3 1/4] clk: bulk: add of_clk_bulk_get()
Date: Fri, 25 May 2018 18:37:20 +0800	[thread overview]
Message-ID: <1527244643-10736-2-git-send-email-aisheng.dong@nxp.com> (raw)
In-Reply-To: <1527244643-10736-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>
---
v2->v3:
 * remove #if define condition
 * remove EXPORT_SYMBOL
---
 drivers/clk/clk-bulk.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/drivers/clk/clk-bulk.c b/drivers/clk/clk-bulk.c
index 6904ed6..4460ac5 100644
--- a/drivers/clk/clk-bulk.c
+++ b/drivers/clk/clk-bulk.c
@@ -19,6 +19,35 @@
 #include <linux/clk.h>
 #include <linux/device.h>
 #include <linux/export.h>
+#include <linux/of.h>
+
+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;
+}
 
 void clk_bulk_put(int num_clks, struct clk_bulk_data *clks)
 {
-- 
2.7.4

WARNING: multiple messages have this Message-ID (diff)
From: aisheng.dong@nxp.com (Dong Aisheng)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH V3 1/4] clk: bulk: add of_clk_bulk_get()
Date: Fri, 25 May 2018 18:37:20 +0800	[thread overview]
Message-ID: <1527244643-10736-2-git-send-email-aisheng.dong@nxp.com> (raw)
In-Reply-To: <1527244643-10736-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>
---
v2->v3:
 * remove #if define condition
 * remove EXPORT_SYMBOL
---
 drivers/clk/clk-bulk.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/drivers/clk/clk-bulk.c b/drivers/clk/clk-bulk.c
index 6904ed6..4460ac5 100644
--- a/drivers/clk/clk-bulk.c
+++ b/drivers/clk/clk-bulk.c
@@ -19,6 +19,35 @@
 #include <linux/clk.h>
 #include <linux/device.h>
 #include <linux/export.h>
+#include <linux/of.h>
+
+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;
+}
 
 void clk_bulk_put(int num_clks, struct clk_bulk_data *clks)
 {
-- 
2.7.4

  reply	other threads:[~2018-05-25 10:38 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-25 10:37 [PATCH V3 0/4] clk: new APIs to handle all available clocks Dong Aisheng
2018-05-25 10:37 ` Dong Aisheng
2018-05-25 10:37 ` Dong Aisheng [this message]
2018-05-25 10:37   ` [PATCH V3 1/4] clk: bulk: add of_clk_bulk_get() Dong Aisheng
2018-05-25 10:37 ` [PATCH V3 2/4] clk: add new APIs to operate on all available clocks Dong Aisheng
2018-05-25 10:37   ` Dong Aisheng
2018-05-25 10:37 ` [PATCH V3 3/4] clk: add managed version of clk_bulk_get_all Dong Aisheng
2018-05-25 10:37   ` Dong Aisheng
2018-05-25 10:37 ` [PATCH V3 4/4] video: simplefb: switch to use clk_bulk API to simplify clock operations Dong Aisheng
2018-05-25 10:37   ` Dong Aisheng
2018-05-25 10:37   ` Dong Aisheng
2018-06-20  2:53 ` [PATCH V3 0/4] clk: new APIs to handle all available clocks A.s. Dong
2018-06-20  2:53   ` A.s. Dong
2018-06-20  2:53   ` A.s. Dong
2018-08-17  2:33   ` A.s. Dong
2018-08-17  2:33     ` A.s. Dong
2018-08-17  2:33     ` A.s. Dong
2018-08-20 16:32     ` Thor Thayer
2018-08-20 16:32       ` Thor Thayer
2018-08-20 16:32       ` Thor Thayer
2018-08-29  3:08     ` Stephen Boyd
2018-08-29  3:08       ` Stephen Boyd
2018-08-29  3:08       ` Stephen Boyd
2018-08-29 12:26       ` A.s. Dong
2018-08-29 12:26         ` A.s. Dong
2018-08-29 12:26         ` A.s. Dong

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=1527244643-10736-2-git-send-email-aisheng.dong@nxp.com \
    --to=aisheng.dong@nxp.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-imx@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=mturquette@baylibre.com \
    --cc=sboyd@codeaurora.org \
    --cc=sboyd@kernel.org \
    --cc=shawnguo@kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.