mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v1 0/4] iio: Unshadow error codes in ->store()
@ 2026-08-13  7:16 Andy Shevchenko
  2026-08-13  7:16 ` [PATCH v1 1/4] iio: light: " Andy Shevchenko
                   ` (3 more replies)
  0 siblings, 4 replies; 16+ messages in thread
From: Andy Shevchenko @ 2026-08-13  7:16 UTC (permalink / raw)
  To: Jonathan Cameron, Maxwell Doose, Sakari Ailus, Andy Shevchenko,
	linux-iio, linux-kernel
  Cc: Marius Cristea, David Lechner, Nuno Sá,
	Andy Shevchenko, Tomasz Duszynski, Jean-Baptiste Maneyrol

kstrtox() may return different error codes. Allow them to be returned.
This mini-series makes all IIO drivers to follow the same pattern when
using kstrtox() APIs. Patches can be individually applied, the series
is just a union by the subject, no code dependencies are there.

Andy Shevchenko (4):
  iio: light: Unshadow error codes in ->store()
  iio: imu: inv_mpu6050: Unshadow error codes in ->store()
  iio: chemical: sps30: Unshadow error codes in ->store()
  iio: adc: pac1934: Unshadow error codes in ->store()

 drivers/iio/adc/pac1934.c                  |  9 ++++++---
 drivers/iio/chemical/sps30.c               | 11 ++++++++---
 drivers/iio/imu/inv_mpu6050/inv_mpu_core.c |  6 ++++--
 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 ++++++++++++----
 7 files changed, 53 insertions(+), 22 deletions(-)

-- 
2.50.1


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH v1 1/4] iio: light: Unshadow error codes in ->store()
  2026-08-13  7:16 [PATCH v1 0/4] iio: Unshadow error codes in ->store() Andy Shevchenko
