Skip to contentSkip to conversation

iio: adc: ad7606: Fix incorrect type for error return variable

PATCH In review Haotian Zhang 3 participants 3 messages Dec 3, 2025 – Dec 7, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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.

Fixes 849cebf8dc67 ("iio: adc: ad7606: Add iio-backend support")
---
 drivers/iio/adc/ad7606_par.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iio/adc/ad7606_par.c +2 -1
index 634852c4bbd2..b81e707ab40c 100644
@@ -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
Reviewed-by on v1 1/1
#1 lore raw
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
maintainer
#2 lore raw
Quoted 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.

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