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

From: Antoniu Miclaus

Date: Fri Jan 30 2026 - 08:53:17 EST


Return -EINVAL instead of -1 when no matching gain value is found
in the gain table. Using standard kernel error codes ensures
consistency and proper error handling.

Signed-off-by: Antoniu Miclaus <antoniu.miclaus@xxxxxxxxxx>
---
drivers/iio/light/ltr501.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/light/ltr501.c b/drivers/iio/light/ltr501.c
index 022e0693983b..29e93986dea6 100644
--- a/drivers/iio/light/ltr501.c
+++ b/drivers/iio/light/ltr501.c
@@ -754,7 +754,7 @@ 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;
}

static int __ltr501_write_raw(struct iio_dev *indio_dev,
--
2.43.0