Re: [PATCH v4 2/4] iio: adc: ad799x: cache regulator voltage during probe

From: Andy Shevchenko

Date: Sun Mar 08 2026 - 17:13:07 EST


On Sun, Mar 08, 2026 at 11:58:09PM +0530, Archit Anant wrote:
> Reading the regulator voltage via regulator_get_voltage() can be a slow
> operation. Since the reference voltage for this ADC is not expected to
> change at runtime, it is inefficient to query the regulator API every
> time userspace reads the IIO_CHAN_INFO_SCALE attribute.
>
> Determine the active reference voltage (either VREF or VCC) during
> probe() and cache it in a single variable in the state structure.
> This improves the performance of ad799x_read_raw(), removes the
> dependency on the regulator pointers during fast-path reads, and
> allows the removal of a redundant negative-value check.

...

> + *val = st->vref_uV / 1000;

Perhaps "(MICRO / MILLI)" instead of "1000" until we have a dedicate constant?

--
With Best Regards,
Andy Shevchenko