iio: adc: ad7816: propagate SPI error codes
Subsystems (4)
PATCH 1/1 iio: adc: ad7816: propagate SPI error codes
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.
--- drivers/staging/iio/adc/ad7816.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/iio/adc/ad7816.c +2 -2
@@ -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;
Signature · 1 line
2.34.1
Quoted 5 lines · Hungyu Lin
The driver currently returns
-EIOfor 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.
...
drivers/staging/iio/adc/ad7816.c static ssize_t ad7816_show_value(struct device *dev, · line 225
Quoted 6 lines
static
ssize_tad7816_show_value(struct device *dev,drivers/staging/iio/adc/ad7816.c +1
-1ret =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
...
drivers/staging/iio/adc/ad7816.c static inline ssize_t ad7816_set_oti(struct device *dev, · line 323
Quoted 6 lines
static inline
ssize_tad7816_set_oti(struct device *dev,drivers/staging/iio/adc/ad7816.c +1
-1ret =ad7816_spi_write (chip, data);if (ret) -return -EIO ; +return ret;
Haven't checked this one, though.
Signature · 2 lines
With Best Regards, Andy Shevchenko
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
Quoted 41 lines · Andy Shevchenko
Quoted 5 lines · Hungyu Lin
The driver currently returns
-EIOfor 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.
...
Review
Quoted 6 lines
static
ssize_tad7816_show_value(struct device *dev,ret = ad7816_spi_read(chip, &data); if (ret)(quoted diff) +1
-1- 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
...
Review
Quoted 6 lines
static inline
ssize_tad7816_set_oti(struct device *dev,ret = ad7816_spi_write(chip, data); if (ret)(quoted diff) +1
-1- return -EIO; + return ret;Haven't checked this one, though.
--
With Best Regards,
Andy Shevchenko