Re: [PATCH v5 3/4] iio: adc: ad799x: cache regulator voltages during probe
From: Andy Shevchenko
Date: Mon Mar 23 2026 - 03:55:35 EST
On Sat, Mar 21, 2026 at 06:27:10PM +0000, Jonathan Cameron wrote:
> On Wed, 18 Mar 2026 14:57:14 +0530
> Archit Anant <architanant5@xxxxxxxxx> wrote:
...
> cleanest option might be;
>
> ret = devm_regulator_get_enable_read_voltage(dev, "vref");
> if (ret < 0 && ret != -ENODEV){ //get the actual error out the way first.
> return ret;
While the comment is true, I nevertheless prefer in this case (basically
regulator) to avoid double checking for ENODEV, id est...
> if (ret == -ENODEV) {
> ret = devm_regulator_get_enable_read_voltage(dev, "vcc");
> if (ret < 0)
> return ret;
>
> st->vref_uv = ret;
...put it here as
} else if (ret) {
return ret;
> } else {
> st->vref_uv = ret;
> ret = devm_regulator_get_enabled(dev, "vcc);
> if (ret)
> return ret;
> }
>
> Then no need to undo anything by hand in remove() and no need to keep
> a pointer to any regulators around for later.
--
With Best Regards,
Andy Shevchenko