All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Maxwell Doose" <maxwell@maxwelld.cc>
To: "Andy Shevchenko" <andriy.shevchenko@linux.intel.com>,
	"Jonathan Cameron" <jic23@kernel.org>,
	"Maxwell Doose" <maxwell@maxwelld.cc>,
	"Sakari Ailus" <sakari.ailus@linux.intel.com>,
	<linux-iio@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Cc: "Marius Cristea" <marius.cristea@microchip.com>,
	"David Lechner" <dlechner@baylibre.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	"Tomasz Duszynski" <tduszyns@gmail.com>,
	"Jean-Baptiste Maneyrol" <jean-baptiste.maneyrol@tdk.com>
Subject: Re: [PATCH v1 1/4] iio: light: Unshadow error codes in ->store()
Date: Thu, 13 Aug 2026 12:51:55 -0500	[thread overview]
Message-ID: <DKO09O8T0FGE.2WMX1VNQN5C7J@maxwelld.cc> (raw)
In-Reply-To: <20260813071912.2465208-2-andriy.shevchenko@linux.intel.com>

On Thu Aug 13, 2026 at 2:16 AM CDT
Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:

> kstrtox() may return different error codes.
>
> Unshadow them in the ->store() callback to give better error report.
>
> While at it, add missing kstrtox.h inclusion.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/iio/light/isl29018.c   |  7 +++++--
>  drivers/iio/light/lm3533-als.c | 11 +++++++----
>  drivers/iio/light/tsl2583.c    | 15 +++++++++++----
>  drivers/iio/light/tsl2772.c    | 16 ++++++++++++----
>  4 files changed, 35 insertions(+), 14 deletions(-)
>
...
> diff --git a/drivers/iio/light/tsl2583.c b/drivers/iio/light/tsl2583.c
> index 53fd423aa7ae..2d041b7530e6 100644
> --- a/drivers/iio/light/tsl2583.c
> +++ b/drivers/iio/light/tsl2583.c
> @@ -7,10 +7,11 @@
>   * Copyright (c) 2016-2017 Brian Masney <masneyb@onstation.org>
>   */
>  
> -#include <linux/kernel.h>
>  #include <linux/i2c.h>
>  #include <linux/errno.h>
>  #include <linux/delay.h>
> +#include <linux/kernel.h>

Stray change? The ordering's messed up (seems to be case for many of
these drivers) so perhaps we can send a patch to fix the ordering.

Otherwise,

Reviewed-by: Maxwell Doose <maxwell@maxwelld.cc>

thanks,
max

> +#include <linux/kstrtox.h>
>  #include <linux/string.h>
>  #include <linux/mutex.h>
>  #include <linux/unistd.h>
> @@ -483,9 +484,12 @@ static ssize_t in_illuminance_input_target_store(struct device *dev,
>  {
>  	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
>  	struct tsl2583_chip *chip = iio_priv(indio_dev);
> -	int value;
> +	int value, ret;
>  
> -	if (kstrtoint(buf, 0, &value) || !value)
> +	ret = kstrtoint(buf, 0, &value);
> +	if (ret)
> +		return ret;
> +	if (!value)
>  		return -EINVAL;
>  
>  	mutex_lock(&chip->als_mutex);
> @@ -503,7 +507,10 @@ static ssize_t in_illuminance_calibrate_store(struct device *dev,
>  	struct tsl2583_chip *chip = iio_priv(indio_dev);
>  	int value, ret;
>  
> -	if (kstrtoint(buf, 0, &value) || value != 1)
> +	ret = kstrtoint(buf, 0, &value);
> +	if (ret)
> +		return ret;
> +	if (value != 1)
>  		return -EINVAL;
>  
>  	mutex_lock(&chip->als_mutex);
> diff --git a/drivers/iio/light/tsl2772.c b/drivers/iio/light/tsl2772.c
> index 4486a1d9d84d..c8a7afc65c1f 100644
> --- a/drivers/iio/light/tsl2772.c
> +++ b/drivers/iio/light/tsl2772.c
> @@ -13,6 +13,7 @@
>  #include <linux/i2c.h>
>  #include <linux/interrupt.h>
>  #include <linux/kernel.h>
> +#include <linux/kstrtox.h>
>  #include <linux/module.h>
>  #include <linux/mutex.h>
>  #include <linux/property.h>
> @@ -951,8 +952,9 @@ static ssize_t in_illuminance0_target_input_store(struct device *dev,
>  	u16 value;
>  	int ret;
>  
> -	if (kstrtou16(buf, 0, &value))
> -		return -EINVAL;
> +	ret = kstrtou16(buf, 0, &value);
> +	if (ret)
> +		return ret;
>  
>  	chip->settings.als_cal_target = value;
>  	ret = tsl2772_invoke_change(indio_dev);
> @@ -970,7 +972,10 @@ static ssize_t in_illuminance0_calibrate_store(struct device *dev,
>  	bool value;
>  	int ret;
>  
> -	if (kstrtobool(buf, &value) || !value)
> +	ret = kstrtobool(buf, &value);
> +	if (ret)
> +		return ret;
> +	if (!value)
>  		return -EINVAL;
>  
>  	ret = tsl2772_als_calibrate(indio_dev);
> @@ -1061,7 +1066,10 @@ static ssize_t in_proximity0_calibrate_store(struct device *dev,
>  	bool value;
>  	int ret;
>  
> -	if (kstrtobool(buf, &value) || !value)
> +	ret = kstrtobool(buf, &value);
> +	if (ret)
> +		return ret;
> +	if (!value)
>  		return -EINVAL;
>  
>  	ret = tsl2772_prox_cal(indio_dev);


  reply	other threads:[~2026-08-13 17:52 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-13  7:16 [PATCH v1 0/4] iio: Unshadow error codes in ->store() Andy Shevchenko
2026-08-13  7:16 ` [PATCH v1 1/4] iio: light: " Andy Shevchenko
2026-08-13 17:51   ` Maxwell Doose [this message]
2026-08-13 20:47     ` Andy Shevchenko
2026-08-14  2:47       ` Maxwell Doose
2026-08-14  8:14         ` Andy Shevchenko
2026-08-14  8:25           ` Joshua Crofts
2026-08-14  8:50             ` Andy Shevchenko
2026-08-17  2:54               ` Jonathan Cameron
2026-08-17 19:12                 ` Maxwell Doose
2026-08-18 14:11                   ` Joshua Crofts
2026-08-22  0:42                     ` Jonathan Cameron
2026-08-13  7:16 ` [PATCH v1 2/4] iio: imu: inv_mpu6050: " Andy Shevchenko
2026-08-13 17:57   ` Maxwell Doose
2026-08-13 20:48     ` Andy Shevchenko
2026-08-13  7:16 ` [PATCH v1 3/4] iio: chemical: sps30: " Andy Shevchenko
2026-08-13 17:53   ` Maxwell Doose
2026-08-13  7:16 ` [PATCH v1 4/4] iio: adc: pac1934: " Andy Shevchenko
2026-08-13 12:17   ` Marius.Cristea
2026-08-13 17:54   ` Maxwell Doose
2026-08-22  1:19 ` [PATCH v1 0/4] iio: " Jonathan Cameron

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=DKO09O8T0FGE.2WMX1VNQN5C7J@maxwelld.cc \
    --to=maxwell@maxwelld.cc \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=andy@kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=jean-baptiste.maneyrol@tdk.com \
    --cc=jic23@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marius.cristea@microchip.com \
    --cc=nuno.sa@analog.com \
    --cc=sakari.ailus@linux.intel.com \
    --cc=tduszyns@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.