[PATCH 3/4] iio: temperature: mlx90614: use devm_pm_runtime_enable() to fix probe error path

From: Stepan Ionichev

Date: Fri May 29 2026 - 06:45:53 EST


When data->wakeup_gpio is present, mlx90614_probe() enables runtime PM with pm_runtime_enable() and then calls the non-devm iio_device_register(). If iio_device_register() fails, probe returns without calling pm_runtime_disable(), leaving the runtime PM enable_count unbalanced. On a subsequent bind attempt the core complains with "Unbalanced pm_runtime_enable".

Switch to devm_pm_runtime_enable() so the framework disables runtime PM automatically when the device is unbound or when probe fails after this point. The corresponding pm_runtime_disable() and pm_runtime_set_suspended() calls in mlx90614_remove() become redundant and are removed; the existing pm_runtime_status_suspended() check and mlx90614_sleep() call are preserved so the part is still put to sleep on unbind when it was not already runtime-suspended.

The edits stay inside the existing if (data->wakeup_gpio) branches, so devices without a wakeup GPIO are unaffected.

Signed-off-by: Stepan Ionichev <sozdayvek@xxxxxxxxx>
---
drivers/iio/temperature/mlx90614.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/iio/temperature/mlx90614.c b/drivers/iio/temperature/mlx90614.c
index 1ad21b73e1b4..9e09597a1c31 100644
--- a/drivers/iio/temperature/mlx90614.c
+++ b/drivers/iio/temperature/mlx90614.c
@@ -625,7 +625,9 @@ static int mlx90614_probe(struct i2c_client *client)
MLX90614_AUTOSLEEP_DELAY);
pm_runtime_use_autosuspend(&client->dev);
pm_runtime_set_active(&client->dev);
- pm_runtime_enable(&client->dev);
+ ret = devm_pm_runtime_enable(&client->dev);
+ if (ret)
+ return ret;
}

return iio_device_register(indio_dev);
@@ -639,10 +641,8 @@ static void mlx90614_remove(struct i2c_client *client)
iio_device_unregister(indio_dev);

if (data->wakeup_gpio) {
- pm_runtime_disable(&client->dev);
if (!pm_runtime_status_suspended(&client->dev))
mlx90614_sleep(data);
- pm_runtime_set_suspended(&client->dev);
}
}

--
2.43.0