Skip to contentSkip to conversation

clk: renesas: fix return value and unused assignment

PATCH In review Yang Li 2 participants 4 messages Jun 17, 2021 – Jun 18, 2021

Subsystems (2)
lore
Share & tools
lore

Yang Li

author
#0 lore raw

PATCH v2 1/1 clk: renesas: fix return value and unused assignment

Currently the function returns NULL on error, so exact error code is lost. This patch changes return convention of the function to use ERR_PTR() on error instead.

---

Change in v2:
--simply "return ERR_PTR(-ENOMEM);"

 drivers/clk/renesas/renesas-rzg2l-cpg.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/clk/renesas/renesas-rzg2l-cpg.c +1 -2
index 5009b9e..d46fffd 100644
@@ -182,8 +182,7 @@ static unsigned long rzg2l_cpg_pll_clk_recalc_rate(struct clk_hw *hw,
 
 	pll_clk = devm_kzalloc(dev, sizeof(*pll_clk), GFP_KERNEL);
 	if (!pll_clk) {
-		clk = ERR_PTR(-ENOMEM);
-		return NULL;
+		return ERR_PTR(-ENOMEM);
 	}
 
 	parent_name = __clk_get_name(parent);
Signature · 1 line
1.8.3.1
Reviewed-by on v2 1/1
#1 lore raw
Quoted 6 lines · Yang Li

Currently the function returns NULL on error, so exact error code is lost. This patch changes return convention of the function to use ERR_PTR() on error instead.

i.e. will queue in renesas-clk-for-v5.15.

drivers/clk/renesas/renesas-rzg2l-cpg.c static unsigned long rzg2l_cpg_pll_clk_recalc_rate(struct clk_hw *hw, · line 186

Quoted 10 lines
drivers/clk/renesas/renesas-rzg2l-cpg.c +1 -2
@@ -182,8 +182,7 @@ static unsigned long rzg2l_cpg_pll_clk_recalc_rate(struct clk_hw *hw,
 
        pll_clk = devm_kzalloc(dev, sizeof(*pll_clk), GFP_KERNEL);
        if (!pll_clk) {
-               clk = ERR_PTR(-ENOMEM);
-               return NULL;
+               return ERR_PTR(-ENOMEM);
        }

I'll drop the curly braces while applying.

drivers/clk/renesas/renesas-rzg2l-cpg.c static unsigned long rzg2l_cpg_pll_clk_recalc_rate(struct clk_hw *hw, · line 188

Quoted 2 lines
drivers/clk/renesas/renesas-rzg2l-cpg.c +0 -0
        parent_name = __clk_get_name(parent);

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#2 lore raw
Quoted 15 lines · Geert Uytterhoeven
Quoted 6 lines · Yang Li

Currently the function returns NULL on error, so exact error code is lost. This patch changes return convention of the function to use ERR_PTR() on error instead.

i.e. will queue in renesas-clk-for-v5.15.

Quoted 4 lines
drivers/clk/renesas/renesas-rzg2l-cpg.c +0 -0
@@ -182,8 +182,7 @@ static unsigned long rzg2l_cpg_pll_clk_recalc_rate(struct clk_hw *hw,
 
Quoted 8 lines

drivers/clk/renesas/renesas-rzg2l-cpg.c static unsigned long rzg2l_cpg_pll_clk_recalc_rate(struct clk_hw *hw, · line 186

Quoted 6 lines
drivers/clk/renesas/renesas-rzg2l-cpg.c +1 -2
        pll_clk = devm_kzalloc(dev, sizeof(*pll_clk), GFP_KERNEL);
        if (!pll_clk) {
-               clk = ERR_PTR(-ENOMEM);
-               return NULL;
+               return ERR_PTR(-ENOMEM);
        }

I'll drop the curly braces while applying.

... and the now unused clk variable.

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#3 lore raw
Quoted 25 lines · Geert Uytterhoeven
Quoted 15 lines · Geert Uytterhoeven
Quoted 6 lines · Yang Li

Currently the function returns NULL on error, so exact error code is lost. This patch changes return convention of the function to use ERR_PTR() on error instead.

i.e. will queue in renesas-clk-for-v5.15.

Quoted 4 lines
drivers/clk/renesas/renesas-rzg2l-cpg.c +0 -0
@@ -182,8 +182,7 @@ static unsigned long rzg2l_cpg_pll_clk_recalc_rate(struct clk_hw *hw,
 
Quoted 8 lines

drivers/clk/renesas/renesas-rzg2l-cpg.c static unsigned long rzg2l_cpg_pll_clk_recalc_rate(struct clk_hw *hw, · line 186

Quoted 6 lines
drivers/clk/renesas/renesas-rzg2l-cpg.c +1 -2
        pll_clk = devm_kzalloc(dev, sizeof(*pll_clk), GFP_KERNEL);
        if (!pll_clk) {
-               clk = ERR_PTR(-ENOMEM);
-               return NULL;
+               return ERR_PTR(-ENOMEM);
        }

I'll drop the curly braces while applying.

Quoted 1 line

... and the now unused clk variable.

Oops, that's only after Dan's patch. Reshuffling...

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds