Re: [PATCH v2] iio: light: ltr501: return proper error code from ltr501_get_gain_index()

From: Jonathan Cameron

Date: Sat Feb 07 2026 - 10:54:18 EST


On Tue, 3 Feb 2026 10:27:23 +0200
Andy Shevchenko <andriy.shevchenko@xxxxxxxxx> wrote:

> On Mon, Feb 02, 2026 at 02:07:12PM +0200, Antoniu Miclaus wrote:
> > Return -EINVAL instead of -1 when no matching gain value is found
> > in the gain table. Update the callers to propagate this error directly
> > rather than overwriting it with -EINVAL.
>
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxx>
>
> ...
>
> > static int ltr501_get_gain_index(const struct ltr501_gain *gain, int size,
>
> > if (val == gain[i].scale && val2 == gain[i].uscale)
> > return i;
> >
> > - return -1;
> > + return -EINVAL;
>
> I would use -ENOENT, but I'm not sure if there is any ABI involved (id est we
> return this to user space).
It will surface. Not sure anyone would notice the change, but lets
keep things simple.

Applied.

Jonathan

>
> > }
>
>