iio: imu: inv_icm42600: Simplify pm_runtime setup

Rework the power management in inv_icm42600_core_probe() to use
devm_pm_runtime_set_active_enabled(), which simplifies the runtime PM
setup by handling activation and enabling in one step.
Remove the separate inv_icm42600_disable_pm callback, as it's no longer
needed with the devm-managed approach.
Using devm_pm_runtime_enable() also fixes the missing disable of
autosuspend.
Update inv_icm42600_disable_vddio_reg() to only disable the regulator if
the device is not suspended i.e. powered-down, preventing unbalanced
disables.
Also remove redundant error msg on regulator_disable(), the regulator
framework already emits an error message when regulator_disable() fails.

This simplifies the PM setup and avoids manipulating the usage counter
unnecessarily.

Fixes: 31c24c1e93 ("iio: imu: inv_icm42600: add core of new inv_icm42600 driver")
Signed-off-by: Sean Nyekjaer <sean@geanix.com>
Link: https://patch.msgid.link/20250901-icm42pmreg-v3-1-ef1336246960@geanix.com
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
This commit is contained in:
Sean Nyekjaer
2025-09-01 09:49:13 +02:00
committed by Jonathan Cameron
parent b947d4edfc
commit 0792c1984a

View File

@@ -711,20 +711,12 @@ static void inv_icm42600_disable_vdd_reg(void *_data)
static void inv_icm42600_disable_vddio_reg(void *_data) static void inv_icm42600_disable_vddio_reg(void *_data)
{ {
struct inv_icm42600_state *st = _data; struct inv_icm42600_state *st = _data;
const struct device *dev = regmap_get_device(st->map); struct device *dev = regmap_get_device(st->map);
int ret;
ret = regulator_disable(st->vddio_supply); if (pm_runtime_status_suspended(dev))
if (ret) return;
dev_err(dev, "failed to disable vddio error %d\n", ret);
}
static void inv_icm42600_disable_pm(void *_data) regulator_disable(st->vddio_supply);
{
struct device *dev = _data;
pm_runtime_put_sync(dev);
pm_runtime_disable(dev);
} }
int inv_icm42600_core_probe(struct regmap *regmap, int chip, int inv_icm42600_core_probe(struct regmap *regmap, int chip,
@@ -824,16 +816,14 @@ int inv_icm42600_core_probe(struct regmap *regmap, int chip,
return ret; return ret;
/* setup runtime power management */ /* setup runtime power management */
ret = pm_runtime_set_active(dev); ret = devm_pm_runtime_set_active_enabled(dev);
if (ret) if (ret)
return ret; return ret;
pm_runtime_get_noresume(dev);
pm_runtime_enable(dev);
pm_runtime_set_autosuspend_delay(dev, INV_ICM42600_SUSPEND_DELAY_MS); pm_runtime_set_autosuspend_delay(dev, INV_ICM42600_SUSPEND_DELAY_MS);
pm_runtime_use_autosuspend(dev); pm_runtime_use_autosuspend(dev);
pm_runtime_put(dev);
return devm_add_action_or_reset(dev, inv_icm42600_disable_pm, dev); return ret;
} }
EXPORT_SYMBOL_NS_GPL(inv_icm42600_core_probe, "IIO_ICM42600"); EXPORT_SYMBOL_NS_GPL(inv_icm42600_core_probe, "IIO_ICM42600");