Skip to contentSkip to conversation

iio: adc: Fix pm runtime clean-up in sun4i_gpadc_probe

PATCH In review Shuhao Fu 3 participants 3 messages Oct 8, 2025 – Oct 12, 2025

Subsystems (2)
lore
Share & tools
lore

Shuhao Fu

author
#0 lore raw

PATCH 1/1 iio: adc: Fix pm runtime clean-up in sun4i_gpadc_probe

In sun4i_gpadc_probe, in case of thermal register failure, the runtime PM usage counter would not be decreased, resulting in a possible inconsistency of runtime PM state.

Fixes b0a242894f11 ("iio: adc: sun4i-gpadc-iio: register in the thermal after registering in pm")
---
 drivers/iio/adc/sun4i-gpadc-iio.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iio/adc/sun4i-gpadc-iio.c +2 -1
index 6b8d6bee1873..ae4a59a965b9 100644
@@ -644,7 +644,8 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
 			dev_err(&pdev->dev,
 				"could not register thermal sensor: %ld\n",
 				PTR_ERR(info->tzd));
-			return PTR_ERR(info->tzd);
+			ret = PTR_ERR(info->tzd);
+			goto err_map;
 		}
 	}
 
Signature · 1 line
2.39.5
#1 lore raw
Quoted 6 lines · Shuhao Fu

In sun4i_gpadc_probe, in case of thermal register failure, the runtime PM usage counter would not be decreased, resulting in a possible inconsistency of runtime PM state.

Fixes b0a242894f11 ("iio: adc: sun4i-gpadc-iio: register in the thermal after registering in pm")

This might fix this problem, but it doesn't fix the whole mess in the probe with devm/non-devm ordering.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
maintainer
#2 lore raw
Quoted 11 lines · On Wed, 8 Oct 2025 19:57:47 +0300 Andy Shevchenko <[email protected]>…
Quoted 6 lines · Shuhao Fu

In sun4i_gpadc_probe, in case of thermal register failure, the runtime PM usage counter would not be decreased, resulting in a possible inconsistency of runtime PM state.

Fixes b0a242894f11 ("iio: adc: sun4i-gpadc-iio: register in the thermal after registering in pm")

This might fix this problem, but it doesn't fix the whole mess in the probe with devm/non-devm ordering.

Mostly this looks simple to fix. Starting with devm_iio_map_register() instead of the non devm version.
Then devm_pm_runtime_enable(). However, I have no idea why we need a pm_runtime_put() in the exit path. Maybe it's messing with the parent power? There isn't a matching get.

Anyone have this hardware to hand for testing if we try to fix this up fully?

Jonathan