Skip to content

Commit da939f6

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, 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-3-marpagan@redhat.com Signed-off-by: Stephen Boyd <sboyd@kernel.org>
1 parent 4880189 commit da939f6

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

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

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ static const struct clk_ops periclk_ops = {
5757
.get_parent = clk_periclk_get_parent,
5858
};
5959

60-
static __init void __socfpga_periph_init(struct device_node *node,
61-
const struct clk_ops *ops)
60+
static void __init __socfpga_periph_init(struct device_node *node,
61+
const struct clk_ops *ops)
6262
{
6363
u32 reg;
6464
struct clk_hw *hw_clk;
@@ -106,21 +106,25 @@ static __init void __socfpga_periph_init(struct device_node *node,
106106

107107
hw_clk = &periph_clk->hw.hw;
108108

109-
if (clk_hw_register(NULL, hw_clk)) {
110-
kfree(periph_clk);
111-
return;
109+
rc = clk_hw_register(NULL, hw_clk);
110+
if (rc) {
111+
pr_err("Could not register clock:%s\n", clk_name);
112+
goto err_clk_hw_register;
112113
}
113-
rc = of_clk_add_provider(node, of_clk_src_simple_get, hw_clk);
114-
if (rc < 0) {
114+
115+
rc = of_clk_add_hw_provider(node, of_clk_hw_simple_get, hw_clk);
116+
if (rc) {
115117
pr_err("Could not register clock provider for node:%s\n",
116118
clk_name);
117-
goto err_clk;
119+
goto err_of_clk_add_hw_provider;
118120
}
119121

120122
return;
121123

122-
err_clk:
124+
err_of_clk_add_hw_provider:
123125
clk_hw_unregister(hw_clk);
126+
err_clk_hw_register:
127+
kfree(periph_clk);
124128
}
125129

126130
void __init socfpga_a10_periph_init(struct device_node *node)

0 commit comments

Comments
 (0)