[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20260130135241.137353-1-antoniu.miclaus@analog.com>
Date: Fri, 30 Jan 2026 15:52:38 +0200
From: Antoniu Miclaus <antoniu.miclaus@...log.com>
To: Jonathan Cameron <jic23@...nel.org>,
David Lechner
<dlechner@...libre.com>,
Nuno Sá <nuno.sa@...log.com>,
Andy Shevchenko <andy@...nel.org>,
Waqar Hameed <waqar.hameed@...s.com>,
chuguangqing <chuguangqing@...pur.com>,
Antoniu Miclaus
<antoniu.miclaus@...log.com>,
<linux-iio@...r.kernel.org>, <linux-kernel@...r.kernel.org>
Subject: [PATCH] iio: light: ltr501: return proper error code from ltr501_get_gain_index()
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@...log.com>
---
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
Powered by blists - more mailing lists