Skip to content

Commit 29c57a6

Browse files
sknseangregkh
authored andcommitted
iio: imu: inv_icm42600: Simplify pm_runtime setup
[ Upstream commit 0792c19 ] 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: 31c24c1 ("iio: imu: inv_icm42600: add core of new inv_icm42600 driver") Signed-off-by: Sean Nyekjaer <[email protected]> Link: https://patch.msgid.link/[email protected] Cc: <[email protected]> Signed-off-by: Jonathan Cameron <[email protected]> Signed-off-by: Sasha Levin <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 69a837b commit 29c57a6

File tree

1 file changed

+7
-17
lines changed

1 file changed

+7
-17
lines changed

drivers/iio/imu/inv_icm42600/inv_icm42600_core.c

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -667,20 +667,12 @@ static void inv_icm42600_disable_vdd_reg(void *_data)
667667
static void inv_icm42600_disable_vddio_reg(void *_data)
668668
{
669669
struct inv_icm42600_state *st = _data;
670-
const struct device *dev = regmap_get_device(st->map);
671-
int ret;
672-
673-
ret = regulator_disable(st->vddio_supply);
674-
if (ret)
675-
dev_err(dev, "failed to disable vddio error %d\n", ret);
676-
}
670+
struct device *dev = regmap_get_device(st->map);
677671

678-
static void inv_icm42600_disable_pm(void *_data)
679-
{
680-
struct device *dev = _data;
672+
if (pm_runtime_status_suspended(dev))
673+
return;
681674

682-
pm_runtime_put_sync(dev);
683-
pm_runtime_disable(dev);
675+
regulator_disable(st->vddio_supply);
684676
}
685677

686678
int inv_icm42600_core_probe(struct regmap *regmap, int chip, int irq,
@@ -777,16 +769,14 @@ int inv_icm42600_core_probe(struct regmap *regmap, int chip, int irq,
777769
return ret;
778770

779771
/* setup runtime power management */
780-
ret = pm_runtime_set_active(dev);
772+
ret = devm_pm_runtime_set_active_enabled(dev);
781773
if (ret)
782774
return ret;
783-
pm_runtime_get_noresume(dev);
784-
pm_runtime_enable(dev);
775+
785776
pm_runtime_set_autosuspend_delay(dev, INV_ICM42600_SUSPEND_DELAY_MS);
786777
pm_runtime_use_autosuspend(dev);
787-
pm_runtime_put(dev);
788778

789-
return devm_add_action_or_reset(dev, inv_icm42600_disable_pm, dev);
779+
return ret;
790780
}
791781
EXPORT_SYMBOL_NS_GPL(inv_icm42600_core_probe, IIO_ICM42600);
792782

0 commit comments

Comments
 (0)