Re: [PATCH v2 3/6] iio: adc: ti-ads1298: fix scale, ID check, regmap and Kconfig
From: Jonathan Cameron
Date: Sun Oct 25 2026 - 19:12:54 EST
On Sat, 24 Oct 2026 20:13:32 -0300
Stephan Costa Barros <stephanbrrs8@xxxxxxxxx> wrote:
> Fix four smaller issues:
>
> - The scale divides the reference, in whole millivolts, by the gain
> before it is reported. With the internal 4 V reference, it is 0.099 %
> low at gain 6, 0.101 % at gain 12 and 0.025 % at gain 3. Report
> VREF / (gain * 2^23) as an IIO_VAL_FRACTIONAL; sysfs still shows it
> with nine decimals, now without the error.
Move this to end of the fixes. An accuracy improvement is nice to have
but not necessarily something anyone will backport if the previous driver
is working well enough for them. As with prior set, separate patch
per fix.
I appreciate that will mean a lot of patches, but they will each
be simpler to review.
>
> - Only the channel codes 0, 1 and 2 of the ID register are defined; an
> ID of 0x93, for example, gives 10 channels. The IIO core then reads
> past ads1298_channels, and the RDATA transfer writes past rx_buffer.
> Refuse the reserved codes as an unknown ID.
No problem with this, but it is hardening against devices we have
never seen. So after fixes and marked as hardening. We should never
have a fallback compatible issue on this, because they shouldn't
be using larger numbers of channels.
>
> - The driver uses regmap but does not select REGMAP, and fails to build
> where nothing else selects it, such as tinyconfig with SPI, IIO and
> TI_ADS1298 on x86_64.
Interesting we never saw this in random builds. Indeed good to fix
but has nothing to do with the rest of this patch.
>
> - Bit 0 of CONFIG3 is a read-only status bit and the GPIO register
> reads the pins, but both are cached, so a read through debugfs returns
> a stale value; debugfs can also write ID, LOFF_STATP and LOFF_STATN.
> Mark CONFIG3 and GPIO volatile, and the other three not writeable.
I don't really care about stale data in debugfs. By all means fix
this but it isn't something we'd bother backporting.
>
> The ID check was found by review and reproduced on an emulated device
> only, where KASAN reports the read past ads1298_channels.
>
> Fixes: 00ef7708fa60 ("iio: adc: ti-ads1298: Add driver")
> Signed-off-by: Stephan Costa Barros <stephanbrrs8@xxxxxxxxx>