From: Jonathan Cameron <jic23@kernel.org>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Vasileios Amoiridis <vassilisamir@gmail.com>,
lars@metafoo.de, robh@kernel.org, krzk+dt@kernel.org,
conor+dt@kernel.org, u.kleine-koenig@pengutronix.de,
linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v5 3/3] iio: chemical: bme680: add power management
Date: Sun, 8 Dec 2024 17:33:36 +0000 [thread overview]
Message-ID: <20241208173336.6a09c9b2@jic23-huawei> (raw)
In-Reply-To: <Z078vIxRoQf_zLsy@smile.fi.intel.com>
On Tue, 3 Dec 2024 14:42:36 +0200
Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:
> On Mon, Dec 02, 2024 at 09:35:50PM +0100, Vasileios Amoiridis wrote:
> > On Mon, Dec 02, 2024 at 09:43:36PM +0200, Andy Shevchenko wrote:
> > > On Mon, Dec 02, 2024 at 08:23:41PM +0100, Vasileios Amoiridis wrote:
> > > > Add runtime power management to the device.
>
> ...
>
> > > > + ret = pm_runtime_resume_and_get(dev);
> > > > + if (ret)
> > > > + return ret;
> > > > +
> > > > + ret = __bme680_read_raw(indio_dev, chan, val, val2, mask);
> > > > + pm_runtime_mark_last_busy(dev);
> > > > + pm_runtime_put_autosuspend(dev);
> > >
> > > Side note: as long as idle method is not defined (NULL) the above dance is
> > > already taken into account in the regular put.
>
> > Thanks again for the review! Indeed by looking at the code a bit, it
> > looks like the suspend callback is being called if the idle one is not
> > found. But I have seen this dance that you mention much more often in
> > the IIO that's why I used it. We can see what Jonathan has to say as
> > well, I think what you propose, simplifies things.
>
> Yeah, this is cargo cult by many people (including me :-) who missed that
> detail. If any, this can be addressed in a different series.
>
> ...
>
> > > > +static int bme680_buffer_preenable(struct iio_dev *indio_dev)
> > > > +{
> > > > + struct bme680_data *data = iio_priv(indio_dev);
> > > > + struct device *dev = regmap_get_device(data->regmap);
> > > > + int ret;
> > >
> > > > + ret = pm_runtime_resume_and_get(dev);
> > > > + if (ret)
> > > > + return ret;
> > > > +
> > > > + return 0;
> > >
> > > Either this is broken (if the above can return positive codes), or can be
> > > replaced with direct return:
> > >
> > > return pm_...
> > >
> > > (but I believe it's the former and you wanted something like if (ret < 0)
> > > there).
> > >
> > > > +}
> >
> > Well, pm_runtime_resume_and_get() looks like it returns 0 on success and
> > negative value on error so I think the if (ret) is correct, no? But I
> > agree with you that it can be simplified as you proposed.
>
> Please, go ahead with the simplification!
>
I tweaked it and applied the series to the togreg branch of iio.git and
pushed out as testing for all the normal reasons.
There was some mess because of the EXPORT_SYMBOL() macro changes this raced
against. Please sanity check I didn't mess it up.
Jonathan
next prev parent reply other threads:[~2024-12-08 17:33 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-02 19:23 [PATCH v5 0/3] iio: chemical bme680: 2nd round of cleanup Vasileios Amoiridis
2024-12-02 19:23 ` [PATCH v5 1/3] dt-bindings: iio: bosch,bme680: Move from trivial-devices and add supplies Vasileios Amoiridis
2024-12-02 19:23 ` [PATCH v5 2/3] iio: chemical: bme680: add regulators Vasileios Amoiridis
2024-12-02 19:23 ` [PATCH v5 3/3] iio: chemical: bme680: add power management Vasileios Amoiridis
2024-12-02 19:43 ` Andy Shevchenko
2024-12-02 20:35 ` Vasileios Amoiridis
2024-12-03 12:42 ` Andy Shevchenko
2024-12-08 17:33 ` Jonathan Cameron [this message]
2024-12-09 23:35 ` Vasileios Amoiridis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241208173336.6a09c9b2@jic23-huawei \
--to=jic23@kernel.org \
--cc=andriy.shevchenko@linux.intel.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=krzk+dt@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robh@kernel.org \
--cc=u.kleine-koenig@pengutronix.de \
--cc=vassilisamir@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).