Re: [PATCH] iio: light: al3010: fix incorrect scale for the highest gain range
From: Jonathan Cameron
Date: Thu Jul 02 2026 - 13:38:11 EST
On Thu, 2 Jul 2026 12:44:54 +0300
Andy Shevchenko <andriy.shevchenko@xxxxxxxxx> wrote:
> On Thu, Jul 02, 2026 at 10:59:13AM +0530, Vidhu Sarwal wrote:
> > al3010_scales[] encodes the highest gain range as {0, 1187200}.
> > For IIO_VAL_INT_PLUS_MICRO, the fractional part must be less than
> > 1000000, so the scale 1.1872 should instead be represented as
> > {1, 187200}.
> >
> > Since write_raw() compares the value from userspace against this
> > table, writing 1.1872 scale never matches the malformed
> > entry and returns -EINVAL. As a result, the highest gain range cannot
> > be selected. Reading the scale in that state also reports the malformed
> > value.
>
> Trailing spaces in the last line of the above paragraph.
>
> >
> > Fixes: c36b5195ab70 ("iio: light: add Dyna-Image AL3010 driver")
> > Signed-off-by: Vidhu Sarwal <vidhu.linux@xxxxxxxxx>
>
> ...
>
> > static const int al3010_scales[][2] = {
> > - {0, 1187200}, {0, 296800}, {0, 74200}, {0, 18600}
> > + {1, 187200}, {0, 296800}, {0, 74200}, {0, 18600}
>
> While at it, add a trailing comma.
Can we take opportunity to move to IIO (well my) preferred formatting
{ 1, 187200 }, { 0, 296800 }, { 0, 74200 }, { 0, 18600 },
Thanks,
Jonathan
>
> > };
>
> Otherwise LGTM, thanks.
>