Re: [PATCH v2 2/4] iio: adc: Add support for the Renesas RZ/N1 ADC
From: Herve Codina
Date: Mon Nov 03 2025 - 03:41:14 EST
Hi Andy,
On Thu, 30 Oct 2025 11:00:12 +0200
Andy Shevchenko <andriy.shevchenko@xxxxxxxxx> wrote:
...
>
> > + ret = devm_regulator_get_enable_optional(dev, avdd_name);
> > + if (ret < 0) {
> > + if (ret != -ENODEV)
> > + return dev_err_probe(dev, ret,
> > + "Failed to get '%s' regulator\n",
> > + avdd_name);
> > + return 0;
> > + }
>
> if (ret == -ENODEV)
> return dev_err_probe(); // takes less LoCs
> if (ret < 0) // do we need ' < 0' part?
> return 0;
>
Well, I need to abort on error returned by devm_regulator_get_enable_optional()
but I need also to filter out the ENODEV error.
ENODEV, returned by devm_regulator_get_enable_optional(), means that the
regulator is not present. This should not be seen as an error by the caller.
Indeed, the regulator is not present and so, the related ADC core will not
be used. This is not an error from the caller perspective.
The code you proposed is not correct regarding this point.
Instead of my original code, I can propose the following:
if (ret < 0) {
if (ret == -ENODEV)
return 0;
return dev_err_probe(dev, ret,
"Failed to get '%s' regulator\n",
avdd_name);
}
What do you think about it?
For other comments you have sent, I agree with them and I will take them into
account in the next iteration.
Best regards,
Hervé