Re: [PATCH 2/3] pwm: renesas-tpu: Fix late Runtime PM enablement

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Geert,

Thank you for the patch.

On Mon, Mar 16, 2020 at 05:01:08PM +0100, Uwe Kleine-König wrote:
> On Mon, Mar 16, 2020 at 11:32:15AM +0100, Geert Uytterhoeven wrote:
> > Runtime PM should be enabled before calling pwmchip_add(), as PWM users
> > can appear immediately after the PWM chip has been added.
> > Likewise, Runtime PM should always be disabled after the removal of the
> > PWM chip, even if the latter failed.
> > Fixes: 99b82abb0a35b073 ("pwm: Add Renesas TPU PWM driver")
> > Signed-off-by: Geert Uytterhoeven <geert+renesas@xxxxxxxxx>
> > ---
> >  drivers/pwm/pwm-renesas-tpu.c | 9 ++++-----
> >  1 file changed, 4 insertions(+), 5 deletions(-)
> > 
> > diff --git a/drivers/pwm/pwm-renesas-tpu.c b/drivers/pwm/pwm-renesas-tpu.c
> > index 4a855a21b782dea3..8032acc84161a9dd 100644
> > --- a/drivers/pwm/pwm-renesas-tpu.c
> > +++ b/drivers/pwm/pwm-renesas-tpu.c
> > @@ -415,16 +415,17 @@ static int tpu_probe(struct platform_device *pdev)
> >  	tpu->chip.base = -1;
> >  	tpu->chip.npwm = TPU_CHANNEL_MAX;
> >  
> > +	pm_runtime_enable(&pdev->dev);
> > +
> >  	ret = pwmchip_add(&tpu->chip);
> >  	if (ret < 0) {
> >  		dev_err(&pdev->dev, "failed to register PWM chip\n");
> > +		pm_runtime_disable(&pdev->dev);
> >  		return ret;
> >  	}
> >  
> >  	dev_info(&pdev->dev, "TPU PWM %d registered\n", tpu->pdev->id);
> >  
> > -	pm_runtime_enable(&pdev->dev);
> > -
> >  	return 0;
> >  }

This part looks good to me.

> >  
> > @@ -434,12 +435,10 @@ static int tpu_remove(struct platform_device *pdev)
> >  	int ret;
> >  
> >  	ret = pwmchip_remove(&tpu->chip);
> > -	if (ret)
> > -		return ret;
> >  
> >  	pm_runtime_disable(&pdev->dev);
> >  
> > -	return 0;
> > +	return ret;
> >  }
> 
> Maybe I was a bit quick with my reply to the previous patch. I wonder if
> it is right to call pm_runtime_disable if pwmchip_remove failed?

It should at least be explained in the commit message why this is the
right thing to do.

-- 
Regards,

Laurent Pinchart



[Index of Archives]     [Linux Samsung SOC]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux