Skip to content

Commit cfdc041

Browse files
aisheng86bebarino
authored andcommitted
clk: bulk: add of_clk_bulk_get()
'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> Tested-by: Thor Thayer <thor.thayer@linux.intel.com> Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com> Signed-off-by: Stephen Boyd <sboyd@kernel.org>
1 parent 5b394b2 commit cfdc041

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

‎drivers/clk/clk-bulk.c‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,35 @@
1919
#include <linux/clk.h>
2020
#include <linux/device.h>
2121
#include <linux/export.h>
22+
#include <linux/of.h>
23+
24+
static int __must_check of_clk_bulk_get(struct device_node *np, int num_clks,
25+
struct clk_bulk_data *clks)
26+
{
27+
int ret;
28+
int i;
29+
30+
for (i = 0; i < num_clks; i++)
31+
clks[i].clk = NULL;
32+
33+
for (i = 0; i < num_clks; i++) {
34+
clks[i].clk = of_clk_get(np, i);
35+
if (IS_ERR(clks[i].clk)) {
36+
ret = PTR_ERR(clks[i].clk);
37+
pr_err("%pOF: Failed to get clk index: %d ret: %d\n",
38+
np, i, ret);
39+
clks[i].clk = NULL;
40+
goto err;
41+
}
42+
}
43+
44+
return 0;
45+
46+
err:
47+
clk_bulk_put(i, clks);
48+
49+
return ret;
50+
}
2251

2352
void clk_bulk_put(int num_clks, struct clk_bulk_data *clks)
2453
{

0 commit comments

Comments
 (0)