* [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; 10+ 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 related [flat|nested] 10+ 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
0 siblings, 0 replies; 10+ 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] 10+ 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; 10+ 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 related [flat|nested] 10+ 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
0 siblings, 0 replies; 10+ 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] 10+ 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; 10+ 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 related [flat|nested] 10+ 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; 10+ 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] 10+ 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; 10+ 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 related [flat|nested] 10+ 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; 10+ 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] 10+ 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; 10+ 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] 10+ messages in thread