iio: adc: ad7606: Fix incorrect type for error return variable
Subsystems (2)
PATCH 1/1 iio: adc: ad7606: Fix incorrect type for error return variable
The variable ret is declared as unsigned int but is used to store return values from functions returning int, which may be negative error codes.
Change ret from unsigned int to int.
--- drivers/iio/adc/ad7606_par.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iio/adc/ad7606_par.c +2 -1
@@ -43,7 +43,8 @@ static int ad7606_par_bus_setup_iio_backend(struct device *dev, struct iio_dev *indio_dev) {struct ad7606_state *st =iio_priv (indio_dev); -unsigned int ret, c; +unsigned int c; +int ret;struct iio_backend_data_fmt data = { .sign_extend = true, .enable = true,
Signature · 1 line
2.50.1.windows.1
Quoted 7 lines · Haotian Zhang
The variable ret is declared as unsigned int but is used to store return values from functions returning int, which may be negative error codes.
Change ret from unsigned int to int.
Fixes 849cebf8dc67 ("iio: adc: ad7606: Add iio-backend support")
Since it returns an int, it is just double conversion (however in the standard promotion from unsigned to signed is UB if I remember correctly). That said, I am not sure this justifies the Fixes tag, but I'm not against it.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Jonathan Cameron
maintainerQuoted 7 lines · On Wed, 3 Dec 2025 11:16:26 +0200 Andy Shevchenko <[email protected]>…
Quoted 5 lines · Haotian Zhang
The variable ret is declared as unsigned int but is used to store return values from functions returning int, which may be negative error codes.
Change ret from unsigned int to int.
Quoted 9 lines
Quoted 1 line
Fixes 849cebf8dc67 ("iio: adc: ad7606: Add iio-backend support")Since it returns an int, it is just double conversion (however in the standard promotion from unsigned to signed is UB if I remember correctly). That said, I am not sure this justifies the Fixes tag, but I'm not against it.
Reviewed-by Andy Shevchenko <[email protected]>
I think it is worth getting this backported as it's definitely wrong if not an actual bug so I'll keep the fixes tag and take it via my fixes branch.
Thanks,
Jonathan