* [PATCH] iio: adc: ad7816: propagate SPI error codes
@ 2026-05-09 2:06 Hungyu Lin
2026-05-09 6:57 ` Andy Shevchenko
0 siblings, 1 reply; 3+ messages in thread
From: Hungyu Lin @ 2026-05-09 2:06 UTC (permalink / raw)
To: jic23
Cc: lars, Michael.Hennerich, dlechner, nuno.sa, andy, gregkh,
linux-iio, linux-staging, linux-kernel, Hungyu Lin
The driver currently returns -EIO for SPI read/write failures,
which hides the actual error code returned by the SPI subsystem.
Return the original error code instead to allow better diagnostics
and error handling by callers.
Signed-off-by: Hungyu Lin <dennylin0707@gmail.com>
---
drivers/staging/iio/adc/ad7816.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/iio/adc/ad7816.c b/drivers/staging/iio/adc/ad7816.c
index 0e32a2295990..9052203eb4f3 100644
--- a/drivers/staging/iio/adc/ad7816.c
+++ b/drivers/staging/iio/adc/ad7816.c
@@ -222,7 +222,7 @@ static ssize_t ad7816_show_value(struct device *dev,
ret = ad7816_spi_read(chip, &data);
if (ret)
- return -EIO;
+ return ret;
data >>= AD7816_VALUE_OFFSET;
@@ -320,7 +320,7 @@ static inline ssize_t ad7816_set_oti(struct device *dev,
ret = ad7816_spi_write(chip, data);
if (ret)
- return -EIO;
+ return ret;
chip->oti_data[chip->channel_id] = data;
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] iio: adc: ad7816: propagate SPI error codes
2026-05-09 2:06 [PATCH] iio: adc: ad7816: propagate SPI error codes Hungyu Lin
@ 2026-05-09 6:57 ` Andy Shevchenko
2026-05-09 7:24 ` Denny Lin
0 siblings, 1 reply; 3+ messages in thread
From: Andy Shevchenko @ 2026-05-09 6:57 UTC (permalink / raw)
To: Hungyu Lin
Cc: jic23, lars, Michael.Hennerich, dlechner, nuno.sa, andy, gregkh,
linux-iio, linux-staging, linux-kernel
On Sat, May 09, 2026 at 02:06:46AM +0000, Hungyu Lin wrote:
> The driver currently returns -EIO for SPI read/write failures,
> which hides the actual error code returned by the SPI subsystem.
>
> Return the original error code instead to allow better diagnostics
> and error handling by callers.
...
> static ssize_t ad7816_show_value(struct device *dev,
> ret = ad7816_spi_read(chip, &data);
> if (ret)
> - return -EIO;
> + return ret;
At least this is an ABI change and should have been mentioned in the commit
message and justified.
Yes, error code is an ABI and infamous case is already known when similar
change badly broke user space.
https://lkml.org/lkml/2012/12/23/75
...
> static inline ssize_t ad7816_set_oti(struct device *dev,
> ret = ad7816_spi_write(chip, data);
> if (ret)
> - return -EIO;
> + return ret;
Haven't checked this one, though.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] iio: adc: ad7816: propagate SPI error codes
2026-05-09 6:57 ` Andy Shevchenko
@ 2026-05-09 7:24 ` Denny Lin
0 siblings, 0 replies; 3+ messages in thread
From: Denny Lin @ 2026-05-09 7:24 UTC (permalink / raw)
To: Andy Shevchenko
Cc: jic23, lars, Michael.Hennerich, dlechner, nuno.sa, andy, gregkh,
linux-iio, linux-staging, linux-kernel
Hi Andy,
Thanks for pointing this out.
You're right that this changes the userspace-visible error codes and
can be considered an ABI change. I don't think this is worth the risk,
so I'll drop this change.
Thanks,
Hungyu
On Fri, May 8, 2026 at 11:57 PM Andy Shevchenko
<andriy.shevchenko@intel.com> wrote:
>
> On Sat, May 09, 2026 at 02:06:46AM +0000, Hungyu Lin wrote:
> > The driver currently returns -EIO for SPI read/write failures,
> > which hides the actual error code returned by the SPI subsystem.
> >
> > Return the original error code instead to allow better diagnostics
> > and error handling by callers.
>
> ...
>
> > static ssize_t ad7816_show_value(struct device *dev,
>
> > ret = ad7816_spi_read(chip, &data);
> > if (ret)
> > - return -EIO;
> > + return ret;
>
> At least this is an ABI change and should have been mentioned in the commit
> message and justified.
>
> Yes, error code is an ABI and infamous case is already known when similar
> change badly broke user space.
>
> https://lkml.org/lkml/2012/12/23/75
>
> ...
>
> > static inline ssize_t ad7816_set_oti(struct device *dev,
>
> > ret = ad7816_spi_write(chip, data);
> > if (ret)
> > - return -EIO;
> > + return ret;
>
> Haven't checked this one, though.
>
> --
> With Best Regards,
> Andy Shevchenko
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-05-09 7:25 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-09 2:06 [PATCH] iio: adc: ad7816: propagate SPI error codes Hungyu Lin
2026-05-09 6:57 ` Andy Shevchenko
2026-05-09 7:24 ` Denny Lin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox