Re: [PATCH v4 2/4] iio: adc: ltc2378: Add support for LTC2378-20 and similar ADCs

From: Andy Shevchenko

Date: Mon Jun 29 2026 - 12:20:34 EST


On Mon, Jun 29, 2026 at 10:16:16AM -0500, David Lechner wrote:
> On 6/29/26 9:57 AM, Marcelo Schmitt wrote:

...

> It could use `_offl ? ...` in the macro for that. Not a big deal to me though.

Personally I am for a full spelling here.

...

> >>> +static int ltc2378_regulator_setup(struct device *dev, struct ltc2378_state *st)
> >>> +{
> >>> + int ret;
> >>> +
> >>> + ret = devm_regulator_get_enable_read_voltage(dev, "refin");
> >>> + if (ret < 0 && ret != -ENODEV) {
> >>> + return dev_err_probe(dev, ret, "failed to read refin regulator\n");
> >>> + } else if (ret > 0) {
> >>
> >> Else is not needed here.
> > Why not?
>
> The if returns unconditionally, so else is not needed. This is just a general
> principal.

Unfortunately in this case ENODEV will go further, I don't see full context,
but it may lead to something unexpected.

Personally I prefer the ladder of

if (ret == -ENODEV)
...
else if (ret < 0)
...
else
...

--
With Best Regards,
Andy Shevchenko