[PATCH 2/4] iio: light: us5182d: use devm_pm_runtime_enable() to fix probe error path
From: Stepan Ionichev
Date: Fri May 29 2026 - 06:49:03 EST
us5182d_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 shutdown_en() cleanup
stays in step with the rest of the manual unwind. The pm_runtime_disable()
and pm_runtime_set_suspended() calls in us5182d_remove() are dropped; the
devm action runs after .remove() and handles the teardown.
Signed-off-by: Stepan Ionichev <sozdayvek@xxxxxxxxx>
---
drivers/iio/light/us5182d.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/iio/light/us5182d.c b/drivers/iio/light/us5182d.c
index d2f5a44892a8..ada75f710bfc 100644
--- a/drivers/iio/light/us5182d.c
+++ b/drivers/iio/light/us5182d.c
@@ -880,7 +880,9 @@ static int us5182d_probe(struct i2c_client *client)
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,
US5182D_SLEEP_MS);
pm_runtime_use_autosuspend(&client->dev);
@@ -904,9 +906,6 @@ static void us5182d_remove(struct i2c_client *client)
iio_device_unregister(i2c_get_clientdata(client));
- pm_runtime_disable(&client->dev);
- pm_runtime_set_suspended(&client->dev);
-
ret = us5182d_shutdown_en(data, US5182D_CFG0_SHUTDOWN_EN);
if (ret)
dev_warn(&client->dev, "Failed to shut down (%pe)\n",
--
2.43.0