* [PATCH V2 0/4] clk: new APIs to handle all available clocks
@ 2018-03-21 3:19 Dong Aisheng
2018-03-21 3:19 ` [PATCH V2 1/4] clk: bulk: add of_clk_bulk_get() Dong Aisheng
` (3 more replies)
0 siblings, 4 replies; 13+ messages in thread
From: Dong Aisheng @ 2018-03-21 3:19 UTC (permalink / raw)
To: linux-clk
Cc: linux-kernel, linux-arm-kernel, mturquette, hdegoede,
b.zolnierkie, linux, linux-fbdev, linux-imx, sboyd, Dong Aisheng
This patch series is a continue of discussion from here,
https://patchwork.kernel.org/patch/9986293/
that some users may want to handle all available clocks from device
tree without need to know the detailed clock information likes clock
numbers and names. This is useful in writing some generic drivers to
handle clock part.
Note:
This patch series is tested on MX6Q SDB cpufreq driver with a minor change
to switch to use clk_bulk_get_all.
But patch 4 only test compiling. Hopefully someone could help test
the function.
v1->v2:
* add clk_bulk_{get|put}_all() which only supports DT platform currently
* remove _all variants and the wrapper struct clk_bulk
* make of_clk_bulk_get and of_clk_bulk_get_all private until someone
proves they need it because they don't have a struct device pointer.
Dong Aisheng (4):
clk: bulk: add of_clk_bulk_get()
clk: add new APIs to operate on all available clocks
clk: add managed version of clk_bulk_get_all
video: simplefb: switch to use clk_bulk API to simplify clock
operations
drivers/clk/clk-bulk.c | 89 ++++++++++++++++++++++++++++++++++++++++++
drivers/clk/clk-devres.c | 24 ++++++++++++
drivers/video/fbdev/simplefb.c | 69 ++++++--------------------------
include/linux/clk.h | 65 +++++++++++++++++++++++++++++-
4 files changed, 190 insertions(+), 57 deletions(-)
--
2.7.4
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH V2 1/4] clk: bulk: add of_clk_bulk_get()
2018-03-21 3:19 [PATCH V2 0/4] clk: new APIs to handle all available clocks Dong Aisheng
@ 2018-03-21 3:19 ` Dong Aisheng
2018-03-23 16:53 ` Stephen Boyd
2018-03-21 3:19 ` [PATCH V2 2/4] clk: add new APIs to operate on all available clocks Dong Aisheng
` (2 subsequent siblings)
3 siblings, 1 reply; 13+ messages in thread
From: Dong Aisheng @ 2018-03-21 3:19 UTC (permalink / raw)
To: linux-clk
Cc: linux-kernel, linux-arm-kernel, mturquette, hdegoede,
b.zolnierkie, linux, linux-fbdev, linux-imx, sboyd, Dong Aisheng,
Stephen Boyd, Russell King
'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
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH V2 2/4] clk: add new APIs to operate on all available clocks
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-21 3:19 ` Dong Aisheng
2018-03-23 16:56 ` Stephen Boyd
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
3 siblings, 1 reply; 13+ messages in thread
From: Dong Aisheng @ 2018-03-21 3:19 UTC (permalink / raw)
To: linux-clk
Cc: linux-kernel, linux-arm-kernel, mturquette, hdegoede,
b.zolnierkie, linux, linux-fbdev, linux-imx, sboyd, Dong Aisheng,
Stephen Boyd, Masahiro Yamada
This patch introduces of_clk_bulk_get_all and clk_bulk_x_all APIs
to users who just want to handle all available clocks from device tree
without need to know the detailed clock information likes clock numbers
and names. This is useful in writing some generic drivers to handle clock
part.
Cc: Stephen Boyd <sboyd@codeaurora.org>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
---
v1->v2:
* make of_clk_bulk_get_all private
* add clk_bulk_get/put_all
---
drivers/clk/clk-bulk.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++
include/linux/clk.h | 42 ++++++++++++++++++++++++++++++++++++-
2 files changed, 98 insertions(+), 1 deletion(-)
diff --git a/drivers/clk/clk-bulk.c b/drivers/clk/clk-bulk.c
index 4b357b2..3293c6b 100644
--- a/drivers/clk/clk-bulk.c
+++ b/drivers/clk/clk-bulk.c
@@ -17,9 +17,11 @@
*/
#include <linux/clk.h>
+#include <linux/clk-provider.h>
#include <linux/device.h>
#include <linux/export.h>
#include <linux/of.h>
+#include <linux/slab.h>
#if defined(CONFIG_OF) && defined(CONFIG_COMMON_CLK)
static int __must_check of_clk_bulk_get(struct device_node *np, int num_clks,
@@ -50,6 +52,38 @@ static int __must_check of_clk_bulk_get(struct device_node *np, int num_clks,
return ret;
}
EXPORT_SYMBOL(of_clk_bulk_get);
+
+static int __must_check of_clk_bulk_get_all(struct device_node *np,
+ struct clk_bulk_data **clks)
+{
+ struct clk_bulk_data *clk_bulk;
+ int num_clks;
+ int ret;
+
+ num_clks = of_clk_get_parent_count(np);
+ if (!num_clks)
+ return 0;
+
+ clk_bulk = kcalloc(num_clks, sizeof(*clk_bulk), GFP_KERNEL);
+ if (!clk_bulk)
+ return -ENOMEM;
+
+ ret = of_clk_bulk_get(np, num_clks, clk_bulk);
+ if (ret) {
+ kfree(clk_bulk);
+ return ret;
+ }
+
+ *clks = clk_bulk;
+
+ return num_clks;
+}
+#else
+static int __must_check of_clk_bulk_get_all(struct device_node *np,
+ struct clk_bulk_data **clks)
+{
+ return -ENOENT;
+}
#endif
void clk_bulk_put(int num_clks, struct clk_bulk_data *clks)
@@ -90,6 +124,29 @@ int __must_check clk_bulk_get(struct device *dev, int num_clks,
}
EXPORT_SYMBOL(clk_bulk_get);
+void clk_bulk_put_all(int num_clks, struct clk_bulk_data *clks)
+{
+ if (IS_ERR_OR_NULL(clks))
+ return;
+
+ clk_bulk_put(num_clks, clks);
+
+ kfree(clks);
+}
+EXPORT_SYMBOL(clk_bulk_put_all);
+
+int __must_check clk_bulk_get_all(struct device *dev,
+ struct clk_bulk_data **clks)
+{
+ struct device_node *np = dev_of_node(dev);
+
+ if (!np)
+ return 0;
+
+ return of_clk_bulk_get_all(np, clks);
+}
+EXPORT_SYMBOL(clk_bulk_get_all);
+
#ifdef CONFIG_HAVE_CLK_PREPARE
/**
diff --git a/include/linux/clk.h b/include/linux/clk.h
index 0dbd088..a76fdff 100644
--- a/include/linux/clk.h
+++ b/include/linux/clk.h
@@ -279,7 +279,26 @@ struct clk *clk_get(struct device *dev, const char *id);
*/
int __must_check clk_bulk_get(struct device *dev, int num_clks,
struct clk_bulk_data *clks);
-
+/**
+ * clk_bulk_get_all - lookup and obtain all available references to clock
+ * producer.
+ * @dev: device for clock "consumer"
+ * @clks: pointer to the clk_bulk_data table of consumer
+ *
+ * This helper function allows drivers to get all clk consumers in one
+ * operation. If any of the clk cannot be acquired then any clks
+ * that were obtained will be freed before returning to the caller.
+ *
+ * Returns a positive value for the number of clocks obtained while the
+ * clock references are stored in the clk_bulk_data table in @clks field.
+ * Returns 0 if there're none and a negative value if something failed.
+ *
+ * Drivers must assume that the clock source is not enabled.
+ *
+ * clk_bulk_get should not be called from within interrupt context.
+ */
+int __must_check clk_bulk_get_all(struct device *dev,
+ struct clk_bulk_data **clks);
/**
* devm_clk_bulk_get - managed get multiple clk consumers
* @dev: device for clock "consumer"
@@ -455,6 +474,19 @@ void clk_put(struct clk *clk);
void clk_bulk_put(int num_clks, struct clk_bulk_data *clks);
/**
+ * clk_bulk_put_all - "free" all the clock source
+ * @num_clks: the number of clk_bulk_data
+ * @clks: the clk_bulk_data table of consumer
+ *
+ * Note: drivers must ensure that all clk_bulk_enable calls made on this
+ * clock source are balanced by clk_bulk_disable calls prior to calling
+ * this function.
+ *
+ * clk_bulk_put_all should not be called from within interrupt context.
+ */
+void clk_bulk_put_all(int num_clks, struct clk_bulk_data *clks);
+
+/**
* devm_clk_put - "free" a managed clock source
* @dev: device used to acquire the clock
* @clk: clock source acquired with devm_clk_get()
@@ -609,6 +641,12 @@ static inline int __must_check clk_bulk_get(struct device *dev, int num_clks,
return 0;
}
+static inline int __must_check clk_bulk_get_all(struct device *dev,
+ struct clk_bulk_data **clks)
+{
+ return 0;
+}
+
static inline struct clk *devm_clk_get(struct device *dev, const char *id)
{
return NULL;
@@ -630,6 +668,8 @@ static inline void clk_put(struct clk *clk) {}
static inline void clk_bulk_put(int num_clks, struct clk_bulk_data *clks) {}
+static inline void clk_bulk_put_all(int num_clks, struct clk_bulk_data *clks) {}
+
static inline void devm_clk_put(struct device *dev, struct clk *clk) {}
--
2.7.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH V2 3/4] clk: add managed version of clk_bulk_get_all
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-21 3:19 ` [PATCH V2 2/4] clk: add new APIs to operate on all available clocks Dong Aisheng
@ 2018-03-21 3:19 ` Dong Aisheng
2018-03-23 6:49 ` kbuild test robot
2018-03-21 3:19 ` [PATCH V2 4/4] video: simplefb: switch to use clk_bulk API to simplify clock operations Dong Aisheng
3 siblings, 1 reply; 13+ messages in thread
From: Dong Aisheng @ 2018-03-21 3:19 UTC (permalink / raw)
To: linux-clk
Cc: linux-kernel, linux-arm-kernel, mturquette, hdegoede,
b.zolnierkie, linux, linux-fbdev, linux-imx, sboyd, Dong Aisheng,
Stephen Boyd
This patch introduces the managed version of clk_bulk_get_all.
Cc: Michael Turquette <mturquette@baylibre.com>
Cc: Stephen Boyd <sboyd@codeaurora.org>
Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
---
v1->v2:
* new patch
---
drivers/clk/clk-devres.c | 24 ++++++++++++++++++++++++
include/linux/clk.h | 23 +++++++++++++++++++++++
2 files changed, 47 insertions(+)
diff --git a/drivers/clk/clk-devres.c b/drivers/clk/clk-devres.c
index d854e26..6d3ca5e 100644
--- a/drivers/clk/clk-devres.c
+++ b/drivers/clk/clk-devres.c
@@ -70,6 +70,30 @@ int __must_check devm_clk_bulk_get(struct device *dev, int num_clks,
}
EXPORT_SYMBOL_GPL(devm_clk_bulk_get);
+int __must_check devm_clk_bulk_get_all(struct device *dev,
+ struct clk_bulk_data **clks)
+{
+ struct clk_bulk_devres *devres;
+ int ret;
+
+ devres = devres_alloc(devm_clk_bulk_release,
+ sizeof(*devres), GFP_KERNEL);
+ if (!devres)
+ return -ENOMEM;
+
+ ret = clk_bulk_get_all(dev, clks);
+ if (ret > 0) {
+ devres->clks = *clks;
+ devres->num_clks = ret;
+ devres_add(dev, devres);
+ } else {
+ devres_free(devres);
+ }
+
+ return ret;
+}
+EXPORT_SYMBOL_GPL(devm_clk_bulk_get_all);
+
static int devm_clk_match(struct device *dev, void *res, void *data)
{
struct clk **c = res;
diff --git a/include/linux/clk.h b/include/linux/clk.h
index a76fdff..fe48e01 100644
--- a/include/linux/clk.h
+++ b/include/linux/clk.h
@@ -313,6 +313,22 @@ int __must_check clk_bulk_get_all(struct device *dev,
*/
int __must_check devm_clk_bulk_get(struct device *dev, int num_clks,
struct clk_bulk_data *clks);
+/**
+ * devm_clk_bulk_get_all - managed get multiple clk consumers
+ * @dev: device for clock "consumer"
+ * @clks: pointer to the clk_bulk_data table of consumer
+ *
+ * Returns a positive value for the number of clocks obtained while the
+ * clock references are stored in the clk_bulk_data table in @clks field.
+ * Returns 0 if there're none and a negative value if something failed.
+ *
+ * This helper function allows drivers to get several clk
+ * consumers in one operation with management, the clks will
+ * automatically be freed when the device is unbound.
+ */
+
+int __must_check devm_clk_bulk_get_all(struct device *dev,
+ struct clk_bulk_data **clks);
/**
* devm_clk_get - lookup and obtain a managed reference to a clock producer.
@@ -658,6 +674,13 @@ static inline int __must_check devm_clk_bulk_get(struct device *dev, int num_clk
return 0;
}
+static inline int __must_check devm_clk_bulk_get_all(struct device *dev,
+ struct clk_bulk_data **clks);
+{
+
+ return 0;
+}
+
static inline struct clk *devm_get_clk_from_child(struct device *dev,
struct device_node *np, const char *con_id)
{
--
2.7.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH V2 4/4] video: simplefb: switch to use clk_bulk API to simplify clock operations
2018-03-21 3:19 [PATCH V2 0/4] clk: new APIs to handle all available clocks Dong Aisheng
` (2 preceding siblings ...)
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 ` Dong Aisheng
2018-03-23 5:28 ` kbuild test robot
3 siblings, 1 reply; 13+ messages in thread
From: Dong Aisheng @ 2018-03-21 3:19 UTC (permalink / raw)
To: linux-clk
Cc: linux-kernel, linux-arm-kernel, mturquette, hdegoede,
b.zolnierkie, linux, linux-fbdev, linux-imx, sboyd, Dong Aisheng,
Masahiro Yamada, Stephen Boyd
Switching to use clk_bulk API to simplify clock operations.
Cc: Hans de Goede <hdegoede@redhat.com>
Cc: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Cc: linux-fbdev@vger.kernel.org
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: Stephen Boyd <sboyd@codeaurora.org>
Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
---
v1->v2:
* switch to clk_bulk_get_all from of_clk_bulk_get_all
---
drivers/video/fbdev/simplefb.c | 69 ++++++++----------------------------------
1 file changed, 13 insertions(+), 56 deletions(-)
diff --git a/drivers/video/fbdev/simplefb.c b/drivers/video/fbdev/simplefb.c
index a3c44ec..3c8124e 100644
--- a/drivers/video/fbdev/simplefb.c
+++ b/drivers/video/fbdev/simplefb.c
@@ -182,7 +182,7 @@ struct simplefb_par {
#if defined CONFIG_OF && defined CONFIG_COMMON_CLK
bool clks_enabled;
unsigned int clk_count;
- struct clk **clks;
+ struct clk_bulk_data *clks;
#endif
#if defined CONFIG_OF && defined CONFIG_REGULATOR
bool regulators_enabled;
@@ -214,37 +214,13 @@ static int simplefb_clocks_get(struct simplefb_par *par,
struct platform_device *pdev)
{
struct device_node *np = pdev->dev.of_node;
- struct clk *clock;
- int i;
if (dev_get_platdata(&pdev->dev) || !np)
return 0;
- par->clk_count = of_clk_get_parent_count(np);
- if (!par->clk_count)
- return 0;
-
- par->clks = kcalloc(par->clk_count, sizeof(struct clk *), GFP_KERNEL);
- if (!par->clks)
- return -ENOMEM;
-
- for (i = 0; i < par->clk_count; i++) {
- clock = of_clk_get(np, i);
- if (IS_ERR(clock)) {
- if (PTR_ERR(clock) == -EPROBE_DEFER) {
- while (--i >= 0) {
- if (par->clks[i])
- clk_put(par->clks[i]);
- }
- kfree(par->clks);
- return -EPROBE_DEFER;
- }
- dev_err(&pdev->dev, "%s: clock %d not found: %ld\n",
- __func__, i, PTR_ERR(clock));
- continue;
- }
- par->clks[i] = clock;
- }
+ par->clk_count = clk_bulk_get_all(&pdev->dev, &par->clks);
+ if ((par->clk_count < 0) && (par->clk_count == -EPROBE_DEFER))
+ return -EPROBE_DEFER;
return 0;
}
@@ -252,45 +228,26 @@ static int simplefb_clocks_get(struct simplefb_par *par,
static void simplefb_clocks_enable(struct simplefb_par *par,
struct platform_device *pdev)
{
- int i, ret;
+ int ret;
+
+ ret = clk_bulk_prepare_enable(par->clk_count, par->clks);
+ if (ret)
+ dev_warn(&pdev->dev, "failed to enable clocks\n");
- for (i = 0; i < par->clk_count; i++) {
- if (par->clks[i]) {
- ret = clk_prepare_enable(par->clks[i]);
- if (ret) {
- dev_err(&pdev->dev,
- "%s: failed to enable clock %d: %d\n",
- __func__, i, ret);
- clk_put(par->clks[i]);
- par->clks[i] = NULL;
- }
- }
- }
par->clks_enabled = true;
}
static void simplefb_clocks_destroy(struct simplefb_par *par)
{
- int i;
-
- if (!par->clks)
- return;
+ if (par->clks_enabled)
+ clk_bulk_disable_unprepare(par->clk_count, par->clks);
- for (i = 0; i < par->clk_count; i++) {
- if (par->clks[i]) {
- if (par->clks_enabled)
- clk_disable_unprepare(par->clks[i]);
- clk_put(par->clks[i]);
- }
- }
-
- kfree(par->clks);
+ clk_bulk_put_all(par->clk_count, par->clks);
}
#else
static int simplefb_clocks_get(struct simplefb_par *par,
struct platform_device *pdev) { return 0; }
-static void simplefb_clocks_enable(struct simplefb_par *par,
- struct platform_device *pdev) { }
+static int simplefb_clocks_enable(struct simplefb_par *par) { }
static void simplefb_clocks_destroy(struct simplefb_par *par) { }
#endif
--
2.7.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH V2 4/4] video: simplefb: switch to use clk_bulk API to simplify clock operations
2018-03-21 3:19 ` [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
0 siblings, 0 replies; 13+ messages in thread
From: kbuild test robot @ 2018-03-23 5:28 UTC (permalink / raw)
To: Dong Aisheng
Cc: kbuild-all, linux-clk, linux-kernel, linux-arm-kernel,
mturquette, hdegoede, b.zolnierkie, linux, linux-fbdev,
linux-imx, sboyd, Dong Aisheng, Masahiro Yamada, Stephen Boyd
[-- Attachment #1: Type: text/plain, Size: 25320 bytes --]
Hi Dong,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on clk/clk-next]
[also build test ERROR on v4.16-rc6 next-20180322]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Dong-Aisheng/clk-new-APIs-to-handle-all-available-clocks/20180323-122451
base: https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git clk-next
config: i386-randconfig-x007-201811 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
reproduce:
# save the attached .config to linux build tree
make ARCH=i386
All error/warnings (new ones prefixed by >>):
drivers/video/fbdev/simplefb.c: In function 'simplefb_clocks_enable':
>> drivers/video/fbdev/simplefb.c:250:42: warning: no return statement in function returning non-void [-Wreturn-type]
static int simplefb_clocks_enable(struct simplefb_par *par) { }
^~~~~~~~~~~~
drivers/video/fbdev/simplefb.c: In function 'simplefb_probe':
>> drivers/video/fbdev/simplefb.c:442:2: error: too many arguments to function 'simplefb_clocks_enable'
simplefb_clocks_enable(par, pdev);
^~~~~~~~~~~~~~~~~~~~~~
drivers/video/fbdev/simplefb.c:250:12: note: declared here
static int simplefb_clocks_enable(struct simplefb_par *par) { }
^~~~~~~~~~~~~~~~~~~~~~
vim +/simplefb_clocks_enable +442 drivers/video/fbdev/simplefb.c
fc219bfd drivers/video/fbdev/simplefb.c Luc Verhaegen 2014-11-14 239
fc219bfd drivers/video/fbdev/simplefb.c Luc Verhaegen 2014-11-14 240 static void simplefb_clocks_destroy(struct simplefb_par *par)
fc219bfd drivers/video/fbdev/simplefb.c Luc Verhaegen 2014-11-14 241 {
a3accfd7 drivers/video/fbdev/simplefb.c Hans de Goede 2017-01-11 242 if (par->clks_enabled)
1904158b drivers/video/fbdev/simplefb.c Dong Aisheng 2018-03-21 243 clk_bulk_disable_unprepare(par->clk_count, par->clks);
fc219bfd drivers/video/fbdev/simplefb.c Luc Verhaegen 2014-11-14 244
1904158b drivers/video/fbdev/simplefb.c Dong Aisheng 2018-03-21 245 clk_bulk_put_all(par->clk_count, par->clks);
fc219bfd drivers/video/fbdev/simplefb.c Luc Verhaegen 2014-11-14 246 }
fc219bfd drivers/video/fbdev/simplefb.c Luc Verhaegen 2014-11-14 247 #else
a3accfd7 drivers/video/fbdev/simplefb.c Hans de Goede 2017-01-11 248 static int simplefb_clocks_get(struct simplefb_par *par,
fc219bfd drivers/video/fbdev/simplefb.c Luc Verhaegen 2014-11-14 249 struct platform_device *pdev) { return 0; }
1904158b drivers/video/fbdev/simplefb.c Dong Aisheng 2018-03-21 @250 static int simplefb_clocks_enable(struct simplefb_par *par) { }
fc219bfd drivers/video/fbdev/simplefb.c Luc Verhaegen 2014-11-14 251 static void simplefb_clocks_destroy(struct simplefb_par *par) { }
fc219bfd drivers/video/fbdev/simplefb.c Luc Verhaegen 2014-11-14 252 #endif
fc219bfd drivers/video/fbdev/simplefb.c Luc Verhaegen 2014-11-14 253
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 254 #if defined CONFIG_OF && defined CONFIG_REGULATOR
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 255
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 256 #define SUPPLY_SUFFIX "-supply"
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 257
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 258 /*
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 259 * Regulator handling code.
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 260 *
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 261 * Here we handle the num-supplies and vin*-supply properties of our
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 262 * "simple-framebuffer" dt node. This is necessary so that we can make sure
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 263 * that any regulators needed by the display hardware that the bootloader
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 264 * set up for us (and for which it provided a simplefb dt node), stay up,
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 265 * for the life of the simplefb driver.
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 266 *
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 267 * When the driver unloads, we cleanly disable, and then release the
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 268 * regulators.
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 269 *
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 270 * We only complain about errors here, no action is taken as the most likely
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 271 * error can only happen due to a mismatch between the bootloader which set
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 272 * up simplefb, and the regulator definitions in the device tree. Chances are
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 273 * that there are no adverse effects, and if there are, a clean teardown of
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 274 * the fb probe will not help us much either. So just complain and carry on,
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 275 * and hope that the user actually gets a working fb at the end of things.
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 276 */
a3accfd7 drivers/video/fbdev/simplefb.c Hans de Goede 2017-01-11 277 static int simplefb_regulators_get(struct simplefb_par *par,
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 278 struct platform_device *pdev)
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 279 {
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 280 struct device_node *np = pdev->dev.of_node;
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 281 struct property *prop;
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 282 struct regulator *regulator;
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 283 const char *p;
a3accfd7 drivers/video/fbdev/simplefb.c Hans de Goede 2017-01-11 284 int count = 0, i = 0;
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 285
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 286 if (dev_get_platdata(&pdev->dev) || !np)
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 287 return 0;
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 288
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 289 /* Count the number of regulator supplies */
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 290 for_each_property_of_node(np, prop) {
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 291 p = strstr(prop->name, SUPPLY_SUFFIX);
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 292 if (p && p != prop->name)
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 293 count++;
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 294 }
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 295
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 296 if (!count)
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 297 return 0;
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 298
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 299 par->regulators = devm_kcalloc(&pdev->dev, count,
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 300 sizeof(struct regulator *), GFP_KERNEL);
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 301 if (!par->regulators)
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 302 return -ENOMEM;
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 303
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 304 /* Get all the regulators */
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 305 for_each_property_of_node(np, prop) {
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 306 char name[32]; /* 32 is max size of property name */
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 307
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 308 p = strstr(prop->name, SUPPLY_SUFFIX);
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 309 if (!p || p == prop->name)
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 310 continue;
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 311
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 312 strlcpy(name, prop->name,
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 313 strlen(prop->name) - strlen(SUPPLY_SUFFIX) + 1);
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 314 regulator = devm_regulator_get_optional(&pdev->dev, name);
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 315 if (IS_ERR(regulator)) {
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 316 if (PTR_ERR(regulator) == -EPROBE_DEFER)
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 317 return -EPROBE_DEFER;
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 318 dev_err(&pdev->dev, "regulator %s not found: %ld\n",
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 319 name, PTR_ERR(regulator));
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 320 continue;
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 321 }
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 322 par->regulators[i++] = regulator;
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 323 }
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 324 par->regulator_count = i;
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 325
a3accfd7 drivers/video/fbdev/simplefb.c Hans de Goede 2017-01-11 326 return 0;
a3accfd7 drivers/video/fbdev/simplefb.c Hans de Goede 2017-01-11 327 }
a3accfd7 drivers/video/fbdev/simplefb.c Hans de Goede 2017-01-11 328
a3accfd7 drivers/video/fbdev/simplefb.c Hans de Goede 2017-01-11 329 static void simplefb_regulators_enable(struct simplefb_par *par,
a3accfd7 drivers/video/fbdev/simplefb.c Hans de Goede 2017-01-11 330 struct platform_device *pdev)
a3accfd7 drivers/video/fbdev/simplefb.c Hans de Goede 2017-01-11 331 {
a3accfd7 drivers/video/fbdev/simplefb.c Hans de Goede 2017-01-11 332 int i, ret;
a3accfd7 drivers/video/fbdev/simplefb.c Hans de Goede 2017-01-11 333
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 334 /* Enable all the regulators */
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 335 for (i = 0; i < par->regulator_count; i++) {
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 336 ret = regulator_enable(par->regulators[i]);
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 337 if (ret) {
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 338 dev_err(&pdev->dev,
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 339 "failed to enable regulator %d: %d\n",
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 340 i, ret);
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 341 devm_regulator_put(par->regulators[i]);
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 342 par->regulators[i] = NULL;
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 343 }
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 344 }
a3accfd7 drivers/video/fbdev/simplefb.c Hans de Goede 2017-01-11 345 par->regulators_enabled = true;
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 346 }
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 347
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 348 static void simplefb_regulators_destroy(struct simplefb_par *par)
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 349 {
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 350 int i;
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 351
a3accfd7 drivers/video/fbdev/simplefb.c Hans de Goede 2017-01-11 352 if (!par->regulators || !par->regulators_enabled)
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 353 return;
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 354
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 355 for (i = 0; i < par->regulator_count; i++)
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 356 if (par->regulators[i])
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 357 regulator_disable(par->regulators[i]);
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 358 }
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 359 #else
a3accfd7 drivers/video/fbdev/simplefb.c Hans de Goede 2017-01-11 360 static int simplefb_regulators_get(struct simplefb_par *par,
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 361 struct platform_device *pdev) { return 0; }
a3accfd7 drivers/video/fbdev/simplefb.c Hans de Goede 2017-01-11 362 static void simplefb_regulators_enable(struct simplefb_par *par,
a3accfd7 drivers/video/fbdev/simplefb.c Hans de Goede 2017-01-11 363 struct platform_device *pdev) { }
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 364 static void simplefb_regulators_destroy(struct simplefb_par *par) { }
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 365 #endif
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 366
26549c8d drivers/video/simplefb.c Stephen Warren 2013-05-24 367 static int simplefb_probe(struct platform_device *pdev)
26549c8d drivers/video/simplefb.c Stephen Warren 2013-05-24 368 {
26549c8d drivers/video/simplefb.c Stephen Warren 2013-05-24 369 int ret;
26549c8d drivers/video/simplefb.c Stephen Warren 2013-05-24 370 struct simplefb_params params;
26549c8d drivers/video/simplefb.c Stephen Warren 2013-05-24 371 struct fb_info *info;
1270be4a drivers/video/fbdev/simplefb.c Luc Verhaegen 2014-11-14 372 struct simplefb_par *par;
26549c8d drivers/video/simplefb.c Stephen Warren 2013-05-24 373 struct resource *mem;
26549c8d drivers/video/simplefb.c Stephen Warren 2013-05-24 374
26549c8d drivers/video/simplefb.c Stephen Warren 2013-05-24 375 if (fb_get_options("simplefb", NULL))
26549c8d drivers/video/simplefb.c Stephen Warren 2013-05-24 376 return -ENODEV;
26549c8d drivers/video/simplefb.c Stephen Warren 2013-05-24 377
5ef76da6 drivers/video/simplefb.c David Herrmann 2013-08-02 378 ret = -ENODEV;
129f1be4 drivers/video/simplefb.c Jingoo Han 2013-09-17 379 if (dev_get_platdata(&pdev->dev))
5ef76da6 drivers/video/simplefb.c David Herrmann 2013-08-02 380 ret = simplefb_parse_pd(pdev, ¶ms);
5ef76da6 drivers/video/simplefb.c David Herrmann 2013-08-02 381 else if (pdev->dev.of_node)
26549c8d drivers/video/simplefb.c Stephen Warren 2013-05-24 382 ret = simplefb_parse_dt(pdev, ¶ms);
5ef76da6 drivers/video/simplefb.c David Herrmann 2013-08-02 383
26549c8d drivers/video/simplefb.c Stephen Warren 2013-05-24 384 if (ret)
26549c8d drivers/video/simplefb.c Stephen Warren 2013-05-24 385 return ret;
26549c8d drivers/video/simplefb.c Stephen Warren 2013-05-24 386
26549c8d drivers/video/simplefb.c Stephen Warren 2013-05-24 387 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
26549c8d drivers/video/simplefb.c Stephen Warren 2013-05-24 388 if (!mem) {
26549c8d drivers/video/simplefb.c Stephen Warren 2013-05-24 389 dev_err(&pdev->dev, "No memory resource\n");
26549c8d drivers/video/simplefb.c Stephen Warren 2013-05-24 390 return -EINVAL;
26549c8d drivers/video/simplefb.c Stephen Warren 2013-05-24 391 }
26549c8d drivers/video/simplefb.c Stephen Warren 2013-05-24 392
1270be4a drivers/video/fbdev/simplefb.c Luc Verhaegen 2014-11-14 393 info = framebuffer_alloc(sizeof(struct simplefb_par), &pdev->dev);
26549c8d drivers/video/simplefb.c Stephen Warren 2013-05-24 394 if (!info)
26549c8d drivers/video/simplefb.c Stephen Warren 2013-05-24 395 return -ENOMEM;
26549c8d drivers/video/simplefb.c Stephen Warren 2013-05-24 396 platform_set_drvdata(pdev, info);
26549c8d drivers/video/simplefb.c Stephen Warren 2013-05-24 397
1270be4a drivers/video/fbdev/simplefb.c Luc Verhaegen 2014-11-14 398 par = info->par;
1270be4a drivers/video/fbdev/simplefb.c Luc Verhaegen 2014-11-14 399
26549c8d drivers/video/simplefb.c Stephen Warren 2013-05-24 400 info->fix = simplefb_fix;
26549c8d drivers/video/simplefb.c Stephen Warren 2013-05-24 401 info->fix.smem_start = mem->start;
26549c8d drivers/video/simplefb.c Stephen Warren 2013-05-24 402 info->fix.smem_len = resource_size(mem);
26549c8d drivers/video/simplefb.c Stephen Warren 2013-05-24 403 info->fix.line_length = params.stride;
26549c8d drivers/video/simplefb.c Stephen Warren 2013-05-24 404
26549c8d drivers/video/simplefb.c Stephen Warren 2013-05-24 405 info->var = simplefb_var;
26549c8d drivers/video/simplefb.c Stephen Warren 2013-05-24 406 info->var.xres = params.width;
26549c8d drivers/video/simplefb.c Stephen Warren 2013-05-24 407 info->var.yres = params.height;
26549c8d drivers/video/simplefb.c Stephen Warren 2013-05-24 408 info->var.xres_virtual = params.width;
26549c8d drivers/video/simplefb.c Stephen Warren 2013-05-24 409 info->var.yres_virtual = params.height;
26549c8d drivers/video/simplefb.c Stephen Warren 2013-05-24 410 info->var.bits_per_pixel = params.format->bits_per_pixel;
26549c8d drivers/video/simplefb.c Stephen Warren 2013-05-24 411 info->var.red = params.format->red;
26549c8d drivers/video/simplefb.c Stephen Warren 2013-05-24 412 info->var.green = params.format->green;
26549c8d drivers/video/simplefb.c Stephen Warren 2013-05-24 413 info->var.blue = params.format->blue;
26549c8d drivers/video/simplefb.c Stephen Warren 2013-05-24 414 info->var.transp = params.format->transp;
26549c8d drivers/video/simplefb.c Stephen Warren 2013-05-24 415
df0960ab drivers/video/simplefb.c David Herrmann 2013-08-02 416 info->apertures = alloc_apertures(1);
df0960ab drivers/video/simplefb.c David Herrmann 2013-08-02 417 if (!info->apertures) {
bf2fda15 drivers/video/fbdev/simplefb.c Luc Verhaegen 2014-11-14 418 ret = -ENOMEM;
bf2fda15 drivers/video/fbdev/simplefb.c Luc Verhaegen 2014-11-14 419 goto error_fb_release;
df0960ab drivers/video/simplefb.c David Herrmann 2013-08-02 420 }
df0960ab drivers/video/simplefb.c David Herrmann 2013-08-02 421 info->apertures->ranges[0].base = info->fix.smem_start;
df0960ab drivers/video/simplefb.c David Herrmann 2013-08-02 422 info->apertures->ranges[0].size = info->fix.smem_len;
df0960ab drivers/video/simplefb.c David Herrmann 2013-08-02 423
26549c8d drivers/video/simplefb.c Stephen Warren 2013-05-24 424 info->fbops = &simplefb_ops;
df0960ab drivers/video/simplefb.c David Herrmann 2013-08-02 425 info->flags = FBINFO_DEFAULT | FBINFO_MISC_FIRMWARE;
9e210be6 drivers/video/simplefb.c David Herrmann 2013-10-02 426 info->screen_base = ioremap_wc(info->fix.smem_start,
26549c8d drivers/video/simplefb.c Stephen Warren 2013-05-24 427 info->fix.smem_len);
26549c8d drivers/video/simplefb.c Stephen Warren 2013-05-24 428 if (!info->screen_base) {
bf2fda15 drivers/video/fbdev/simplefb.c Luc Verhaegen 2014-11-14 429 ret = -ENOMEM;
bf2fda15 drivers/video/fbdev/simplefb.c Luc Verhaegen 2014-11-14 430 goto error_fb_release;
26549c8d drivers/video/simplefb.c Stephen Warren 2013-05-24 431 }
1270be4a drivers/video/fbdev/simplefb.c Luc Verhaegen 2014-11-14 432 info->pseudo_palette = par->palette;
26549c8d drivers/video/simplefb.c Stephen Warren 2013-05-24 433
a3accfd7 drivers/video/fbdev/simplefb.c Hans de Goede 2017-01-11 434 ret = simplefb_clocks_get(par, pdev);
fc219bfd drivers/video/fbdev/simplefb.c Luc Verhaegen 2014-11-14 435 if (ret < 0)
fc219bfd drivers/video/fbdev/simplefb.c Luc Verhaegen 2014-11-14 436 goto error_unmap;
fc219bfd drivers/video/fbdev/simplefb.c Luc Verhaegen 2014-11-14 437
a3accfd7 drivers/video/fbdev/simplefb.c Hans de Goede 2017-01-11 438 ret = simplefb_regulators_get(par, pdev);
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 439 if (ret < 0)
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 440 goto error_clocks;
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 441
a3accfd7 drivers/video/fbdev/simplefb.c Hans de Goede 2017-01-11 @442 simplefb_clocks_enable(par, pdev);
a3accfd7 drivers/video/fbdev/simplefb.c Hans de Goede 2017-01-11 443 simplefb_regulators_enable(par, pdev);
a3accfd7 drivers/video/fbdev/simplefb.c Hans de Goede 2017-01-11 444
9f192a92 drivers/video/simplefb.c Tom Gundersen 2013-09-07 445 dev_info(&pdev->dev, "framebuffer at 0x%lx, 0x%x bytes, mapped to 0x%p\n",
9f192a92 drivers/video/simplefb.c Tom Gundersen 2013-09-07 446 info->fix.smem_start, info->fix.smem_len,
9f192a92 drivers/video/simplefb.c Tom Gundersen 2013-09-07 447 info->screen_base);
9f192a92 drivers/video/simplefb.c Tom Gundersen 2013-09-07 448 dev_info(&pdev->dev, "format=%s, mode=%dx%dx%d, linelength=%d\n",
9f192a92 drivers/video/simplefb.c Tom Gundersen 2013-09-07 449 params.format->name,
9f192a92 drivers/video/simplefb.c Tom Gundersen 2013-09-07 450 info->var.xres, info->var.yres,
9f192a92 drivers/video/simplefb.c Tom Gundersen 2013-09-07 451 info->var.bits_per_pixel, info->fix.line_length);
9f192a92 drivers/video/simplefb.c Tom Gundersen 2013-09-07 452
26549c8d drivers/video/simplefb.c Stephen Warren 2013-05-24 453 ret = register_framebuffer(info);
26549c8d drivers/video/simplefb.c Stephen Warren 2013-05-24 454 if (ret < 0) {
26549c8d drivers/video/simplefb.c Stephen Warren 2013-05-24 455 dev_err(&pdev->dev, "Unable to register simplefb: %d\n", ret);
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 456 goto error_regulators;
26549c8d drivers/video/simplefb.c Stephen Warren 2013-05-24 457 }
26549c8d drivers/video/simplefb.c Stephen Warren 2013-05-24 458
26549c8d drivers/video/simplefb.c Stephen Warren 2013-05-24 459 dev_info(&pdev->dev, "fb%d: simplefb registered!\n", info->node);
26549c8d drivers/video/simplefb.c Stephen Warren 2013-05-24 460
26549c8d drivers/video/simplefb.c Stephen Warren 2013-05-24 461 return 0;
bf2fda15 drivers/video/fbdev/simplefb.c Luc Verhaegen 2014-11-14 462
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 463 error_regulators:
814740e7 drivers/video/fbdev/simplefb.c Chen-Yu Tsai 2015-11-17 464 simplefb_regulators_destroy(par);
fc219bfd drivers/video/fbdev/simplefb.c Luc Verhaegen 2014-11-14 465 error_clocks:
fc219bfd drivers/video/fbdev/simplefb.c Luc Verhaegen 2014-11-14 466 simplefb_clocks_destroy(par);
bf2fda15 drivers/video/fbdev/simplefb.c Luc Verhaegen 2014-11-14 467 error_unmap:
bf2fda15 drivers/video/fbdev/simplefb.c Luc Verhaegen 2014-11-14 468 iounmap(info->screen_base);
bf2fda15 drivers/video/fbdev/simplefb.c Luc Verhaegen 2014-11-14 469 error_fb_release:
bf2fda15 drivers/video/fbdev/simplefb.c Luc Verhaegen 2014-11-14 470 framebuffer_release(info);
bf2fda15 drivers/video/fbdev/simplefb.c Luc Verhaegen 2014-11-14 471 return ret;
26549c8d drivers/video/simplefb.c Stephen Warren 2013-05-24 472 }
26549c8d drivers/video/simplefb.c Stephen Warren 2013-05-24 473
:::::: The code at line 442 was first introduced by commit
:::::: a3accfd70e166af4956a686ffcdf414702c0a13e video: fbdev: simplefb: Separate clk / regulator get and enable steps
:::::: TO: Hans de Goede <hdegoede@redhat.com>
:::::: CC: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 32787 bytes --]
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH V2 3/4] clk: add managed version of clk_bulk_get_all
2018-03-21 3:19 ` [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
0 siblings, 1 reply; 13+ messages in thread
From: kbuild test robot @ 2018-03-23 6:49 UTC (permalink / raw)
To: Dong Aisheng
Cc: kbuild-all, linux-clk, linux-kernel, linux-arm-kernel,
mturquette, hdegoede, b.zolnierkie, linux, linux-fbdev,
linux-imx, sboyd, Dong Aisheng, Stephen Boyd
[-- Attachment #1: Type: text/plain, Size: 1748 bytes --]
Hi Dong,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on clk/clk-next]
[also build test ERROR on v4.16-rc6 next-20180322]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Dong-Aisheng/clk-new-APIs-to-handle-all-available-clocks/20180323-122451
base: https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git clk-next
config: powerpc-defconfig (attached as .config)
compiler: powerpc64-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=powerpc
All errors (new ones prefixed by >>):
In file included from include/linux/cpufreq.h:14:0,
from arch/powerpc/platforms/cell/cpufreq_spudemand.c:23:
include/linux/clk.h:679:1: error: expected identifier or '(' before '{' token
{
^
>> include/linux/clk.h:677:32: error: 'devm_clk_bulk_get_all' declared 'static' but never defined [-Werror=unused-function]
static inline int __must_check devm_clk_bulk_get_all(struct device *dev,
^~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
vim +677 include/linux/clk.h
676
> 677 static inline int __must_check devm_clk_bulk_get_all(struct device *dev,
678 struct clk_bulk_data **clks);
> 679 {
680
681 return 0;
682 }
683
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 24187 bytes --]
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH V2 1/4] clk: bulk: add of_clk_bulk_get()
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
0 siblings, 1 reply; 13+ messages in thread
From: Stephen Boyd @ 2018-03-23 16:53 UTC (permalink / raw)
To: Dong Aisheng, linux-clk
Cc: linux-kernel, linux-arm-kernel, mturquette, hdegoede,
b.zolnierkie, linux, linux-fbdev, linux-imx, Dong Aisheng,
Stephen Boyd, Russell King
Quoting Dong Aisheng (2018-03-20 20:19:48)
> 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)
Do we need these defines? of_clk_get() is a stub function when these
configs are false.
> +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);
It's static, so don't export it.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH V2 2/4] clk: add new APIs to operate on all available clocks
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
0 siblings, 1 reply; 13+ messages in thread
From: Stephen Boyd @ 2018-03-23 16:56 UTC (permalink / raw)
To: Dong Aisheng, linux-clk
Cc: linux-kernel, linux-arm-kernel, mturquette, hdegoede,
b.zolnierkie, linux, linux-fbdev, linux-imx, Dong Aisheng,
Stephen Boyd, Masahiro Yamada
Quoting Dong Aisheng (2018-03-20 20:19:49)
> @@ -50,6 +52,38 @@ static int __must_check of_clk_bulk_get(struct device_node *np, int num_clks,
> return ret;
> }
> EXPORT_SYMBOL(of_clk_bulk_get);
> +
> +static int __must_check of_clk_bulk_get_all(struct device_node *np,
> + struct clk_bulk_data **clks)
> +{
> + struct clk_bulk_data *clk_bulk;
> + int num_clks;
> + int ret;
> +
> + num_clks = of_clk_get_parent_count(np);
> + if (!num_clks)
> + return 0;
> +
> + clk_bulk = kcalloc(num_clks, sizeof(*clk_bulk), GFP_KERNEL);
Can be kmalloc_array? of_clk_bulk_get() already clears things out
appropriately.
> + if (!clk_bulk)
> + return -ENOMEM;
> +
> + ret = of_clk_bulk_get(np, num_clks, clk_bulk);
> + if (ret) {
> + kfree(clk_bulk);
> + return ret;
> + }
> +
> + *clks = clk_bulk;
> +
> + return num_clks;
> +}
> +#else
> +static int __must_check of_clk_bulk_get_all(struct device_node *np,
> + struct clk_bulk_data **clks)
> +{
> + return -ENOENT;
> +}
> #endif
This else can probably be dropped too.
>
> void clk_bulk_put(int num_clks, struct clk_bulk_data *clks)
> @@ -90,6 +124,29 @@ int __must_check clk_bulk_get(struct device *dev, int num_clks,
> }
> EXPORT_SYMBOL(clk_bulk_get);
>
> +void clk_bulk_put_all(int num_clks, struct clk_bulk_data *clks)
> +{
> + if (IS_ERR_OR_NULL(clks))
> + return;
> +
> + clk_bulk_put(num_clks, clks);
> +
> + kfree(clks);
> +}
> +EXPORT_SYMBOL(clk_bulk_put_all);
> +
> +int __must_check clk_bulk_get_all(struct device *dev,
> + struct clk_bulk_data **clks)
> +{
> + struct device_node *np = dev_of_node(dev);
> +
> + if (!np)
> + return 0;
> +
> + return of_clk_bulk_get_all(np, clks);
> +}
> +EXPORT_SYMBOL(clk_bulk_get_all);
Looks better!
^ permalink raw reply [flat|nested] 13+ messages in thread
* RE: [PATCH V2 1/4] clk: bulk: add of_clk_bulk_get()
2018-03-23 16:53 ` Stephen Boyd
@ 2018-05-25 9:48 ` A.s. Dong
0 siblings, 0 replies; 13+ messages in thread
From: A.s. Dong @ 2018-05-25 9:48 UTC (permalink / raw)
To: Stephen Boyd, linux-clk
Cc: linux-kernel, linux-arm-kernel, mturquette, hdegoede,
b.zolnierkie, linux, linux-fbdev, dl-linux-imx, Stephen Boyd,
Russell King
Hi Stephen,
> -----Original Message-----
> From: Stephen Boyd [mailto:sboyd@kernel.org]
> Sent: Saturday, March 24, 2018 12:53 AM
> To: A.s. Dong <aisheng.dong@nxp.com>; linux-clk@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org; linux-arm-kernel@lists.infradead.org;
> mturquette@baylibre.com; hdegoede@redhat.com;
> b.zolnierkie@samsung.com; linux@armlinux.org.uk; linux-
> fbdev@vger.kernel.org; dl-linux-imx <linux-imx@nxp.com>; A.s. Dong
> <aisheng.dong@nxp.com>; Stephen Boyd <sboyd@codeaurora.org>; Russell
> King <linux@arm.linux.org.uk>
> Subject: Re: [PATCH V2 1/4] clk: bulk: add of_clk_bulk_get()
>
> Quoting Dong Aisheng (2018-03-20 20:19:48)
> > 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)
>
> Do we need these defines? of_clk_get() is a stub function when these
> configs are false.
>
You're right. Will drop it.
> > +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);
>
> It's static, so don't export it.
Got it.
Sorry for such mistake.
Will fix and sent V3.
Regards
Dong Aisheng
^ permalink raw reply [flat|nested] 13+ messages in thread
* RE: [PATCH V2 2/4] clk: add new APIs to operate on all available clocks
2018-03-23 16:56 ` Stephen Boyd
@ 2018-05-25 9:49 ` A.s. Dong
0 siblings, 0 replies; 13+ messages in thread
From: A.s. Dong @ 2018-05-25 9:49 UTC (permalink / raw)
To: Stephen Boyd, linux-clk
Cc: linux-kernel, linux-arm-kernel, mturquette, hdegoede,
b.zolnierkie, linux, linux-fbdev, dl-linux-imx, Stephen Boyd,
Masahiro Yamada
> -----Original Message-----
> From: Stephen Boyd [mailto:sboyd@kernel.org]
> Sent: Saturday, March 24, 2018 12:57 AM
> To: A.s. Dong <aisheng.dong@nxp.com>; linux-clk@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org; linux-arm-kernel@lists.infradead.org;
> mturquette@baylibre.com; hdegoede@redhat.com;
> b.zolnierkie@samsung.com; linux@armlinux.org.uk; linux-
> fbdev@vger.kernel.org; dl-linux-imx <linux-imx@nxp.com>; A.s. Dong
> <aisheng.dong@nxp.com>; Stephen Boyd <sboyd@codeaurora.org>;
> Masahiro Yamada <yamada.masahiro@socionext.com>
> Subject: Re: [PATCH V2 2/4] clk: add new APIs to operate on all available
> clocks
>
> Quoting Dong Aisheng (2018-03-20 20:19:49)
> > @@ -50,6 +52,38 @@ static int __must_check of_clk_bulk_get(struct
> device_node *np, int num_clks,
> > return ret;
> > }
> > EXPORT_SYMBOL(of_clk_bulk_get);
> > +
> > +static int __must_check of_clk_bulk_get_all(struct device_node *np,
> > + struct clk_bulk_data
> > +**clks) {
> > + struct clk_bulk_data *clk_bulk;
> > + int num_clks;
> > + int ret;
> > +
> > + num_clks = of_clk_get_parent_count(np);
> > + if (!num_clks)
> > + return 0;
> > +
> > + clk_bulk = kcalloc(num_clks, sizeof(*clk_bulk), GFP_KERNEL);
>
> Can be kmalloc_array? of_clk_bulk_get() already clears things out
> appropriately.
Yes, indeed. Will use kmalloc_array instead.
>
> > + if (!clk_bulk)
> > + return -ENOMEM;
> > +
> > + ret = of_clk_bulk_get(np, num_clks, clk_bulk);
> > + if (ret) {
> > + kfree(clk_bulk);
> > + return ret;
> > + }
> > +
> > + *clks = clk_bulk;
> > +
> > + return num_clks;
> > +}
> > +#else
> > +static int __must_check of_clk_bulk_get_all(struct device_node *np,
> > + struct clk_bulk_data
> > +**clks) {
> > + return -ENOENT;
> > +}
> > #endif
>
> This else can probably be dropped too.
>
Right.
> >
> > void clk_bulk_put(int num_clks, struct clk_bulk_data *clks) @@ -90,6
> > +124,29 @@ int __must_check clk_bulk_get(struct device *dev, int
> > num_clks, } EXPORT_SYMBOL(clk_bulk_get);
> >
> > +void clk_bulk_put_all(int num_clks, struct clk_bulk_data *clks) {
> > + if (IS_ERR_OR_NULL(clks))
> > + return;
> > +
> > + clk_bulk_put(num_clks, clks);
> > +
> > + kfree(clks);
> > +}
> > +EXPORT_SYMBOL(clk_bulk_put_all);
> > +
> > +int __must_check clk_bulk_get_all(struct device *dev,
> > + struct clk_bulk_data **clks) {
> > + struct device_node *np = dev_of_node(dev);
> > +
> > + if (!np)
> > + return 0;
> > +
> > + return of_clk_bulk_get_all(np, clks); }
> > +EXPORT_SYMBOL(clk_bulk_get_all);
>
> Looks better!
Thanks
Regards
Dong Aisheng
^ permalink raw reply [flat|nested] 13+ messages in thread
* RE: [PATCH V2 3/4] clk: add managed version of clk_bulk_get_all
2018-03-23 6:49 ` kbuild test robot
@ 2018-05-25 9:51 ` A.s. Dong
0 siblings, 0 replies; 13+ messages in thread
From: A.s. Dong @ 2018-05-25 9:51 UTC (permalink / raw)
To: kbuild test robot
Cc: kbuild-all, linux-clk, linux-kernel, linux-arm-kernel,
mturquette, hdegoede, b.zolnierkie, linux, linux-fbdev,
dl-linux-imx, sboyd, Stephen Boyd
> -----Original Message-----
> From: kbuild test robot [mailto:lkp@intel.com]
> Sent: Friday, March 23, 2018 2:49 PM
> To: A.s. Dong <aisheng.dong@nxp.com>
> Cc: kbuild-all@01.org; linux-clk@vger.kernel.org; linux-
> kernel@vger.kernel.org; linux-arm-kernel@lists.infradead.org;
> mturquette@baylibre.com; hdegoede@redhat.com;
> b.zolnierkie@samsung.com; linux@armlinux.org.uk; linux-
> fbdev@vger.kernel.org; dl-linux-imx <linux-imx@nxp.com>;
> sboyd@kernel.org; A.s. Dong <aisheng.dong@nxp.com>; Stephen Boyd
> <sboyd@codeaurora.org>
> Subject: Re: [PATCH V2 3/4] clk: add managed version of clk_bulk_get_all
>
[...]
> All errors (new ones prefixed by >>):
>
> In file included from include/linux/cpufreq.h:14:0,
> from arch/powerpc/platforms/cell/cpufreq_spudemand.c:23:
> include/linux/clk.h:679:1: error: expected identifier or '(' before '{' token
> {
> ^
> >> include/linux/clk.h:677:32: error: 'devm_clk_bulk_get_all' declared
> >> 'static' but never defined [-Werror=unused-function]
> static inline int __must_check devm_clk_bulk_get_all(struct device *dev,
> ^~~~~~~~~~~~~~~~~~~~~
> cc1: all warnings being treated as errors
>
> vim +677 include/linux/clk.h
>
> 676
> > 677 static inline int __must_check devm_clk_bulk_get_all(struct device
> *dev,
> 678 struct
> clk_bulk_data **clks);
Thanks for the reporting.
Caused by the extra unneeded ';' at the end of the line.
Will fix.
Regards
Dong Aisheng
> > 679 {
> 680
> 681 return 0;
> 682 }
> 683
>
> ---
> 0-DAY kernel test infrastructure Open Source Technology Center
> https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flist
> s.01.org%2Fpipermail%2Fkbuild-
> all&data=02%7C01%7Caisheng.dong%40nxp.com%7Ce9e35f96c61a4c46d1790
> 8d5908a4d46%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C6365738
> 46071200287&sdata=yIWEjcpE2tyJP%2BmsMPqn%2F83TCsxw64J%2Ba5ue73
> qGnN0%3D&reserved=0 Intel Corporation
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH V2 1/4] clk: bulk: add of_clk_bulk_get()
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
0 siblings, 0 replies; 13+ messages in thread
From: Dong Aisheng @ 2018-03-21 2:54 UTC (permalink / raw)
To: linux-clk
Cc: linux-kernel, linux-arm-kernel, mturquette, hdegoede,
b.zolnierkie, linux, linux-fbdev, linux-imx, sboyd, Dong Aisheng,
Stephen Boyd, Russell King
'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
^ permalink raw reply related [flat|nested] 13+ messages in thread
end of thread, other threads:[~2018-05-25 9:51 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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-23 6:49 ` kbuild test robot
2018-05-25 9:51 ` A.s. Dong
2018-03-21 3:19 ` [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
-- strict thread matches above, loose matches on Subject: below --
2018-03-21 2:54 [PATCH V2 0/4] clk: new APIs to handle all available clocks Dong Aisheng
2018-03-21 2:54 ` [PATCH V2 1/4] clk: bulk: add of_clk_bulk_get() Dong Aisheng
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).