@ 2026-08-13  7:16 ` Andy Shevchenko
  2026-08-13 17:51   ` Maxwell Doose
  2026-08-13  7:16 ` [PATCH v1 2/4] iio: imu: inv_mpu6050: " Andy Shevchenko
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 16+ messages in thread
From: Andy Shevchenko @ 2026-08-13  7:16 UTC (permalink / raw)
  To: Jonathan Cameron, Maxwell Doose, Sakari Ailus, Andy Shevchenko,
	linux-iio, linux-kernel
  Cc: Marius Cristea, David Lechner, Nuno Sá,
	Andy Shevchenko, Tomasz Duszynski, Jean-Baptiste Maneyrol

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/isl29018.c b/drivers/iio/light/isl29018.c
index 759cb71ed1c5..7f7a563df4d9 100644
--- a/drivers/iio/light/isl29018.c
+++ b/drivers/iio/light/isl29018.c
@@ -10,6 +10,7 @@
 
 #include <linux/i2c.h>
 #include <linux/err.h>
+#include <linux/kstrtox.h>
 #include <linux/module.h>
 #include <linux/mutex.h>
 #include <linux/delay.h>
@@ -339,9 +340,11 @@ static ssize_t proximity_on_chip_ambient_infrared_suppression_store
 	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
 	struct isl29018_chip *chip = iio_priv(indio_dev);
 	int val;
+	int ret;
 
-	if (kstrtoint(buf, 10, &val))
-		return -EINVAL;
+	ret = kstrtoint(buf, 10, &val);
+	if (ret)
+		return ret;
 	if (!(val == 0 || val == 1))
 		return -EINVAL;
 
diff --git a/drivers/iio/light/lm3533-als.c b/drivers/iio/light/lm3533-als.c
index 99f0b903018c..5db9591a85b9 100644
--- a/drivers/iio/light/lm3533-als.c
+++ b/drivers/iio/light/lm3533-als.c
@@ -13,6 +13,7 @@
 #include <linux/io.h>
 #include <linux/iio/events.h>
 #include <linux/iio/iio.h>
+#include <linux/kstrtox.h>
 #include <linux/module.h>
 #include <linux/mutex.h>
 #include <linux/mfd/core.h>
@@ -434,8 +435,9 @@ static ssize_t store_thresh_either_en(struct device *dev,
 	if (!als->irq)
 		return -EBUSY;
 
-	if (kstrtoul(buf, 0, &enable))
-		return -EINVAL;
+	ret = kstrtoul(buf, 0, &enable);
+	if (ret)
+		return ret;
 
 	int_enabled = test_bit(LM3533_ALS_FLAG_INT_ENABLED, &als->flags);
 
@@ -542,8 +544,9 @@ static ssize_t store_als_attr(struct device *dev,
 	u8 val;
 	int ret;
 
-	if (kstrtou8(buf, 0, &val))
-		return -EINVAL;
+	ret = kstrtou8(buf, 0, &val);
+	if (ret)
+		return ret;
 
 	switch (als_attr->type) {
 	case LM3533_ATTR_TYPE_TARGET:
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>
+#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);
-- 
2.50.1


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH v1 2/4] iio: imu: inv_mpu6050: Unshadow error codes in ->store()
  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  7:16 ` Andy Shevchenko
  2026-08-13 17:57   ` Maxwell Doose
  2026-08-13  7:16 ` [PATCH v1 3/4] iio: chemical: sps30: " Andy Shevchenko
  2026-08-13  7:16 ` [PATCH v1 4/4] iio: adc: pac1934: " Andy Shevchenko
  3 siblings, 1 reply; 16+ messages in thread
From: Andy Shevchenko @ 2026-08-13  7:16 UTC (permalink / raw)
  To: Jonathan Cameron, Maxwell Doose, Sakari Ailus, Andy Shevchenko,
	linux-iio, linux-kernel
  Cc: Marius Cristea, David Lechner, Nuno Sá,
	Andy Shevchenko, Tomasz Duszynski, Jean-Baptiste Maneyrol

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/imu/inv_mpu6050/inv_mpu_core.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
index 5796896d54cd..38c3f3b398d4 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
@@ -13,6 +13,7 @@
 #include <linux/irq.h>
 #include <linux/interrupt.h>
 #include <linux/acpi.h>
+#include <linux/kstrtox.h>
 #include <linux/platform_device.h>
 #include <linux/regulator/consumer.h>
 #include <linux/math64.h>
@@ -1303,8 +1304,9 @@ inv_mpu6050_fifo_rate_store(struct device *dev, struct device_attribute *attr,
 	struct inv_mpu6050_state *st = iio_priv(indio_dev);
 	struct device *pdev = regmap_get_device(st->map);
 
-	if (kstrtoint(buf, 10, &fifo_rate))
-		return -EINVAL;
+	result = kstrtoint(buf, 10, &fifo_rate);
+	if (result)
+		return result;
 	if (fifo_rate < INV_MPU6050_MIN_FIFO_RATE ||
 	    fifo_rate > INV_MPU6050_MAX_FIFO_RATE)
 		return -EINVAL;
-- 
2.50.1


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH v1 3/4] iio: chemical: sps30: Unshadow error codes in ->store()
  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  7:16 ` [PATCH v1 2/4] iio: imu: inv_mpu6050: " Andy Shevchenko
