[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20260131171158.5c4b93f9@jic23-huawei>
Date: Sat, 31 Jan 2026 17:11:58 +0000
From: Jonathan Cameron <jic23@...nel.org>
To: Antoniu Miclaus <antoniu.miclaus@...log.com>
Cc: 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>,
<linux-iio@...r.kernel.org>, <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] iio: light: ltr501: return proper error code from
ltr501_get_gain_index()
On Fri, 30 Jan 2026 15:52:38 +0200
Antoniu Miclaus <antoniu.miclaus@...log.com> wrote:
> 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;
Look at how this is used. What you have here isn't wrong but I'd rather
we returned the error this function provides than overwrite -EINVAL
with -EINVAL at the caller.
> }
>
> static int __ltr501_write_raw(struct iio_dev *indio_dev,
Powered by blists - more mailing lists