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

From: Andy Shevchenko

Date: Tue Feb 03 2026 - 03:34:46 EST


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).

> }


--
With Best Regards,
Andy Shevchenko