diff options
author | Haojian Zhuang <haojian.zhuang@linaro.org> | 2013-10-22 16:50:38 +0800 |
---|---|---|
committer | Haojian Zhuang <haojian.zhuang@linaro.org> | 2013-10-22 19:29:18 +0800 |
commit | 1c16ddeb3574a51f508964ecd4a35e6b221fbde7 (patch) | |
tree | 999f3f3f44f8b1507f0f1982a2ea54fb1182b8bc | |
parent | 17a1a8fe4338d4bd267ca9c9b4729b0ff1c73879 (diff) |
clk: hi3xxx: fix the useless pointer in mux
The code of parsing mux table was moved into a function. But the pointer
is still *, not **. So it won't work right. Fix it by merging code into
mux setup function.
Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org>
-rw-r--r-- | drivers/clk/hisilicon/clk-hi3xxx.c | 57 |
1 files changed, 19 insertions, 38 deletions
diff --git a/drivers/clk/hisilicon/clk-hi3xxx.c b/drivers/clk/hisilicon/clk-hi3xxx.c index b14c11c0899a..a331a786e343 100644 --- a/drivers/clk/hisilicon/clk-hi3xxx.c +++ b/drivers/clk/hisilicon/clk-hi3xxx.c @@ -213,45 +213,14 @@ err_pclk: kfree(parent_names); } -static int __init hi3xxx_parse_mux(struct device_node *np, - u8 *num_parents, - u32 *table) -{ - int i, cnt, ret; - - /* get the count of items in mux */ - for (i = 0, cnt = 0; ; i++, cnt++) { - /* parent's #clock-cells property is always 0 */ - if (!of_parse_phandle(np, "clocks", i)) - break; - } - - for (i = 0; i < cnt; i++) { - if (!of_clk_get_parent_name(np, i)) - return -ENOENT; - } - *num_parents = cnt; - table = kzalloc(sizeof(u32 *) * cnt, GFP_KERNEL); - if (!table) - return -ENOMEM; - ret = of_property_read_u32_array(np, "hisilicon,clkmux-table", - table, cnt); - if (ret) - goto err; - return 0; -err: - kfree(table); - return ret; -} - static void __init hi3620_clkmux_setup(struct device_node *np) { struct clk *clk; const char *clk_name, **parent_names = NULL; u32 rdata[2], mask, *table = NULL; - u8 num_parents, shift, flag = 0; + u8 shift, flag = 0; void __iomem *reg, *base; - int i, ret; + int i, cnt, ret; base = hs_init_clocks(np); if (!base) @@ -266,20 +235,32 @@ static void __init hi3620_clkmux_setup(struct device_node *np) if (of_property_read_bool(np, "hiword")) flag = CLK_MUX_HIWORD_MASK; - ret = hi3xxx_parse_mux(np, &num_parents, table); - if (ret) + cnt = of_count_phandle_with_args(np, "clocks", "#clock-cells"); + if (cnt < 0) { + pr_err("failed to find clock parent\n"); + return; + } + + table = kzalloc(sizeof(u32) * cnt, GFP_KERNEL); + if (!table) + return; + ret = of_property_read_u32_array(np, "hisilicon,clkmux-table", + table, cnt); + if (ret) { + pr_err("failed on parsing %s's clkmux-table \n", clk_name); return; + } - parent_names = kzalloc(sizeof(char *) * num_parents, GFP_KERNEL); + parent_names = kzalloc(sizeof(char *) * cnt, GFP_KERNEL); if (!parent_names) goto err; - for (i = 0; i < num_parents; i++) + for (i = 0; i < cnt; i++) parent_names[i] = of_clk_get_parent_name(np, i); reg = base + rdata[0]; shift = ffs(rdata[1]) - 1; mask = rdata[1] >> shift; - clk = clk_register_mux_table(NULL, clk_name, parent_names, num_parents, + clk = clk_register_mux_table(NULL, clk_name, parent_names, (u8)cnt, CLK_SET_RATE_PARENT, reg, shift, mask, flag, table, &hs_clk.lock); |