Skip to content

Commit 6e83bd7

Browse files
Marco Paganibebarino
authored andcommitted
clk: socfpga: arria10: use of_clk_add_hw_provider and improve error handling
The function of_clk_add_provider() has been deprecated, so use its suggested replacement of_clk_add_hw_provider() instead. Since of_clk_add_hw_provider() can fail, like of_clk_add_provider(), check its return value and do the error handling. The indentation of the init function parameters has been aligned to match open parenthesis as suggested by checkpatch. Signed-off-by: Marco Pagani <marpagan@redhat.com> Link: https://lore.kernel.org/r/20221209152913.1335068-5-marpagan@redhat.com Signed-off-by: Stephen Boyd <sboyd@kernel.org>
1 parent 85f1b57 commit 6e83bd7

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

drivers/clk/socfpga/clk-gate-a10.c

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ static struct clk_ops gateclk_ops = {
4040
};
4141

4242
static void __init __socfpga_gate_init(struct device_node *node,
43-
const struct clk_ops *ops)
43+
const struct clk_ops *ops)
4444
{
4545
u32 clk_gate[2];
4646
u32 div_reg[3];
@@ -94,13 +94,25 @@ static void __init __socfpga_gate_init(struct device_node *node,
9494
socfpga_clk->hw.hw.init = &init;
9595
hw_clk = &socfpga_clk->hw.hw;
9696

97-
if (clk_hw_register(NULL, hw_clk)) {
98-
kfree(socfpga_clk);
99-
return;
97+
rc = clk_hw_register(NULL, hw_clk);
98+
if (rc) {
99+
pr_err("Could not register clock:%s\n", clk_name);
100+
goto err_clk_hw_register;
100101
}
101-
rc = of_clk_add_provider(node, of_clk_src_simple_get, hw_clk);
102-
if (WARN_ON(rc))
103-
return;
102+
103+
rc = of_clk_add_hw_provider(node, of_clk_hw_simple_get, hw_clk);
104+
if (rc) {
105+
pr_err("Could not register clock provider for node:%s\n",
106+
clk_name);
107+
goto err_of_clk_add_hw_provider;
108+
}
109+
110+
return;
111+
112+
err_of_clk_add_hw_provider:
113+
clk_hw_unregister(hw_clk);
114+
err_clk_hw_register:
115+
kfree(socfpga_clk);
104116
}
105117

106118
void __init socfpga_a10_gate_init(struct device_node *node)

0 commit comments

Comments
 (0)