Re: [PATCH RFC] iio: adc: ad4030: fix calibscale read/write unit mismatch

From: Jonathan Cameron

Date: Sat Feb 28 2026 - 11:28:30 EST


On Thu, 26 Feb 2026 09:32:45 +0000
Nuno Sá <noname.nuno@xxxxxxxxx> wrote:

> On Wed, 2026-02-25 at 09:20 -0600, David Lechner wrote:
> > On 2/25/26 5:53 AM, Marcelo Schmitt wrote:
> > > On 02/25, Giorgi Tchankvetadze wrote:
> > > > The read path returns calibscale in IIO_VAL_INT_PLUS_NANO but the write
> > > > path treats it as MICRO. Since no write_raw_get_fmt is provided, the
> > > > IIO core defaults to MICRO when parsing userspace input.
> > > >
> > > > This means reading calibscale and writing it back results in a ~1000x
> > > > gain error.
> > > >
> > > > Change the read path and available range to use MICRO to match the
> > > > write path.
> > >
> > > The updates to ad4030 driver will add write_raw_get_fmt() [1].
> > > [1]:
> > > https://lore.kernel.org/linux-iio/516cccc47e917bd26be29b016907f50a244a68b9.1771865684.git.marcelo.schmitt@xxxxxxxxxx/
> > >
> > > At first glance, I think this could instead add a case to write_raw_get_fmt(),
> > > keeping calibscale nano precision (unless nano precision doesn't make sense
> > > for ad4030 calibscale (don't recall from top of my mind)).
> >
> > Since this is a fix and needs to be backported, it probably make sense
> > to not depend on a patch that is adding new features.
> >
>
> +1
>
> - Nuno Sá
>
> > I'm sure Jonathan will have an opinion about how he would like to handle
> > a conflict between the fixes and testing branches though.

Fixes in theory always go first. That'll mean I end up holding the
other series back if this one is ready in the near future.

I'm not sure I fully understand the bug though!

Jonathan