Skip to content

Commit 4880189

Browse files
Marco Paganibebarino
authored andcommitted
clk: socfpga: 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, and the __init macro moved before the function name, as specified in init.h. Signed-off-by: Marco Pagani <marpagan@redhat.com> Link: https://lore.kernel.org/r/20221209152913.1335068-2-marpagan@redhat.com Signed-off-by: Stephen Boyd <sboyd@kernel.org>
1 parent fe15c26 commit 4880189

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

drivers/clk/socfpga/clk-periph.c

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ static const struct clk_ops periclk_ops = {
4747
.get_parent = clk_periclk_get_parent,
4848
};
4949

50-
static __init void __socfpga_periph_init(struct device_node *node,
51-
const struct clk_ops *ops)
50+
static void __init __socfpga_periph_init(struct device_node *node,
51+
const struct clk_ops *ops)
5252
{
5353
u32 reg;
5454
struct clk_hw *hw_clk;
@@ -96,11 +96,25 @@ static __init void __socfpga_periph_init(struct device_node *node,
9696
periph_clk->hw.hw.init = &init;
9797
hw_clk = &periph_clk->hw.hw;
9898

99-
if (clk_hw_register(NULL, hw_clk)) {
100-
kfree(periph_clk);
101-
return;
99+
rc = clk_hw_register(NULL, hw_clk);
100+
if (rc) {
101+
pr_err("Could not register clock:%s\n", clk_name);
102+
goto err_clk_hw_register;
103+
}
104+
105+
rc = of_clk_add_hw_provider(node, of_clk_hw_simple_get, hw_clk);
106+
if (rc) {
107+
pr_err("Could not register clock provider for node:%s\n",
108+
clk_name);
109+
goto err_of_clk_add_hw_provider;
102110
}
103-
rc = of_clk_add_provider(node, of_clk_src_simple_get, hw_clk);
111+
112+
return;
113+
114+
err_of_clk_add_hw_provider:
115+
clk_hw_unregister(hw_clk);
116+
err_clk_hw_register:
117+
kfree(periph_clk);
104118
}
105119

106120
void __init socfpga_periph_init(struct device_node *node)

0 commit comments

Comments
 (0)