Skip to content

Commit 00720a9

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 return type of the init function has been changed to void since the return value was not used, and the indentation of the parameters has been aligned to match open parenthesis, as suggested by checkpatch. The err variable has been renamed rc for consistency. Signed-off-by: Marco Pagani <marpagan@redhat.com> Link: https://lore.kernel.org/r/20221209152913.1335068-6-marpagan@redhat.com Signed-off-by: Stephen Boyd <sboyd@kernel.org>
1 parent 6e83bd7 commit 00720a9

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

drivers/clk/socfpga/clk-pll.c

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ static const struct clk_ops clk_pll_ops = {
7070
.get_parent = clk_pll_get_parent,
7171
};
7272

73-
static __init struct clk_hw *__socfpga_pll_init(struct device_node *node,
74-
const struct clk_ops *ops)
73+
static void __init __socfpga_pll_init(struct device_node *node,
74+
const struct clk_ops *ops)
7575
{
7676
u32 reg;
7777
struct clk_hw *hw_clk;
@@ -80,13 +80,13 @@ static __init struct clk_hw *__socfpga_pll_init(struct device_node *node,
8080
const char *parent_name[SOCFPGA_MAX_PARENTS];
8181
struct clk_init_data init;
8282
struct device_node *clkmgr_np;
83-
int err;
83+
int rc;
8484

8585
of_property_read_u32(node, "reg", &reg);
8686

8787
pll_clk = kzalloc(sizeof(*pll_clk), GFP_KERNEL);
8888
if (WARN_ON(!pll_clk))
89-
return NULL;
89+
return;
9090

9191
clkmgr_np = of_find_compatible_node(NULL, NULL, "altr,clk-mgr");
9292
clk_mgr_base_addr = of_iomap(clkmgr_np, 0);
@@ -108,13 +108,25 @@ static __init struct clk_hw *__socfpga_pll_init(struct device_node *node,
108108

109109
hw_clk = &pll_clk->hw.hw;
110110

111-
err = clk_hw_register(NULL, hw_clk);
112-
if (err) {
113-
kfree(pll_clk);
114-
return ERR_PTR(err);
111+
rc = clk_hw_register(NULL, hw_clk);
112+
if (rc) {
113+
pr_err("Could not register clock:%s\n", clk_name);
114+
goto err_clk_hw_register;
115115
}
116-
of_clk_add_provider(node, of_clk_src_simple_get, hw_clk);
117-
return hw_clk;
116+
117+
rc = of_clk_add_hw_provider(node, of_clk_hw_simple_get, hw_clk);
118+
if (rc) {
119+
pr_err("Could not register clock provider for node:%s\n",
120+
clk_name);
121+
goto err_of_clk_add_hw_provider;
122+
}
123+
124+
return;
125+
126+
err_of_clk_add_hw_provider:
127+
clk_hw_unregister(hw_clk);
128+
err_clk_hw_register:
129+
kfree(pll_clk);
118130
}
119131

120132
void __init socfpga_pll_init(struct device_node *node)

0 commit comments

Comments
 (0)