Skip to contentSkip to conversation

pwm: sun4i: Fix inconsistent IS_ERR and PTR_ERR

PATCH In review Gustavo A. R. Silva 3 participants 5 messages Jan 9, 2020 – Jan 10, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pwm: sun4i: Fix inconsistent IS_ERR and PTR_ERR

Fix inconsistent IS_ERR and PTR_ERR in sun4i_pwm_probe().

The proper pointers to be passed as arguments are pwm->clk and pwm->bus_clk.

This bug was detected with the help of Coccinelle.

Fixes b8d74644f34a ("pwm: sun4i: Prefer "mod" clock to unnamed")
Fixes 5b090b430d75 ("pwm: sun4i: Add an optional probe for bus clock")
---
 drivers/pwm/pwm-sun4i.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/pwm/pwm-sun4i.c +3 -3
index 1afd41ebd3fd..a805c347ee84 100644
@@ -423,7 +423,7 @@ static int sun4i_pwm_probe(struct platform_device *pdev)
 	 */
 	pwm->clk = devm_clk_get_optional(&pdev->dev, "mod");
 	if (IS_ERR(pwm->clk)) {
-		if (PTR_ERR(pwm->rst) != -EPROBE_DEFER)
+		if (PTR_ERR(pwm->clk) != -EPROBE_DEFER)
 			dev_err(&pdev->dev, "get mod clock failed %pe\n",
 				pwm->clk);
 		return PTR_ERR(pwm->clk);
@@ -432,7 +432,7 @@ static int sun4i_pwm_probe(struct platform_device *pdev)
 	if (!pwm->clk) {
 		pwm->clk = devm_clk_get(&pdev->dev, NULL);
 		if (IS_ERR(pwm->clk)) {
-			if (PTR_ERR(pwm->rst) != -EPROBE_DEFER)
+			if (PTR_ERR(pwm->clk) != -EPROBE_DEFER)
 				dev_err(&pdev->dev, "get unnamed clock failed %pe\n",
 					pwm->clk);
 			return PTR_ERR(pwm->clk);
@@ -441,7 +441,7 @@ static int sun4i_pwm_probe(struct platform_device *pdev)
 
 	pwm->bus_clk = devm_clk_get_optional(&pdev->dev, "bus");
 	if (IS_ERR(pwm->bus_clk)) {
-		if (PTR_ERR(pwm->rst) != -EPROBE_DEFER)
+		if (PTR_ERR(pwm->bus_clk) != -EPROBE_DEFER)
 			dev_err(&pdev->dev, "get bus clock failed %pe\n",
 				pwm->bus_clk);
 		return PTR_ERR(pwm->bus_clk);
Signature · 7 lines
2.23.0


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Reviewed-by on v1 1/1
#1 lore raw

Hello Gustavo,

Quoted 18 lines · Gustavo A. R. Silva

Fix inconsistent IS_ERR and PTR_ERR in sun4i_pwm_probe().

The proper pointers to be passed as arguments are pwm->clk and pwm->bus_clk.

This bug was detected with the help of Coccinelle.

Fixes b8d74644f34a ("pwm: sun4i: Prefer "mod" clock to unnamed")
Fixes 5b090b430d75 ("pwm: sun4i: Add an optional probe for bus clock")
---
 drivers/pwm/pwm-sun4i.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/pwm/pwm-sun4i.c +0 -0
index 1afd41ebd3fd..a805c347ee84 100644

drivers/pwm/pwm-sun4i.c static int sun4i_pwm_probe(struct platform_device *pdev) · line 426

Quoted 5 lines
drivers/pwm/pwm-sun4i.c +1 -1
@@ -423,7 +423,7 @@ static int sun4i_pwm_probe(struct platform_device *pdev)
 	 */
 	pwm->clk = devm_clk_get_optional(&pdev->dev, "mod");
 	if (IS_ERR(pwm->clk)) {
-		if (PTR_ERR(pwm->rst) != -EPROBE_DEFER)
+		if (PTR_ERR(pwm->clk) != -EPROBE_DEFER)

How embarrassing that I didn't notice these. Thanks for catching.

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |
#2 lore raw

Hi Uwe, Gustavo,

Quoted 7 lines · Uwe Kleine-König

Hello Gustavo,

Quoted 3 lines · Gustavo A. R. Silva

Fix inconsistent IS_ERR and PTR_ERR in sun4i_pwm_probe().

The proper pointers to be passed as arguments are pwm->clk and pwm->bus_clk.

Thanks for the catch.

As these patches are still in next should we update them or apply a fix ?

Regards,
Clement

Quoted 31 lines
Quoted 15 lines

This bug was detected with the help of Coccinelle.

Fixes b8d74644f34a ("pwm: sun4i: Prefer "mod" clock to unnamed")
Fixes 5b090b430d75 ("pwm: sun4i: Add an optional probe for bus clock")
---
 drivers/pwm/pwm-sun4i.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/pwm/pwm-sun4i.c +0 -0
index 1afd41ebd3fd..a805c347ee84 100644

drivers/pwm/pwm-sun4i.c static int sun4i_pwm_probe(struct platform_device *pdev) · line 426

Quoted 5 lines
drivers/pwm/pwm-sun4i.c +1 -1
@@ -423,7 +423,7 @@ static int sun4i_pwm_probe(struct platform_device *pdev)
       */
      pwm->clk = devm_clk_get_optional(&pdev->dev, "mod");
      if (IS_ERR(pwm->clk)) {
-             if (PTR_ERR(pwm->rst) != -EPROBE_DEFER)
+             if (PTR_ERR(pwm->clk) != -EPROBE_DEFER)

How embarrassing that I didn't notice these. Thanks for catching.

Best regards
Uwe

--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | https://www.pengutronix.de/ |

#3 lore raw

Hello,

Quoted 5 lines · Clément Péron
Quoted 3 lines · Uwe Kleine-König

Hello Gustavo,

Quoted 8 lines
Quoted 4 lines · Gustavo A. R. Silva
Quoted 3 lines

Fix inconsistent IS_ERR and PTR_ERR in sun4i_pwm_probe().

The proper pointers to be passed as arguments are pwm->clk and pwm->bus_clk.

Thanks for the catch.

As these patches are still in next should we update them or apply a fix ?

That's for Thierry to answer.

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |
Reviewed-by on v1 1/1
#4 lore raw
In reply to Gustavo A. R. Silva

Hello,

Quoted 9 lines · Gustavo A. R. Silva

Fix inconsistent IS_ERR and PTR_ERR in sun4i_pwm_probe().

The proper pointers to be passed as arguments are pwm->clk and pwm->bus_clk.

This bug was detected with the help of Coccinelle.

Fixes b8d74644f34a ("pwm: sun4i: Prefer "mod" clock to unnamed")
Fixes 5b090b430d75 ("pwm: sun4i: Add an optional probe for bus clock")

Patchwork seems to have missed my earlier reply with my Reviewed-by:.
(https://patchwork.ozlabs.org/patch/1220206/ only has Clément's reply that still contains my quoted text, but obviously this wasn't picked up by patchwork.)

So resending it in the hope this was a one-time miss:

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |