From: Jonathan Cameron <jic23@kernel.org>
To: Lars-Peter Clausen <lars@metafoo.de>
Cc: Mike Looijmans <mike.looijmans@topic.nl>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
devicetree@vger.kernel.org, linux-iio@vger.kernel.org,
Caleb Connolly <caleb.connolly@linaro.org>,
ChiYuan Huang <cy_huang@richtek.com>,
ChiaEn Wu <chiaen_wu@richtek.com>,
Cosmin Tanislav <demonsingur@gmail.com>,
Ibrahim Tilki <Ibrahim.Tilki@analog.com>,
Ramona Bolboaca <ramona.bolboaca@analog.com>,
William Breathitt Gray <william.gray@linaro.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 2/2] iio: adc: Add TI ADS1100 and ADS1000
Date: Sat, 4 Mar 2023 17:19:50 +0000 [thread overview]
Message-ID: <20230304171950.5a411037@jic23-huawei> (raw)
In-Reply-To: <b635b91e-1dcc-71ba-95d1-1f87a20dbaf2@metafoo.de>
On Thu, 2 Mar 2023 05:20:38 -0800
Lars-Peter Clausen <lars@metafoo.de> wrote:
> On 3/2/23 05:16, Lars-Peter Clausen wrote:
> > On 3/1/23 23:49, Mike Looijmans wrote:
> >>
> >>
> >>> ...
> >>> ...
> >>>
> >>>> +static int ads1100_runtime_suspend(struct device *dev)
> >>>> +{
> >>>> + struct iio_dev *indio_dev =
> >>>> i2c_get_clientdata(to_i2c_client(dev));
> >>>> + struct ads1100_data *data = iio_priv(indio_dev);
> >>>> +
> >>>> + ads1100_set_config_bits(data, ADS1100_CFG_SC,
> >>>> ADS1100_SINGLESHOT);
> >>>> + regulator_disable(data->reg_vdd);
> >>> Wrong devm / non-devm ordering.
> >>
> >> Don't understand your remark, can you explain further please?
> >>
> >> devm / non-devm ordering would be related to the "probe" function. As
> >> far as I can tell, I'm not allocating resources after the devm calls.
> >> And the "remove" is empty.
> >
> > Strictly speaking we need to unregister the IIO device before
> > disabling the regulator, otherwise there is a small window where the
> > IIO device still exists, but doesn't work anymore. This is a very
> > theoretical scenario though.
> >
> > You are lucky :) There is a new function
> > `devm_regulator_get_enable()`[1], which will manage the
> > regulator_disable() for you. Using that will also reduce the
> > boilerplate in `probe()` a bit
> >
> > - Lars
> >
> > [1] https://lwn.net/Articles/904383/
> >
> Sorry, just saw that Andy's comment was on the suspend() function, not
> remove(). In that case there is of course no need for any devm things.
> But still a good idea to use `devm_regulator_get_enable()` in probe for
> the boiler plate.
>
You can't because (annoyingly) devem_regulator_get_enable() doesn't
provide you access to the struct regulator that you need to be able
to turn it of for power management.
That case only works for the leave the power on all the time cases.
Jonathan
next prev parent reply other threads:[~2023-03-04 17:20 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-28 6:31 [PATCH v3 1/2] dt-bindings: iio: adc: Add TI ADS1100 and ADS1000 Mike Looijmans
2023-02-28 6:31 ` [PATCH v3 2/2] " Mike Looijmans
2023-03-01 15:30 ` Andy Shevchenko
[not found] ` <1b153bce-a66a-45ee-a5c6-963ea6fb1c82.949ef384-8293-46b8-903f-40a477c056ae.0685d97e-4a28-499e-a9e3-3bafec126832@emailsignatures365.codetwo.com>
2023-03-02 7:49 ` Mike Looijmans
2023-03-02 13:16 ` Lars-Peter Clausen
2023-03-02 13:20 ` Lars-Peter Clausen
2023-03-02 14:24 ` Andy Shevchenko
2023-03-04 17:19 ` Jonathan Cameron [this message]
2023-03-02 14:23 ` Andy Shevchenko
2023-03-04 17:26 ` Jonathan Cameron
2023-03-06 12:09 ` Andy Shevchenko
2023-03-04 17:57 ` Jonathan Cameron
[not found] ` <1b153bce-a66a-45ee-a5c6-963ea6fb1c82.949ef384-8293-46b8-903f-40a477c056ae.1e5d3371-10e4-4627-b16c-6b250afbb522@emailsignatures365.codetwo.com>
2023-03-06 6:31 ` Mike Looijmans
[not found] ` <1b153bce-a66a-45ee-a5c6-963ea6fb1c82.949ef384-8293-46b8-903f-40a477c056ae.c6259f01-fccb-4a0c-a50a-69f2dcd4ea5b@emailsignatures365.codetwo.com>
2023-03-06 11:21 ` Mike Looijmans
2023-03-12 14:53 ` Jonathan Cameron
2023-03-06 12:11 ` Andy Shevchenko
2023-03-06 12:16 ` Andy Shevchenko
2023-03-06 12:20 ` Andy Shevchenko
[not found] ` <1b153bce-a66a-45ee-a5c6-963ea6fb1c82.949ef384-8293-46b8-903f-40a477c056ae.be34025c-a863-4735-b566-67fda50f37f8@emailsignatures365.codetwo.com>
2023-03-06 12:56 ` Mike Looijmans
2023-03-06 13:19 ` Andy Shevchenko
2023-02-28 10:34 ` [PATCH v3 1/2] dt-bindings: " Krzysztof Kozlowski
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=20230304171950.5a411037@jic23-huawei \
--to=jic23@kernel.org \
--cc=Ibrahim.Tilki@analog.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=caleb.connolly@linaro.org \
--cc=chiaen_wu@richtek.com \
--cc=cy_huang@richtek.com \
--cc=demonsingur@gmail.com \
--cc=devicetree@vger.kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mike.looijmans@topic.nl \
--cc=ramona.bolboaca@analog.com \
--cc=william.gray@linaro.org \
/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).