pwm: spear: fix check on pwmchip_add() return value
PATCH 1/1 pwm: spear: fix check on pwmchip_add() return value
pwmchip_add() returns zero on success and a negative value on error, so the condition of the check must be inverted.
--- drivers/pwm/pwm-spear.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pwm/pwm-spear.c +1 -1
@@ -222,7 +222,7 @@ static int spear_pwm_probe(struct platform_device *pdev) } ret =pwmchip_add (&pc->chip); -if (!ret) { +if (ret <0 ) {clk_unprepare (pc->clk);dev_err (&pdev->dev,"pwmchip_add() failed: %d\n" , ret); }
Signature · 1 line
1.7.10.4
Quoted 13 lines · Beniamino Galvani
pwmchip_add()returns zero on success and a negative value on error, so the condition of the check must be inverted.Signed-off-by Beniamino Galvani <[email protected]>--- drivers/pwm/pwm-spear.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/pwm/pwm-spear.c +0
-0
drivers/pwm/pwm-spear.c static int spear_pwm_probe(struct platform_device *pdev) · line 228
Quoted 8 lines
drivers/pwm/pwm-spear.c +1
-1@@ -222,7 +222,7 @@ static int spear_pwm_probe(struct platform_device *pdev) } ret =pwmchip_add (&pc->chip); -if (!ret) { +if (ret <0 ) {clk_unprepare (pc->clk);dev_err (&pdev->dev,"pwmchip_add() failed: %d\n" , ret); }
Quoted 16 lines · Viresh Kumar
Quoted 15 lines · Beniamino Galvani
pwmchip_add()returns zero on success and a negative value on error, so the condition of the check must be inverted.Signed-off-by Beniamino Galvani <[email protected]>--- drivers/pwm/pwm-spear.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/pwm/pwm-spear.c +0
-0@@ -222,7 +222,7 @@ static int spear_pwm_probe(struct platform_device *pdev) }
Quoted 6 lines
drivers/pwm/pwm-spear.c static int spear_pwm_probe(struct platform_device *pdev) · line 228
Quoted 6 lines
drivers/pwm/pwm-spear.c +1
-1ret =pwmchip_add (&pc->chip); -if (!ret) { +if (ret <0 ) {clk_unprepare (pc->clk);dev_err (&pdev->dev,"pwmchip_add() failed: %d\n" , ret); }
So the current code would run clk_unprepare() on success, but not on failure. Does that cause any harm? Is the device still usable after this? I'm asking because I'm not sure if this is linux-next material or should be a fix for 3.15 (and possibly backported to stable).
Thierry
Quoted 2 lines · Thierry Reding
So the current code would run
clk_unprepare()on success, but not on failure. Does that cause any harm?
Yeah, that would make the device unusable as clk_enable will always fail.
Quoted 1 line
Is the device still usable after this?
Yes, this will fix the bug.
Quoted 2 lines
I'm asking because I'm not sure if this is linux-next material or should be a fix for 3.15 (and possibly backported to stable).
IMO, it should be sent for stable: v3.8+
Quoted 5 lines · Viresh Kumar
Quoted 2 lines · Thierry Reding
So the current code would run
clk_unprepare()on success, but not on failure. Does that cause any harm?Yeah, that would make the device unusable as
clk_enablewill always fail.
Hmm... so ever since this driver was merged in 3.8 it was completely broken and nobody noticed? Interesting.
Quoted 8 lines
Quoted 1 line
Is the device still usable after this?
Yes, this will fix the bug.
Quoted 2 lines
I'm asking because I'm not sure if this is linux-next material or should be a fix for 3.15 (and possibly backported to stable).
IMO, it should be sent for stable: v3.8+
Since this was obviously broken since 3.8 and nobody noticed I wonder if there's really an urgent need for this in stable.
Thierry
Quoted 2 lines · Thierry Reding
Since this was obviously broken since 3.8 and nobody noticed I wonder if there's really an urgent need for this in stable.
I don't think there is any urgent need of this, in case somebody wants we can add it later. :)