linux-pwm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] pwm: spear: fix check on pwmchip_add() return value
@ 2014-05-05 21:29 Beniamino Galvani
  2014-05-07  6:07 ` Viresh Kumar
  0 siblings, 1 reply; 6+ messages in thread
From: Beniamino Galvani @ 2014-05-05 21:29 UTC (permalink / raw)
  To: Thierry Reding; +Cc: linux-pwm, linux-kernel, 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 <b.galvani@gmail.com>
---
 drivers/pwm/pwm-spear.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pwm/pwm-spear.c b/drivers/pwm/pwm-spear.c
index cb2d4f0..945556d 100644
--- a/drivers/pwm/pwm-spear.c
+++ b/drivers/pwm/pwm-spear.c
@@ -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);
 	}
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] pwm: spear: fix check on pwmchip_add() return value
  2014-05-05 21:29 [PATCH] pwm: spear: fix check on pwmchip_add() return value Beniamino Galvani
@ 2014-05-07  6:07 ` Viresh Kumar
  2014-05-07  8:24   ` Thierry Reding
  0 siblings, 1 reply; 6+ messages in thread
From: Viresh Kumar @ 2014-05-07  6:07 UTC (permalink / raw)
  To: Beniamino Galvani; +Cc: Thierry Reding, linux-pwm, linux-kernel@vger.kernel.org

On Tue, May 6, 2014 at 2:59 AM, Beniamino Galvani <b.galvani@gmail.com> wrote:
> 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 <b.galvani@gmail.com>
> ---
>  drivers/pwm/pwm-spear.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/pwm/pwm-spear.c b/drivers/pwm/pwm-spear.c
> index cb2d4f0..945556d 100644
> --- a/drivers/pwm/pwm-spear.c
> +++ b/drivers/pwm/pwm-spear.c
> @@ -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);
>         }

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] pwm: spear: fix check on pwmchip_add() return value
  2014-05-07  6:07 ` Viresh Kumar
@ 2014-05-07  8:24   ` Thierry Reding
  2014-05-07  8:32     ` Viresh Kumar
  0 siblings, 1 reply; 6+ messages in thread
From: Thierry Reding @ 2014-05-07  8:24 UTC (permalink / raw)
  To: Viresh Kumar; +Cc: Beniamino Galvani, linux-pwm, linux-kernel@vger.kernel.org

[-- Attachment #1: Type: text/plain, Size: 1209 bytes --]

On Wed, May 07, 2014 at 11:37:25AM +0530, Viresh Kumar wrote:
> On Tue, May 6, 2014 at 2:59 AM, Beniamino Galvani <b.galvani@gmail.com> wrote:
> > 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 <b.galvani@gmail.com>
> > ---
> >  drivers/pwm/pwm-spear.c |    2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/pwm/pwm-spear.c b/drivers/pwm/pwm-spear.c
> > index cb2d4f0..945556d 100644
> > --- a/drivers/pwm/pwm-spear.c
> > +++ b/drivers/pwm/pwm-spear.c
> > @@ -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);
> >         }

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

[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] pwm: spear: fix check on pwmchip_add() return value
  2014-05-07  8:24   ` Thierry Reding
@ 2014-05-07  8:32     ` Viresh Kumar
  2014-05-07  8:49       ` Thierry Reding
  0 siblings, 1 reply; 6+ messages in thread
From: Viresh Kumar @ 2014-05-07  8:32 UTC (permalink / raw)
  To: Thierry Reding; +Cc: Beniamino Galvani, linux-pwm, linux-kernel@vger.kernel.org

On 7 May 2014 13:54, Thierry Reding <thierry.reding@gmail.com> wrote:
> 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.

> Is the device still usable after this?

Yes, this will fix the bug.

> 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+

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] pwm: spear: fix check on pwmchip_add() return value
  2014-05-07  8:32     ` Viresh Kumar
@ 2014-05-07  8:49       ` Thierry Reding
  2014-05-07  8:53         ` Viresh Kumar
  0 siblings, 1 reply; 6+ messages in thread
From: Thierry Reding @ 2014-05-07  8:49 UTC (permalink / raw)
  To: Viresh Kumar; +Cc: Beniamino Galvani, linux-pwm, linux-kernel@vger.kernel.org

[-- Attachment #1: Type: text/plain, Size: 854 bytes --]

On Wed, May 07, 2014 at 02:02:24PM +0530, Viresh Kumar wrote:
> On 7 May 2014 13:54, Thierry Reding <thierry.reding@gmail.com> wrote:
> > 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.

Hmm... so ever since this driver was merged in 3.8 it was completely
broken and nobody noticed? Interesting.

> > Is the device still usable after this?
> 
> Yes, this will fix the bug.
> 
> > 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

[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] pwm: spear: fix check on pwmchip_add() return value
  2014-05-07  8:49       ` Thierry Reding
@ 2014-05-07  8:53         ` Viresh Kumar
  0 siblings, 0 replies; 6+ messages in thread
From: Viresh Kumar @ 2014-05-07  8:53 UTC (permalink / raw)
  To: Thierry Reding; +Cc: Beniamino Galvani, linux-pwm, linux-kernel@vger.kernel.org

On 7 May 2014 14:19, Thierry Reding <thierry.reding@gmail.com> wrote:
> 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. :)

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-05-07  8:53 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-05 21:29 [PATCH] pwm: spear: fix check on pwmchip_add() return value Beniamino Galvani
2014-05-07  6:07 ` Viresh Kumar
2014-05-07  8:24   ` Thierry Reding
2014-05-07  8:32     ` Viresh Kumar
2014-05-07  8:49       ` Thierry Reding
2014-05-07  8:53         ` Viresh Kumar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).