* [PATCH] iio: adc: at91_adc: return proper error code from at91_ts_sample()
@ 2026-01-30 13:51 Antoniu Miclaus
2026-01-31 17:10 ` Jonathan Cameron
0 siblings, 1 reply; 2+ messages in thread
From: Antoniu Miclaus @ 2026-01-30 13:51 UTC (permalink / raw)
To: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
Nicolas Ferre, Alexandre Belloni, Claudiu Beznea, Antoniu Miclaus,
linux-iio, linux-arm-kernel, linux-kernel
Return -EIO instead of -1 when xscale or yscale read from hardware
registers is zero. Using -EIO since this indicates unexpected data
from the hardware rather than an invalid argument.
Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
---
drivers/iio/adc/at91_adc.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c
index 920dd9ffd27a..5e8719d5ac01 100644
--- a/drivers/iio/adc/at91_adc.c
+++ b/drivers/iio/adc/at91_adc.c
@@ -323,7 +323,7 @@ static int at91_ts_sample(struct iio_dev *idev)
xscale = (reg >> 16) & xyz_mask;
if (xscale == 0) {
dev_err(&idev->dev, "Error: xscale == 0!\n");
- return -1;
+ return -EIO;
}
x /= xscale;
@@ -334,7 +334,7 @@ static int at91_ts_sample(struct iio_dev *idev)
yscale = (reg >> 16) & xyz_mask;
if (yscale == 0) {
dev_err(&idev->dev, "Error: yscale == 0!\n");
- return -1;
+ return -EIO;
}
y /= yscale;
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] iio: adc: at91_adc: return proper error code from at91_ts_sample()
2026-01-30 13:51 [PATCH] iio: adc: at91_adc: return proper error code from at91_ts_sample() Antoniu Miclaus
@ 2026-01-31 17:10 ` Jonathan Cameron
0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2026-01-31 17:10 UTC (permalink / raw)
To: Antoniu Miclaus
Cc: David Lechner, Nuno Sá, Andy Shevchenko, Nicolas Ferre,
Alexandre Belloni, Claudiu Beznea, linux-iio, linux-arm-kernel,
linux-kernel
On Fri, 30 Jan 2026 15:51:22 +0200
Antoniu Miclaus <antoniu.miclaus@analog.com> wrote:
> Return -EIO instead of -1 when xscale or yscale read from hardware
> registers is zero. Using -EIO since this indicates unexpected data
> from the hardware rather than an invalid argument.
>
> Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
This is a little pointless as nothing actually reads the return value.
It might be better to either make that clear by changing the return type
or figure out if it actually is useful for the caller to know this failed.
On it's own this patch gets us very little even though it looks very
sensible in isolation!
Thanks,
Jonathan
> ---
> drivers/iio/adc/at91_adc.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c
> index 920dd9ffd27a..5e8719d5ac01 100644
> --- a/drivers/iio/adc/at91_adc.c
> +++ b/drivers/iio/adc/at91_adc.c
> @@ -323,7 +323,7 @@ static int at91_ts_sample(struct iio_dev *idev)
> xscale = (reg >> 16) & xyz_mask;
> if (xscale == 0) {
> dev_err(&idev->dev, "Error: xscale == 0!\n");
> - return -1;
> + return -EIO;
> }
> x /= xscale;
>
> @@ -334,7 +334,7 @@ static int at91_ts_sample(struct iio_dev *idev)
> yscale = (reg >> 16) & xyz_mask;
> if (yscale == 0) {
> dev_err(&idev->dev, "Error: yscale == 0!\n");
> - return -1;
> + return -EIO;
> }
> y /= yscale;
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-01-31 17:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-30 13:51 [PATCH] iio: adc: at91_adc: return proper error code from at91_ts_sample() Antoniu Miclaus
2026-01-31 17:10 ` Jonathan Cameron
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox