[PATCH v2 02/12] iio: adc: Remove redundant pm_runtime_mark_last_busy() calls
Sakari Ailus
sakari.ailus at linux.intel.com
Mon Aug 25 04:57:23 PDT 2025
Hi Jonathan,
Thanks for the review.
On Wed, Jul 09, 2025 at 04:37:56PM +0100, Jonathan Cameron wrote:
> On Wed, 9 Jul 2025 02:11:52 +0300
> Sakari Ailus <sakari.ailus at linux.intel.com> wrote:
>
> > pm_runtime_put_autosuspend(), pm_runtime_put_sync_autosuspend(),
> > pm_runtime_autosuspend() and pm_request_autosuspend() now include a call
> > to pm_runtime_mark_last_busy(). Remove the now-reduntant explicit call to
> > pm_runtime_mark_last_busy().
> >
> > Signed-off-by: Sakari Ailus <sakari.ailus at linux.intel.com>
> > Reviewed-by: Linus Walleij <linus.walleij at linaro.org>
>
> Some comments for the future as more about what can be improved on the back
> of this than what you have here.
>
> >
> > diff --git a/drivers/iio/adc/rcar-gyroadc.c b/drivers/iio/adc/rcar-gyroadc.c
> > index cc326f21d398..3a17b3898bf6 100644
> > --- a/drivers/iio/adc/rcar-gyroadc.c
> > +++ b/drivers/iio/adc/rcar-gyroadc.c
> > @@ -163,12 +163,10 @@ static int rcar_gyroadc_set_power(struct rcar_gyroadc *priv, bool on)
> > {
> > struct device *dev = priv->dev;
> >
> This is a very clear example of where the *_set_power() pattern is a bad idea.
> There are two calls of this function, one with it hard coded as on and one with it
> hard coded as off. We can just push the pm_runtime_resume_and_get()
> to the on case etc.
>
> I don't mind that much if we do so as a follow up patch so this one can
> be the mechanical change and then we follow up with the enabled simplification.
Ack. I presume this pattern is due to one driver having used it first and
then other drivers copying that. I haven't seen it elsewhere, or at least
not being used as widely.
>
> > - if (on) {
> > + if (on)
> > return pm_runtime_resume_and_get(dev);
> > - } else {
> > - pm_runtime_mark_last_busy(dev);
> > - return pm_runtime_put_autosuspend(dev);
> > - }
> > +
> > + return pm_runtime_put_autosuspend(dev);
> > }
> >
> > static int rcar_gyroadc_read_raw(struct iio_dev *indio_dev,
> >> diff --git a/drivers/iio/adc/ti-ads1015.c b/drivers/iio/adc/ti-ads1015.c
> > index 48549d617e5f..f2a93c63ca14 100644
> > --- a/drivers/iio/adc/ti-ads1015.c
> > +++ b/drivers/iio/adc/ti-ads1015.c
> > @@ -374,12 +374,10 @@ static int ads1015_set_power_state(struct ads1015_data *data, bool on)
> > int ret;
> > struct device *dev = regmap_get_device(data->regmap);
> >
> > - if (on) {
> > + if (on)
> > ret = pm_runtime_resume_and_get(dev);
> > - } else {
> > - pm_runtime_mark_last_busy(dev);
> > + else
> > ret = pm_runtime_put_autosuspend(dev);
> > - }
> >
> > return ret < 0 ? ret : 0;
> So this one has a stub version which only brings benefits because
> we have checks on the pm_runtime_put_autosuspend() path failing
> (which it does if we have !CONFIG_PM).
>
> I think the right option there is check the return value is < 0
> for the resume_and_get() and don't check the _put_autosuspend()
> return value at all. Then we can just push this down to the
> call sites as all of them hard code the bool value.
Ack.
--
Regards,
Sakari Ailus
More information about the linux-arm-kernel
mailing list