[PATCH 4/4] iio: accel: bmi088-accel: use devm_pm_runtime_enable() to fix probe error path
From: Stepan Ionichev
Date: Fri May 29 2026 - 06:46:07 EST
The probe path calls pm_runtime_enable() and then registers the IIO device with iio_device_register(). If registration fails, the function returns the error directly without calling pm_runtime_disable(), leaving the runtime PM enable_count unbalanced. On the next bind attempt the core warns with "Unbalanced pm_runtime_enable".
Switch to devm_pm_runtime_enable() so the enable is automatically undone when the device is unbound, regardless of whether the rest of probe (or the bus remove callback) succeeds. This makes the error path correct without adding a new goto label.
With the runtime PM teardown now handled by the devm action, the manual pm_runtime_disable() and pm_runtime_set_suspended() calls in bmi088_accel_core_remove() become redundant and are dropped. The hardware-level power_down() call is kept so the chip is placed in suspend mode before the regmap goes away.
Signed-off-by: Stepan Ionichev <sozdayvek@xxxxxxxxx>
---
drivers/iio/accel/bmi088-accel-core.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/iio/accel/bmi088-accel-core.c b/drivers/iio/accel/bmi088-accel-core.c
index c7da90af0d2d..0fd840d85a15 100644
--- a/drivers/iio/accel/bmi088-accel-core.c
+++ b/drivers/iio/accel/bmi088-accel-core.c
@@ -573,7 +573,9 @@ int bmi088_accel_core_probe(struct device *dev, struct regmap *regmap,
/* Enable runtime PM */
pm_runtime_get_noresume(dev);
pm_runtime_set_suspended(dev);
- pm_runtime_enable(dev);
+ ret = devm_pm_runtime_enable(dev);
+ if (ret)
+ return ret;
/* We need ~6ms to startup, so set the delay to 6 seconds */
pm_runtime_set_autosuspend_delay(dev, 6000);
pm_runtime_use_autosuspend(dev);
@@ -595,8 +597,6 @@ void bmi088_accel_core_remove(struct device *dev)
iio_device_unregister(indio_dev);
- pm_runtime_disable(dev);
- pm_runtime_set_suspended(dev);
bmi088_accel_power_down(data);
}
EXPORT_SYMBOL_NS_GPL(bmi088_accel_core_remove, "IIO_BMI088");
--
2.43.0