@ 2026-08-13  7:16 ` Andy Shevchenko
  2026-08-13 17:53   ` Maxwell Doose
  2026-08-13  7:16 ` [PATCH v1 4/4] iio: adc: pac1934: " Andy Shevchenko
  3 siblings, 1 reply; 16+ messages in thread
From: Andy Shevchenko @ 2026-08-13  7:16 UTC (permalink / raw)
  To: Jonathan Cameron, Maxwell Doose, Sakari Ailus, Andy Shevchenko,
	linux-iio, linux-kernel
  Cc: Marius Cristea, David Lechner, Nuno Sá,
	Andy Shevchenko, Tomasz Duszynski, Jean-Baptiste Maneyrol

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/chemical/sps30.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/iio/chemical/sps30.c b/drivers/iio/chemical/sps30.c
index 8e15baa31423..b47d08ab4d0f 100644
--- a/drivers/iio/chemical/sps30.c
+++ b/drivers/iio/chemical/sps30.c
@@ -15,6 +15,7 @@
 #include <linux/iio/trigger_consumer.h>
 #include <linux/iio/triggered_buffer.h>
 #include <linux/kernel.h>
+#include <linux/kstrtox.h>
 #include <linux/module.h>
 
 #include "sps30.h"
@@ -193,7 +194,10 @@ static ssize_t start_cleaning_store(struct device *dev,
 	struct sps30_state *state = iio_priv(indio_dev);
 	int val, ret;
 
-	if (kstrtoint(buf, 0, &val) || val != 1)
+	ret = kstrtoint(buf, 0, &val);
+	if (ret)
+		return ret;
+	if (val != 1)
 		return -EINVAL;
 
 	guard(mutex)(&state->lock);
@@ -230,8 +234,9 @@ static ssize_t cleaning_period_store(struct device *dev, struct device_attribute
 	struct sps30_state *state = iio_priv(indio_dev);
 	int val, ret;
 
-	if (kstrtoint(buf, 0, &val))
-		return -EINVAL;
+	ret = kstrtoint(buf, 0, &val);
+	if (ret)
+		return ret;
 
 	if ((val < SPS30_AUTO_CLEANING_PERIOD_MIN) ||
 	    (val > SPS30_AUTO_CLEANING_PERIOD_MAX))
-- 
2.50.1


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH v1 4/4] iio: adc: pac1934: Unshadow error codes in ->store()
  2026-08-13  7:16 [PATCH v1 0/4] iio: Unshadow error codes in ->store() Andy Shevchenko
                   ` (2 preceding siblings ...)
  2026-08-13  7:16 ` [PATCH v1 3/4] iio: chemical: sps30: " Andy Shevchenko
@ 2026-08-13  7:16 ` Andy Shevchenko
  2026-08-13 12:17   ` Marius.Cristea
  2026-08-13 17:54   ` Maxwell Doose
  3 siblings, 2 replies; 16+ messages in thread
From: Andy Shevchenko @ 2026-08-13  7:16 UTC (permalink / raw)
  To: Jonathan Cameron, Maxwell Doose, Sakari Ailus, Andy Shevchenko,
	linux-iio, linux-kernel
  Cc: Marius Cristea, David Lechner, Nuno Sá,
	Andy Shevchenko, Tomasz Duszynski, Jean-Baptiste Maneyrol

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/adc/pac1934.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/iio/adc/pac1934.c b/drivers/iio/adc/pac1934.c
index 23055405a6e0..2d934452eb11 100644
--- a/drivers/iio/adc/pac1934.c
+++ b/drivers/iio/adc/pac1934.c
@@ -19,6 +19,7 @@
 #include <linux/i2c.h>
 #include <linux/iio/iio.h>
 #include <linux/iio/sysfs.h>
