[PATCH 1/4] iio: light: pa12203001: use devm_pm_runtime_enable() to fix probe error path
From: Stepan Ionichev
Date: Fri May 29 2026 - 06:55:03 EST
pa12203001_probe() calls pm_runtime_enable() and then
iio_device_register(). If iio_device_register() fails the function
jumps to out_err but the existing out_err handler does not call
pm_runtime_disable(), leaking the runtime PM enable_count on probe
failure and on subsequent rebind.
Switch to devm_pm_runtime_enable() so the enable (and the matching
dont_use_autosuspend) are torn down automatically. On its new error path
the probe jumps to the existing out_err label so the chip-disable cleanup
stays in step with the rest of the manual unwind. The pm_runtime_disable()
and pm_runtime_set_suspended() calls in pa12203001_remove() are dropped;
the devm action runs after .remove() and handles the teardown.
Signed-off-by: Stepan Ionichev <sozdayvek@xxxxxxxxx>
---
drivers/iio/light/pa12203001.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/iio/light/pa12203001.c b/drivers/iio/light/pa12203001.c
index 98a1f1624c75..b9f50c9070a3 100644
--- a/drivers/iio/light/pa12203001.c
+++ b/drivers/iio/light/pa12203001.c
@@ -372,7 +372,9 @@ static int pa12203001_probe(struct i2c_client *client)
if (ret < 0)
goto out_err;
- pm_runtime_enable(&client->dev);
+ ret = devm_pm_runtime_enable(&client->dev);
+ if (ret)
+ goto out_err;
pm_runtime_set_autosuspend_delay(&client->dev,
PA12203001_SLEEP_DELAY_MS);
pm_runtime_use_autosuspend(&client->dev);
@@ -395,9 +397,6 @@ static void pa12203001_remove(struct i2c_client *client)
iio_device_unregister(indio_dev);
- pm_runtime_disable(&client->dev);
- pm_runtime_set_suspended(&client->dev);
-
ret = pa12203001_power_chip(indio_dev, PA12203001_CHIP_DISABLE);
if (ret)
dev_warn(&client->dev, "Failed to power down (%pe)\n",
--
2.43.0