From: andy.shevchenko@gmail.com
To: fl.scratchpad@gmail.com
Cc: jic23@kernel.org, Lars-Peter Clausen <lars@metafoo.de>,
Michael Hennerich <Michael.Hennerich@analog.com>,
Alexandru Tachici <alexandru.tachici@analog.com>,
Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
Jonathan Cameron <Jonathan.Cameron@huawei.com>
Subject: Re: [PATCH v3 3/5] iio: adc: ad7192: Use VRef instead of AVdd as reference voltage source
Date: Sat, 3 Jun 2023 15:03:25 +0300 [thread overview]
Message-ID: <ZHssDS57yx46RvFA@surfacebook> (raw)
In-Reply-To: <20230530075311.400686-4-fl.scratchpad@gmail.com>
Tue, May 30, 2023 at 09:53:09AM +0200, fl.scratchpad@gmail.com kirjoitti:
> From: Fabrizio Lamarque <fl.scratchpad@gmail.com>
>
> Add missing vref-supply and fix avdd-supply used as if it were vref.
>
> AD7192 requires three independent voltage sources, digital supply (on
> pin DVdd), analog supply (on AVdd) and reference voltage (VRef on
> alternate pin pair REFIN1 or REFIN2).
>
> Emit a warning message when AVdd is used in place of VRef for backwards
> compatibility.
...
> + st->vref = devm_regulator_get_optional(&spi->dev, "vref");
> + if (!IS_ERR(st->vref)) {
> + ret = regulator_enable(st->vref);
> + if (ret)
> + return dev_err_probe(&spi->dev, ret,
> + "Failed to enable specified VRef supply\n");
> +
> + ret = devm_add_action_or_reset(&spi->dev, ad7192_reg_disable, st->vref);
> + if (ret)
> + return ret;
> + } else if (PTR_ERR(st->vref) != -ENODEV) {
> + return PTR_ERR(st->vref);
> + }
Wouldn't this be better?
if (IS_ERR(st->vref)) {
if (PTR_ERR(st->vref) != -ENODEV)
return PTR_ERR(st->vref);
} else {
...
> if (ret)
> return dev_err_probe(&spi->dev, ret, "Failed to enable specified DVdd supply\n");
>
> - ret = regulator_get_voltage(st->avdd);
> +
One blank line is enough.
> + if (!IS_ERR(st->vref)) {
> + ret = regulator_get_voltage(st->vref);
Why negative conditional? Usual pattern is to check for errors first, so
if (IS_ERR(st->vref)) {
dev_warn(...);
...
} else {
ret = regulator_get_voltage(st->vref);
}
> + } else {
> + dev_warn(&spi->dev, "Using AVdd in place of VRef. Likely an old DTS\n");
> + ret = regulator_get_voltage(st->avdd);
> + }
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2023-06-03 12:03 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-30 7:53 [PATCH v3 0/5] Fix ad7192 driver issues fl.scratchpad
2023-05-30 7:53 ` [PATCH v3 1/5] iio: adc: ad7192: Fix null ad7192_state pointer access fl.scratchpad
2023-06-04 11:32 ` Jonathan Cameron
2023-05-30 7:53 ` [PATCH v3 2/5] iio: adc: ad7192: Fix internal/external clock selection fl.scratchpad
2023-06-04 11:33 ` Jonathan Cameron
2023-05-30 7:53 ` [PATCH v3 3/5] iio: adc: ad7192: Use VRef instead of AVdd as reference voltage source fl.scratchpad
2023-06-03 12:03 ` andy.shevchenko [this message]
2023-05-30 7:53 ` [PATCH v3 4/5] dt-bindings: iio: ad7192: Add mandatory " fl.scratchpad
2023-05-30 17:22 ` Conor Dooley
2023-06-04 11:35 ` Jonathan Cameron
2023-05-30 7:53 ` [PATCH v3 5/5] dt-bindings: iio: ad7192: Allow selection of clock modes fl.scratchpad
2023-05-30 17:22 ` Conor Dooley
2023-05-31 6:59 ` Fabrizio Lamarque
2023-05-31 7:14 ` Krzysztof Kozlowski
2023-05-31 9:40 ` Fabrizio Lamarque
2023-05-31 12:56 ` Conor Dooley
[not found] ` <01dae949-4018-37f4-2dd9-cbecbd65b9a1@linaro.org>
2023-06-07 7:40 ` Fabrizio Lamarque
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=ZHssDS57yx46RvFA@surfacebook \
--to=andy.shevchenko@gmail.com \
--cc=Jonathan.Cameron@huawei.com \
--cc=Michael.Hennerich@analog.com \
--cc=alexandru.tachici@analog.com \
--cc=broonie@kernel.org \
--cc=fl.scratchpad@gmail.com \
--cc=jic23@kernel.org \
--cc=lars@metafoo.de \
--cc=lgirdwood@gmail.com \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.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