Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Dong Aisheng and committed by
Stephen Boyd
cfdc0411 5b394b2d

+29
+29
drivers/clk/clk-bulk.c
··· 19 19 #include <linux/clk.h> 20 20 #include <linux/device.h> 21 21 #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 + } 22 51 23 52 void clk_bulk_put(int num_clks, struct clk_bulk_data *clks) 24 53 {