From: Jonathan Cameron <jic23@kernel.org>
To: David Lechner <dlechner@baylibre.com>
Cc: Jonathan Corbet <corbet@lwn.net>,
Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>, Jean Delvare <jdelvare@suse.com>,
Guenter Roeck <linux@roeck-us.net>,
Support Opensource <support.opensource@diasemi.com>,
Cosmin Tanislav <cosmin.tanislav@analog.com>,
Lars-Peter Clausen <lars@metafoo.de>,
Michael Hennerich <Michael.Hennerich@analog.com>,
Antoniu Miclaus <antoniu.miclaus@analog.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Dmitry Torokhov <dmitry.torokhov@gmail.com>,
linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-hwmon@vger.kernel.org, linux-iio@vger.kernel.org,
linux-staging@lists.linux.dev, linux-input@vger.kernel.org
Subject: Re: [PATCH RFC 4/7] iio: addac: ad74115: Use devm_regulator_get_enable_get_voltage()
Date: Thu, 28 Mar 2024 13:58:08 +0000 [thread overview]
Message-ID: <20240328135808.7aff4fb5@jic23-huawei> (raw)
In-Reply-To: <20240327-regulator-get-enable-get-votlage-v1-4-5f4517faa059@baylibre.com>
On Wed, 27 Mar 2024 18:18:53 -0500
David Lechner <dlechner@baylibre.com> wrote:
> We can reduce boilerplate code by using
> devm_regulator_get_enable_get_voltage().
There is a change in behaviour in this one. I'd like some
explanation in the patch title for why it is always safe to get
the voltage of avdd_mv when previously it wasn't.
There seems to me to be a corner case where a DTS is not providing
the entry because it's always powered on so we get a stub regulator
but that doesn't matter because we aren't in DIN_THRESHOLD_MOD_AVDD.
After this change that dts is broken as now we read the voltage
whatever.
You could use the optional form and then fail the probe if
in a mode where the value will be used?
>
> Signed-off-by: David Lechner <dlechner@baylibre.com>
> ---
> drivers/iio/addac/ad74115.c | 28 +++-------------------------
> 1 file changed, 3 insertions(+), 25 deletions(-)
>
> diff --git a/drivers/iio/addac/ad74115.c b/drivers/iio/addac/ad74115.c
> index e6bc5eb3788d..01073d7de6aa 100644
> --- a/drivers/iio/addac/ad74115.c
> +++ b/drivers/iio/addac/ad74115.c
> @@ -199,7 +199,6 @@ struct ad74115_state {
> struct spi_device *spi;
> struct regmap *regmap;
> struct iio_trigger *trig;
> - struct regulator *avdd;
>
> /*
> * Synchronize consecutive operations when doing a one-shot
> @@ -1672,14 +1671,6 @@ static int ad74115_setup(struct iio_dev *indio_dev)
> if (ret)
> return ret;
>
> - if (val == AD74115_DIN_THRESHOLD_MODE_AVDD) {
> - ret = regulator_get_voltage(st->avdd);
> - if (ret < 0)
> - return ret;
> -
> - st->avdd_mv = ret / 1000;
> - }
> -
> st->din_threshold_mode = val;
>
> ret = ad74115_apply_fw_prop(st, &ad74115_dac_bipolar_fw_prop, &val);
> @@ -1788,11 +1779,6 @@ static int ad74115_reset(struct ad74115_state *st)
> return 0;
> }
>
> -static void ad74115_regulator_disable(void *data)
> -{
> - regulator_disable(data);
> -}
> -
> static int ad74115_setup_trigger(struct iio_dev *indio_dev)
> {
> struct ad74115_state *st = iio_priv(indio_dev);
> @@ -1855,19 +1841,11 @@ static int ad74115_probe(struct spi_device *spi)
> indio_dev->modes = INDIO_DIRECT_MODE;
> indio_dev->info = &ad74115_info;
>
> - st->avdd = devm_regulator_get(dev, "avdd");
> - if (IS_ERR(st->avdd))
> - return PTR_ERR(st->avdd);
> -
> - ret = regulator_enable(st->avdd);
> - if (ret) {
> - dev_err(dev, "Failed to enable avdd regulator\n");
> + ret = devm_regulator_get_enable_get_voltage(dev, "avdd");
> + if (ret < 0)
> return ret;
> - }
>
> - ret = devm_add_action_or_reset(dev, ad74115_regulator_disable, st->avdd);
> - if (ret)
> - return ret;
> + st->avdd_mv = ret / 1000;
>
> ret = devm_regulator_bulk_get_enable(dev, ARRAY_SIZE(regulator_names),
> regulator_names);
>
next prev parent reply other threads:[~2024-03-28 13:58 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-27 23:18 [PATCH RFC 0/7] regulator: new APIs for voltage reference supplies David Lechner
2024-03-27 23:18 ` [PATCH RFC 1/7] regulator: devres: add APIs for " David Lechner
2024-03-28 13:47 ` Jonathan Cameron
2024-03-28 15:54 ` David Lechner
2024-03-28 18:03 ` Dmitry Torokhov
2024-03-28 18:18 ` Mark Brown
2024-03-28 20:17 ` Dmitry Torokhov
2024-03-28 20:25 ` Mark Brown
2024-03-30 16:02 ` Jonathan Cameron
2024-03-27 23:18 ` [PATCH RFC 2/7] hwmon: (adc128d818) Use devm_regulator_get_optional_enable_get_voltage() David Lechner
2024-03-28 14:05 ` Jonathan Cameron
2024-03-27 23:18 ` [PATCH RFC 3/7] hwmon: (da9052) Use devm_regulator_get_enable_get_voltage() David Lechner
2024-03-28 14:20 ` Jonathan Cameron
2024-03-28 15:20 ` Guenter Roeck
2024-03-28 15:53 ` Jonathan Cameron
2024-03-27 23:18 ` [PATCH RFC 4/7] iio: addac: ad74115: " David Lechner
2024-03-28 13:58 ` Jonathan Cameron [this message]
2024-03-27 23:18 ` [PATCH RFC 5/7] iio: frequency: admv1013: " David Lechner
2024-03-28 13:51 ` Jonathan Cameron
2024-03-27 23:18 ` [PATCH RFC 6/7] staging: iio: impedance-analyzer: " David Lechner
2024-03-28 13:50 ` Jonathan Cameron
2024-03-27 23:18 ` [PATCH RFC 7/7] Input: mpr121: " David Lechner
2024-03-28 14:21 ` Jonathan Cameron
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=20240328135808.7aff4fb5@jic23-huawei \
--to=jic23@kernel.org \
--cc=Michael.Hennerich@analog.com \
--cc=antoniu.miclaus@analog.com \
--cc=broonie@kernel.org \
--cc=corbet@lwn.net \
--cc=cosmin.tanislav@analog.com \
--cc=dlechner@baylibre.com \
--cc=dmitry.torokhov@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=jdelvare@suse.com \
--cc=lars@metafoo.de \
--cc=lgirdwood@gmail.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=linux@roeck-us.net \
--cc=support.opensource@diasemi.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).