Re: [PATCH v3 2/4] iio: adc: ad799x: cache regulator voltages during probe

From: Andy Shevchenko

Date: Mon Mar 02 2026 - 08:13:40 EST


On Mon, Mar 02, 2026 at 06:36:30PM +0530, Archit Anant wrote:
> Reading the regulator voltage via regulator_get_voltage() can be a slow
> operation. Since the reference voltages for this ADC are not expected to
> change at runtime, it is inefficient to query the regulator API every
> time userspace reads the IIO_CHAN_INFO_SCALE attribute.
>
> Cache the VCC and VREF voltages in the state structure during probe().
> This improves the performance of ad799x_read_raw() and removes the
> dependency on the regulator pointers during fast-path reads.

...

> + int vcc_uv;
> + int vref_uv;

_uV in both cases, please. It's a unit suffix.

...

> case IIO_CHAN_INFO_SCALE:
> if (st->vref)
> - ret = regulator_get_voltage(st->vref);
> + ret = st->vref_uv;
> else
> - ret = regulator_get_voltage(st->reg);
> + ret = st->vcc_uv;

> if (ret < 0)
> return ret;

Isn't it a dead check now?

--
With Best Regards,
Andy Shevchenko