[PATCH 1/4] iio: light: isl29028: use devm_pm_runtime_enable() to fix probe error path
From: Stepan Ionichev
Date: Fri May 29 2026 - 06:51:43 EST
isl29028_probe() calls pm_runtime_enable() before iio_device_register(). If iio_device_register() fails, the probe returns directly without calling pm_runtime_disable(), leaving the runtime PM enable_count unbalanced. On the next probe attempt the kernel logs "Unbalanced pm_runtime_enable".
Switch to devm_pm_runtime_enable() so the runtime PM state is unwound automatically on probe failure and on driver detach. Propagate its return value with a direct return on error.
With runtime PM now managed by devres, isl29028_remove() no longer needs to call pm_runtime_disable() and pm_runtime_set_suspended() explicitly; drop those two calls. The remaining isl29028_clear_configure_reg() write does not depend on the runtime PM state.
Signed-off-by: Stepan Ionichev <sozdayvek@xxxxxxxxx>
---
drivers/iio/light/isl29028.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/iio/light/isl29028.c b/drivers/iio/light/isl29028.c
index 374bccad9119..4fb0262b214a 100644
--- a/drivers/iio/light/isl29028.c
+++ b/drivers/iio/light/isl29028.c
@@ -615,7 +615,9 @@ static int isl29028_probe(struct i2c_client *client)
indio_dev->name = id->name;
indio_dev->modes = INDIO_DIRECT_MODE;
- pm_runtime_enable(&client->dev);
+ ret = devm_pm_runtime_enable(&client->dev);
+ if (ret)
+ return ret;
pm_runtime_set_autosuspend_delay(&client->dev,
ISL29028_POWER_OFF_DELAY_MS);
pm_runtime_use_autosuspend(&client->dev);
@@ -638,9 +640,6 @@ static void isl29028_remove(struct i2c_client *client)
iio_device_unregister(indio_dev);
- pm_runtime_disable(&client->dev);
- pm_runtime_set_suspended(&client->dev);
-
isl29028_clear_configure_reg(chip);
}
--
2.43.0