Thread (8 messages) 8 messages, 3 authors, 2021-06-09

Re: [PATCH V2] clk: socfpga: err out if of_clk_add_provider() failed in __socfpga_pll_init()

From: Stephen Boyd <sboyd@kernel.org>
Date: 2021-06-09 21:57:16
Also in: lkml

Quoting Yu Kuai (2021-06-02 01:42:59)
__socfpga_pll_init() should fail if of_clk_add_provider() failed.
remove 'rc' in the meantime to avoid gcc
'-Wunused-but-set-variable' warning.

Signed-off-by: Yu Kuai <redacted>
---
Please don't send as in-reply-to previous patches. Makes it hard for me
to find them on the list.
quoted hunk ↗ jump to hunk
changes in V2:
 - remove 'rc' and use err' instead of 'rc'
 - err out if of_clk_add_provider() failed

 drivers/clk/socfpga/clk-pll.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/drivers/clk/socfpga/clk-pll.c b/drivers/clk/socfpga/clk-pll.c
index dcb573d44034..5a9eec2eca80 100644
--- a/drivers/clk/socfpga/clk-pll.c
+++ b/drivers/clk/socfpga/clk-pll.c
@@ -80,7 +80,6 @@ static __init struct clk_hw *__socfpga_pll_init(struct device_node *node,
        const char *parent_name[SOCFPGA_MAX_PARENTS];
        struct clk_init_data init;
        struct device_node *clkmgr_np;
-       int rc;
        int err;
 
        of_property_read_u32(node, "reg", &reg);
@@ -110,12 +109,16 @@ static __init struct clk_hw *__socfpga_pll_init(struct device_node *node,
        hw_clk = &pll_clk->hw.hw;
 
        err = clk_hw_register(NULL, hw_clk);
-       if (err) {
-               kfree(pll_clk);
-               return ERR_PTR(err);
-       }
-       rc = of_clk_add_provider(node, of_clk_src_simple_get, hw_clk);
+       if (err)
+               goto err_out;
+       err = of_clk_add_provider(node, of_clk_src_simple_get, hw_clk);
+       if (err)
Now we don't unregister the clk on failure? Can you use
of_clk_add_hw_provider() as well? That would make this more modern. It
can be done as a followup patch to this one.
+               goto err_out;
        return hw_clk;
+
+err_out:
+       kfree(pll_clk);
+       return ERR_PTR(err);
 }
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help