mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Antoniu Miclaus <antoniu.miclaus@analog.com>
Cc: "David Lechner" <dlechner@baylibre.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	"Waqar Hameed" <waqar.hameed@axis.com>,
	chuguangqing <chuguangqing@inspur.com>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] iio: light: ltr501: return proper error code from ltr501_get_gain_index()
Date: Sat, 31 Jan 2026 17:11:58 +0000	[thread overview]
Message-ID: <20260131171158.5c4b93f9@jic23-huawei> (raw)
In-Reply-To: <20260130135241.137353-1-antoniu.miclaus@analog.com>

On Fri, 30 Jan 2026 15:52:38 +0200
Antoniu Miclaus <antoniu.miclaus@analog.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@analog.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,


      reply	other threads:[~2026-01-31 17:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-30 13:52 Antoniu Miclaus
2026-01-31 17:11 ` Jonathan Cameron [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260131171158.5c4b93f9@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=andy@kernel.org \
    --cc=antoniu.miclaus@analog.com \
    --cc=chuguangqing@inspur.com \
    --cc=dlechner@baylibre.com \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nuno.sa@analog.com \
    --cc=waqar.hameed@axis.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®