Skip to content

Commit 3dc6faa

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 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. Signed-off-by: Marco Pagani <marpagan@redhat.com> Link: https://lore.kernel.org/r/20221209152913.1335068-7-marpagan@redhat.com Signed-off-by: Stephen Boyd <sboyd@kernel.org>
1 parent 00720a9 commit 3dc6faa

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

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

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ static const struct clk_ops clk_pll_ops = {
6363
.get_parent = clk_pll_get_parent,
6464
};
6565

66-
static struct clk_hw * __init __socfpga_pll_init(struct device_node *node,
67-
const struct clk_ops *ops)
66+
static void __init __socfpga_pll_init(struct device_node *node,
67+
const struct clk_ops *ops)
6868
{
6969
u32 reg;
7070
struct clk_hw *hw_clk;
@@ -73,13 +73,14 @@ static struct clk_hw * __init __socfpga_pll_init(struct device_node *node,
7373
const char *parent_name[SOCFGPA_MAX_PARENTS];
7474
struct clk_init_data init;
7575
struct device_node *clkmgr_np;
76+
int rc;
7677
int i = 0;
7778

7879
of_property_read_u32(node, "reg", &reg);
7980

8081
pll_clk = kzalloc(sizeof(*pll_clk), GFP_KERNEL);
8182
if (WARN_ON(!pll_clk))
82-
return NULL;
83+
return;
8384

8485
clkmgr_np = of_find_compatible_node(NULL, NULL, "altr,clk-mgr");
8586
clk_mgr_a10_base_addr = of_iomap(clkmgr_np, 0);
@@ -103,12 +104,25 @@ static struct clk_hw * __init __socfpga_pll_init(struct device_node *node,
103104
pll_clk->hw.bit_idx = SOCFPGA_PLL_EXT_ENA;
104105
hw_clk = &pll_clk->hw.hw;
105106

106-
if (clk_hw_register(NULL, hw_clk)) {
107-
kfree(pll_clk);
108-
return NULL;
107+
rc = clk_hw_register(NULL, hw_clk);
108+
if (rc) {
109+
pr_err("Could not register clock:%s\n", clk_name);
110+
goto err_clk_hw_register;
109111
}
110-
of_clk_add_provider(node, of_clk_src_simple_get, hw_clk);
111-
return hw_clk;
112+
113+
rc = of_clk_add_hw_provider(node, of_clk_hw_simple_get, hw_clk);
114+
if (rc) {
115+
pr_err("Could not register clock provider for node:%s\n",
116+
clk_name);
117+
goto err_of_clk_add_hw_provider;
118+
}
119+
120+
return;
121+
122+
err_of_clk_add_hw_provider:
123+
clk_hw_unregister(hw_clk);
124+
err_clk_hw_register:
125+
kfree(pll_clk);
112126
}
113127

114128
void __init socfpga_a10_pll_init(struct device_node *node)

0 commit comments

Comments
 (0)