From: "Nuno Sá" <noname.nuno@gmail.com>
To: David Lechner <dlechner@baylibre.com>,
Jonathan Cameron <jic23@kernel.org>
Cc: "Marcelo Schmitt" <marcelo.schmitt1@gmail.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Michael Hennerich" <Michael.Hennerich@analog.com>,
"Mark Brown" <broonie@kernel.org>,
"Liam Girdwood" <lgirdwood@gmail.com>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/5] iio: adc: ad7266: use devm_regulator_get_enable_read_voltage
Date: Wed, 05 Jun 2024 11:33:57 +0200 [thread overview]
Message-ID: <aac3acb3f02642fd9aa0ec922f7b02bb9f32435a.camel@gmail.com> (raw)
In-Reply-To: <57a60f5c-a989-4187-ab4f-1f6a15578578@baylibre.com>
On Tue, 2024-06-04 at 09:10 -0500, David Lechner wrote:
> On 6/4/24 6:19 AM, Nuno Sá wrote:
> > On Fri, 2024-05-31 at 16:19 -0500, David Lechner wrote:
> > > This makes use of the new devm_regulator_get_enable_read_voltage()
> > > function to reduce boilerplate code.
> > >
> > > Signed-off-by: David Lechner <dlechner@baylibre.com>
> > > ---
> > > drivers/iio/adc/ad7266.c | 37 ++++++++++---------------------------
> > > 1 file changed, 10 insertions(+), 27 deletions(-)
> > >
> > > diff --git a/drivers/iio/adc/ad7266.c b/drivers/iio/adc/ad7266.c
> > > index 353a97f9c086..026db1bedc0a 100644
> > > --- a/drivers/iio/adc/ad7266.c
> > > +++ b/drivers/iio/adc/ad7266.c
> > > @@ -25,7 +25,6 @@
> > >
> > > struct ad7266_state {
> > > struct spi_device *spi;
> > > - struct regulator *reg;
> > > unsigned long vref_mv;
> > >
> > > struct spi_transfer single_xfer[3];
> > > @@ -377,11 +376,6 @@ static const char * const ad7266_gpio_labels[] = {
> > > "ad0", "ad1", "ad2",
> > > };
> > >
> > > -static void ad7266_reg_disable(void *reg)
> > > -{
> > > - regulator_disable(reg);
> > > -}
> > > -
> > > static int ad7266_probe(struct spi_device *spi)
> > > {
> > > struct ad7266_platform_data *pdata = spi->dev.platform_data;
> > > @@ -396,28 +390,17 @@ static int ad7266_probe(struct spi_device *spi)
> > >
> > > st = iio_priv(indio_dev);
> > >
> > > - st->reg = devm_regulator_get_optional(&spi->dev, "vref");
> > > - if (!IS_ERR(st->reg)) {
> > > - ret = regulator_enable(st->reg);
> > > - if (ret)
> > > - return ret;
> > > -
> > > - ret = devm_add_action_or_reset(&spi->dev,
> > > ad7266_reg_disable, st-
> > > > reg);
> > > - if (ret)
> > > - return ret;
> > > -
> > > - ret = regulator_get_voltage(st->reg);
> > > - if (ret < 0)
> > > - return ret;
> > > -
> > > - st->vref_mv = ret / 1000;
> > > - } else {
> > > - /* Any other error indicates that the regulator does
> > > exist */
> > > - if (PTR_ERR(st->reg) != -ENODEV)
> > > - return PTR_ERR(st->reg);
> > > - /* Use internal reference */
> > > + /*
> > > + * Use external reference from vref if present, otherwise use
> > > 2.5V
> > > + * internal reference.
> > > + */
> >
> > Not sure the comment brings any added value. The code is fairly self
> > explanatory
> > IMO...
>
> Well, you do this every day. :-)
I guess... still not an excuse :)
>
> For someone who never wrote an IIO driver, it could be helpful.
Still dunno but no strong feelings anyways...
- Nuno Sá
next prev parent reply other threads:[~2024-06-05 9:30 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-31 21:19 [PATCH 0/5] iio: adc: use devm_regulator_get_enable_read_voltage round 1 David Lechner
2024-05-31 21:19 ` [PATCH 1/5] iio: adc: ad7192: use devm_regulator_get_enable_read_voltage David Lechner
2024-06-01 12:48 ` Jonathan Cameron
2024-06-03 13:36 ` David Lechner
2024-06-03 20:10 ` Jonathan Cameron
2024-05-31 21:19 ` [PATCH 2/5] iio: adc: ad7266: " David Lechner
2024-06-04 11:19 ` Nuno Sá
2024-06-04 14:10 ` David Lechner
2024-06-05 9:33 ` Nuno Sá [this message]
2024-05-31 21:19 ` [PATCH 3/5] iio: adc: ad7292: " David Lechner
2024-06-08 4:28 ` Marcelo Schmitt
2024-05-31 21:19 ` [PATCH 4/5] iio: adc: ad7793: " David Lechner
2024-05-31 21:19 ` [PATCH 5/5] iio: adc: ad7944: " David Lechner
2024-06-01 13:01 ` Jonathan Cameron
2024-06-03 13:38 ` David Lechner
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=aac3acb3f02642fd9aa0ec922f7b02bb9f32435a.camel@gmail.com \
--to=noname.nuno@gmail.com \
--cc=Michael.Hennerich@analog.com \
--cc=broonie@kernel.org \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marcelo.schmitt1@gmail.com \
--cc=nuno.sa@analog.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