+#include <linux/kstrtox.h>
 #include <linux/unaligned.h>
 
 /*
@@ -494,11 +495,13 @@ static ssize_t pac1934_shunt_value_store(struct device *dev,
 	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
 	struct pac1934_chip_info *info = iio_priv(indio_dev);
 	struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-	int sh_val;
+	unsigned int sh_val;
+	int ret;
 
-	if (kstrtouint(buf, 10, &sh_val)) {
+	ret = kstrtouint(buf, 10, &sh_val);
+	if (ret) {
 		dev_err(dev, "Shunt value is not valid\n");
-		return -EINVAL;
+		return ret;
 	}
 
 	scoped_guard(mutex, &info->lock)
-- 
2.50.1


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v1 4/4] iio: adc: pac1934: Unshadow error codes in ->store()
  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
  1 sibling, 0 replies; 16+ messages in thread
From: Marius.Cristea @ 2026-08-13 12:17 UTC (permalink / raw)
  To: andriy.shevchenko, jic23, maxwell, linux-kernel, sakari.ailus, linux-iio
  Cc: tduszyns, nuno.sa, dlechner, jean-baptiste.maneyrol, andy

On Thu, 2026-08-13 at 09:16 +0200, Andy Shevchenko wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you
> know the content is safe
> 
> 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/adc/pac1934.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/iio/adc/pac1934.c b/drivers/iio/adc/pac1934.c
> index 23055405a6e0..2d934452eb11 100644
> --- a/drivers/iio/adc/pac1934.c
> +++ b/drivers/iio/adc/pac1934.c
> @@ -19,6 +19,7 @@
>  #include <linux/i2c.h>
>  #include <linux/iio/iio.h>
>  #include <linux/iio/sysfs.h>
> +#include <linux/kstrtox.h>
>  #include <linux/unaligned.h>
> 
>  /*
> @@ -494,11 +495,13 @@ static ssize_t pac1934_shunt_value_store(struct
> device *dev,
>         struct iio_dev *indio_dev = dev_to_iio_dev(dev);
>         struct pac1934_chip_info *info = iio_priv(indio_dev);
>         struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
> -       int sh_val;
> +       unsigned int sh_val;
> +       int ret;
> 
> -       if (kstrtouint(buf, 10, &sh_val)) {
> +       ret = kstrtouint(buf, 10, &sh_val);
> +       if (ret) {
>                 dev_err(dev, "Shunt value is not valid\n");
> -               return -EINVAL;
> +               return ret;
>         }
> 
>         scoped_guard(mutex, &info->lock)
> --
> 2.50.1

Reviewed-by: Marius Cristea <marius.cristea@microchip.com>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v1 1/4] iio: light: Unshadow error codes in ->store()
  2026-08-13  7:16 ` [PATCH v1 1/4] iio: light: " Andy Shevchenko
@ 2026-08-13 17:51   ` Maxwell Doose
  2026-08-13 20:47     ` Andy Shevchenko
  0 siblings, 1 reply; 16+ messages in thread
From: Maxwell Doose @ 2026-08-13 17:51 UTC (permalink / raw)
  To: Andy Shevchenko, Jonathan Cameron, Maxwell Doose, Sakari Ailus,
	linux-iio, linux-kernel
  Cc: Marius Cristea, David Lechner, Nuno Sá,
	Andy Shevchenko, Tomasz Duszynski, Jean-Baptiste Maneyrol

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);


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v1 3/4] iio: chemical: sps30: Unshadow error codes in ->store()
  2026-08-13  7:16 ` [PATCH v1 3/4] iio: chemical: sps30: " Andy Shevchenko
@ 2026-08-13 17:53   ` Maxwell Doose
  0 siblings, 0 replies; 16+ messages in thread
From: Maxwell Doose @ 2026-08-13 17:53 UTC (permalink / raw)
  To: Andy Shevchenko, Jonathan Cameron, Maxwell Doose, Sakari Ailus,
	linux-iio, linux-kernel
  Cc: Marius Cristea, David Lechner, Nuno Sá,
	Andy Shevchenko, Tomasz Duszynski, Jean-Baptiste Maneyrol

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/chemical/sps30.c | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
>

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

thanks,
max

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v1 4/4] iio: adc: pac1934: Unshadow error codes in ->store()
  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
  1 sibling, 0 replies; 16+ messages in thread
From: Maxwell Doose @ 2026-08-13 17:54 UTC (permalink / raw)
  To: Andy Shevchenko, Jonathan Cameron, Maxwell Doose, Sakari Ailus,
	linux-iio, linux-kernel
  Cc: Marius Cristea, David Lechner, Nuno Sá,
	Andy Shevchenko, Tomasz Duszynski, Jean-Baptiste Maneyrol

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/adc/pac1934.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
>

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

thanks,
max

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v1 2/4] iio: imu: inv_mpu6050: Unshadow error codes in ->store()
  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
  0 siblings, 1 reply; 16+ messages in thread
From: Maxwell Doose @ 2026-08-13 17:57 UTC (permalink / raw)
  To: Andy Shevchenko, Jonathan Cameron, Maxwell Doose, Sakari Ailus,
	linux-iio, linux-kernel
  Cc: Marius Cristea, David Lechner, Nuno Sá,
	Andy Shevchenko, Tomasz Duszynski, Jean-Baptiste Maneyrol

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/imu/inv_mpu6050/inv_mpu_core.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
> index 5796896d54cd..38c3f3b398d4 100644
> --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
> +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
> @@ -13,6 +13,7 @@
>  #include <linux/irq.h>
>  #include <linux/interrupt.h>
>  #include <linux/acpi.h>
> +#include <linux/kstrtox.h>
>  #include <linux/platform_device.h>
>  #include <linux/regulator/consumer.h>
>  #include <linux/math64.h>
> @@ -1303,8 +1304,9 @@ inv_mpu6050_fifo_rate_store(struct device *dev, struct device_attribute *attr,
>  	struct inv_mpu6050_state *st = iio_priv(indio_dev);
>  	struct device *pdev = regmap_get_device(st->map);
>  
> -	if (kstrtoint(buf, 10, &fifo_rate))
> -		return -EINVAL;
> +	result = kstrtoint(buf, 10, &fifo_rate);
> +	if (result)
> +		return result;

I suppose result is what was being used before? Oh well doesn't seem
worth it to send a patch *just* to change to int ret.

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

thanks,
max


>  	if (fifo_rate < INV_MPU6050_MIN_FIFO_RATE ||
>  	    fifo_rate > INV_MPU6050_MAX_FIFO_RATE)
>  		return -EINVAL;


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v1 1/4] iio: light: Unshadow error codes in ->store()
  2026-08-13 17:51   ` Maxwell Doose
@ 2026-08-13 20:47     ` Andy Shevchenko
  2026-08-14  2:47       ` Maxwell Doose
  0 siblings, 1 reply; 16+ messages in thread
From: Andy Shevchenko @ 2026-08-13 20:47 UTC (permalink / raw)
  To: Maxwell Doose
  Cc: Andy Shevchenko, Jonathan Cameron, Sakari Ailus, linux-iio,
	linux-kernel, Marius Cristea, David Lechner, Nuno Sá,
	Andy Shevchenko, Tomasz Duszynski, Jean-Baptiste Maneyrol

On Thu, Aug 13, 2026 at 8:52 PM Maxwell Doose <maxwell@maxwelld.cc> wrote:
> On Thu Aug 13, 2026 at 2:16 AM CDT
> Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:

...

> > -#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.

Not really. I understand what you mean, but I took a step just for the
k*.h letter to group them. It's slightly easier to follow with
kernel.h being moved. Note, that kernel.h shouldn't be there at all,
but that is definitely out of scope here.

> > +#include <linux/kstrtox.h>
> >  #include <linux/string.h>
> >  #include <linux/mutex.h>
> >  #include <linux/unistd.h>

Thanks for the review!

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v1 2/4] iio: imu: inv_mpu6050: Unshadow error codes in ->store()
  2026-08-13 17:57   ` Maxwell Doose
@ 2026-08-13 20:48     ` Andy Shevchenko
  0 siblings, 0 replies; 16+ messages in thread
From: Andy Shevchenko @ 2026-08-13 20:48 UTC (permalink / raw)
  To: Maxwell Doose
  Cc: Andy Shevchenko, Jonathan Cameron, Sakari Ailus, linux-iio,
	linux-kernel, Marius Cristea, David Lechner, Nuno Sá,
	Andy Shevchenko, Tomasz Duszynski, Jean-Baptiste Maneyrol

On Thu, Aug 13, 2026 at 8:57 PM Maxwell Doose <maxwell@maxwelld.cc> wrote:
> On Thu Aug 13, 2026 at 2:16 AM CDT
> Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:

...

> > +     result = kstrtoint(buf, 10, &fifo_rate);
> > +     if (result)
> > +             return result;
>
> I suppose result is what was being used before?

Yes, its semantic is the same as for the usual 'ret' variable.

>  Oh well doesn't seem
> worth it to send a patch *just* to change to int ret.

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

Thanks!

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v1 1/4] iio: light: Unshadow error codes in ->store()
  2026-08-13 20:47     ` Andy Shevchenko
@ 2026-08-14  2:47       ` Maxwell Doose
  2026-08-14  8:14         ` Andy Shevchenko
  0 siblings, 1 reply; 16+ messages in thread
From: Maxwell Doose @ 2026-08-14  2:47 UTC (permalink / raw)
  To: Andy Shevchenko, Maxwell Doose
  Cc: Andy Shevchenko, Jonathan Cameron, Sakari Ailus, linux-iio,
	linux-kernel, Marius Cristea, David Lechner, Nuno Sá,
	Andy Shevchenko, Tomasz Duszynski, Jean-Baptiste Maneyrol

On Thu Aug 13, 2026 at 3:47 PM CDT
Andy Shevchenko <andy.shevchenko@gmail.com> wrote:

> On Thu, Aug 13, 2026 at 8:52 PM Maxwell Doose <maxwell@maxwelld.cc> wrote:
>> On Thu Aug 13, 2026 at 2:16 AM CDT
>> Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:
>
> ...
>
>> > -#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.
>
> Not really. I understand what you mean, but I took a step just for the
> k*.h letter to group them. It's slightly easier to follow with

Fair enough :)

> kernel.h being moved. Note, that kernel.h shouldn't be there at all,
> but that is definitely out of scope here.

Makes sense. I wonder if it may be worth doing a patch series removing
all of the kernel.h inclusions in IIO all at once (or maybe some drivers
have a legitimate use for it, but that seems highly unlikely).

thanks,
max

>
>> > +#include <linux/kstrtox.h>
>> >  #include <linux/string.h>
>> >  #include <linux/mutex.h>
>> >  #include <linux/unistd.h>
>
> Thanks for the review!


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v1 1/4] iio: light: Unshadow error codes in ->store()
  2026-08-14  2:47       ` Maxwell Doose
@ 2026-08-14  8:14         ` Andy Shevchenko
  2026-08-14  8:25           ` Joshua Crofts
  0 siblings, 1 reply; 16+ messages in thread
From: Andy Shevchenko @ 2026-08-14  8:14 UTC (permalink / raw)
  To: Maxwell Doose
  Cc: Andy Shevchenko, Jonathan Cameron, Sakari Ailus, linux-iio,
	linux-kernel, Marius Cristea, David Lechner, Nuno Sá,
	Andy Shevchenko, Tomasz Duszynski, Jean-Baptiste Maneyrol

On Thu, Aug 13, 2026 at 09:47:00PM -0500, Maxwell Doose wrote:
> On Thu Aug 13, 2026 at 3:47 PM CDT
> Andy Shevchenko <andy.shevchenko@gmail.com> wrote:
> > On Thu, Aug 13, 2026 at 8:52 PM Maxwell Doose <maxwell@maxwelld.cc> wrote:

...

> > Note, that kernel.h shouldn't be there at all, but that is definitely out
> > of scope here.
> 
> Makes sense. I wonder if it may be worth doing a patch series removing
> all of the kernel.h inclusions in IIO all at once (or maybe some drivers
> have a legitimate use for it, but that seems highly unlikely).

Yes, for sure! I have simply had no time to do it myself, but I have a low-prio
item in my always grown TODO list. So, if you do that, I will really appreciate!
But be careful, the actual patches should care about the whole bunch of the
inclusions, and not just about kernel.h. This means each driver should be
carefully inspected in accordance with the IWYU principles.

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v1 1/4] iio: light: Unshadow error codes in ->store()
  2026-08-14  8:14         ` Andy Shevchenko
@ 2026-08-14  8:25           ` Joshua Crofts
  2026-08-14  8:50             ` Andy Shevchenko
  0 siblings, 1 reply; 16+ messages in thread
From: Joshua Crofts @ 2026-08-14  8:25 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Maxwell Doose, Andy Shevchenko, Jonathan Cameron, Sakari Ailus,
	linux-iio, linux-kernel, Marius Cristea, David Lechner,
	Nuno Sá,
	Andy Shevchenko, Tomasz Duszynski, Jean-Baptiste Maneyrol

On Fri, 14 Aug 2026 at 10:16, Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> On Thu, Aug 13, 2026 at 09:47:00PM -0500, Maxwell Doose wrote:
> > On Thu Aug 13, 2026 at 3:47 PM CDT
> > Andy Shevchenko <andy.shevchenko@gmail.com> wrote:
> > > On Thu, Aug 13, 2026 at 8:52 PM Maxwell Doose <maxwell@maxwelld.cc> wrote:
>
> ...
>
> > > Note, that kernel.h shouldn't be there at all, but that is definitely out
> > > of scope here.
> >
> > Makes sense. I wonder if it may be worth doing a patch series removing
> > all of the kernel.h inclusions in IIO all at once (or maybe some drivers
> > have a legitimate use for it, but that seems highly unlikely).
>
> Yes, for sure! I have simply had no time to do it myself, but I have a low-prio
> item in my always grown TODO list. So, if you do that, I will really appreciate!
> But be careful, the actual patches should care about the whole bunch of the
> inclusions, and not just about kernel.h. This means each driver should be
> carefully inspected in accordance with the IWYU principles.

This will be a gruelling task (implementing and reviewing), but perhaps it
would be easier to do one sensor type at a time instead of the entire
subsystem.

--
Kind regards,
Joshua Crofts

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v1 1/4] iio: light: Unshadow error codes in ->store()
  2026-08-14  8:25           ` Joshua Crofts
@ 2026-08-14  8:50             ` Andy Shevchenko
  0 siblings, 0 replies; 16+ messages in thread
From: Andy Shevchenko @ 2026-08-14  8:50 UTC (permalink / raw)
  To: Joshua Crofts
  Cc: Maxwell Doose, Andy Shevchenko, Jonathan Cameron, Sakari Ailus,
	linux-iio, linux-kernel, Marius Cristea, David Lechner,
	Nuno Sá,
	Andy Shevchenko, Tomasz Duszynski, Jean-Baptiste Maneyrol

On Fri, Aug 14, 2026 at 10:25:32AM +0200, Joshua Crofts wrote:
> On Fri, 14 Aug 2026 at 10:16, Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:
> > On Thu, Aug 13, 2026 at 09:47:00PM -0500, Maxwell Doose wrote:
> > > On Thu Aug 13, 2026 at 3:47 PM CDT
> > > Andy Shevchenko <andy.shevchenko@gmail.com> wrote:
> > > > On Thu, Aug 13, 2026 at 8:52 PM Maxwell Doose <maxwell@maxwelld.cc> wrote:

...

> > > > Note, that kernel.h shouldn't be there at all, but that is definitely out
> > > > of scope here.
> > >
> > > Makes sense. I wonder if it may be worth doing a patch series removing
> > > all of the kernel.h inclusions in IIO all at once (or maybe some drivers
> > > have a legitimate use for it, but that seems highly unlikely).
> >
> > Yes, for sure! I have simply had no time to do it myself, but I have a low-prio
> > item in my always grown TODO list. So, if you do that, I will really appreciate!
> > But be careful, the actual patches should care about the whole bunch of the
> > inclusions, and not just about kernel.h. This means each driver should be
> > carefully inspected in accordance with the IWYU principles.
> 
> This will be a gruelling task (implementing and reviewing), but perhaps it
> would be easier to do one sensor type at a time instead of the entire
> subsystem.

I would start from the easy cases where kernel.h is just not used at all (not
even as a "proxy" header). Then continue with the rest.

Joshua, note, it's only about the drivers that have explicit kernel.h
inclusion. In general the entire IIO needs to be revisited, indeed.

$ git grep -n -lw linux/kernel.h -- drivers/iio/ | wc -l
234

$ git ls-files | grep ^drivers/iio/.*\.c$ | wc -l
707

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2026-08-14  8:51 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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-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

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®