Skip to contentSkip to conversation

clk: clk-prima2: fix return value check in prima2_clk_init()

PATCH Applied Xu Wang 3 participants 3 messages Sep 21, 2020 – Oct 14, 2020 Common clk

lore
Share & tools
lore

Xu Wang

author
#0 lore raw

PATCH 1/1 clk: clk-prima2: fix return value check in prima2_clk_init()

In case of error, the function clk_register() returns ERR_PTR() and never returns NULL. The NULL test in the return value check should be replaced with IS_ERR().

---
 drivers/clk/sirf/clk-prima2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/sirf/clk-prima2.c +1 -1
index 45dcbc9e0302..d17b345f4d2d 100644
@@ -134,7 +134,7 @@ static void __init prima2_clk_init(struct device_node *np)
 
 	for (i = pll1; i < maxclk; i++) {
 		prima2_clks[i] = clk_register(NULL, prima2_clk_hw_array[i]);
-		BUG_ON(!prima2_clks[i]);
+		BUG_ON(IS_ERR(prima2_clks[i]));
 	}
 	clk_register_clkdev(prima2_clks[cpu], NULL, "cpu");
 	clk_register_clkdev(prima2_clks[io],  NULL, "io");
Signature · 1 line
2.17.1
Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · Xu Wang <[email protected]> 于2020年9月21日周一 下午3:45写道:

In case of error, the function clk_register() returns ERR_PTR() and never returns NULL. The NULL test in the return value check should be replaced with IS_ERR().

Thanks

Quoted 20 lines
---
 drivers/clk/sirf/clk-prima2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/sirf/clk-prima2.c +1 -2
index 45dcbc9e0302..d17b345f4d2d 100644
@@ -134,7 +134,7 @@ static void __init prima2_clk_init(struct device_node *np)
 
        for (i = pll1; i < maxclk; i++) {
                prima2_clks[i] = clk_register(NULL, prima2_clk_hw_array[i]);
-               BUG_ON(!prima2_clks[i]);
+               BUG_ON(IS_ERR(prima2_clks[i]));
        }
        clk_register_clkdev(prima2_clks[cpu], NULL, "cpu");
        clk_register_clkdev(prima2_clks[io],  NULL, "io");
--

2.17.1

maintainer Applied
#2 lore raw
In reply to Xu Wang

Quoting Xu Wang (2020-09-20 20:45:22)

Quoted 6 lines

In case of error, the function clk_register() returns ERR_PTR() and never returns NULL. The NULL test in the return value check should be replaced with IS_ERR().

---

Applied to clk-next