Skip to content

Commit 85f1b57

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 err variable unnecessarily duplicates the functionality of the rc variable, so it has been removed. Signed-off-by: Marco Pagani <marpagan@redhat.com> Link: https://lore.kernel.org/r/20221209152913.1335068-4-marpagan@redhat.com Signed-off-by: Stephen Boyd <sboyd@kernel.org>
1 parent da939f6 commit 85f1b57

File tree

1 file changed

+22
-13
lines changed

1 file changed

+22
-13
lines changed

drivers/clk/socfpga/clk-gate.c

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -126,17 +126,14 @@ void __init socfpga_gate_init(struct device_node *node)
126126
struct clk_init_data init;
127127
struct clk_ops *ops;
128128
int rc;
129-
int err;
130129

131130
socfpga_clk = kzalloc(sizeof(*socfpga_clk), GFP_KERNEL);
132131
if (WARN_ON(!socfpga_clk))
133132
return;
134133

135134
ops = kmemdup(&gateclk_ops, sizeof(gateclk_ops), GFP_KERNEL);
136-
if (WARN_ON(!ops)) {
137-
kfree(socfpga_clk);
138-
return;
139-
}
135+
if (WARN_ON(!ops))
136+
goto err_kmemdup;
140137

141138
rc = of_property_read_u32_array(node, "clk-gate", clk_gate, 2);
142139
if (rc)
@@ -182,13 +179,25 @@ void __init socfpga_gate_init(struct device_node *node)
182179

183180
hw_clk = &socfpga_clk->hw.hw;
184181

185-
err = clk_hw_register(NULL, hw_clk);
186-
if (err) {
187-
kfree(ops);
188-
kfree(socfpga_clk);
189-
return;
182+
rc = clk_hw_register(NULL, hw_clk);
183+
if (rc) {
184+
pr_err("Could not register clock:%s\n", clk_name);
185+
goto err_clk_hw_register;
190186
}
191-
rc = of_clk_add_provider(node, of_clk_src_simple_get, hw_clk);
192-
if (WARN_ON(rc))
193-
return;
187+
188+
rc = of_clk_add_hw_provider(node, of_clk_hw_simple_get, hw_clk);
189+
if (rc) {
190+
pr_err("Could not register clock provider for node:%s\n",
191+
clk_name);
192+
goto err_of_clk_add_hw_provider;
193+
}
194+
195+
return;
196+
197+
err_of_clk_add_hw_provider:
198+
clk_hw_unregister(hw_clk);
199+
err_clk_hw_register:
200+
kfree(ops);
201+
err_kmemdup:
202+
kfree(socfpga_clk);
194203
}

0 commit comments

Comments
 (0)