Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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: 31c24c1e93c3 ("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>

authored by

Sean Nyekjaer and committed by
Jonathan Cameron
0792c198 b947d4ed

+7 -17
+7 -17
drivers/iio/imu/inv_icm42600/inv_icm42600_core.c
··· 711 711 static void inv_icm42600_disable_vddio_reg(void *_data) 712 712 { 713 713 struct inv_icm42600_state *st = _data; 714 - const struct device *dev = regmap_get_device(st->map); 715 - int ret; 714 + struct device *dev = regmap_get_device(st->map); 716 715 717 - ret = regulator_disable(st->vddio_supply); 718 - if (ret) 719 - dev_err(dev, "failed to disable vddio error %d\n", ret); 720 - } 716 + if (pm_runtime_status_suspended(dev)) 717 + return; 721 718 722 - static void inv_icm42600_disable_pm(void *_data) 723 - { 724 - struct device *dev = _data; 725 - 726 - pm_runtime_put_sync(dev); 727 - pm_runtime_disable(dev); 719 + regulator_disable(st->vddio_supply); 728 720 } 729 721 730 722 int inv_icm42600_core_probe(struct regmap *regmap, int chip, ··· 816 824 return ret; 817 825 818 826 /* setup runtime power management */ 819 - ret = pm_runtime_set_active(dev); 827 + ret = devm_pm_runtime_set_active_enabled(dev); 820 828 if (ret) 821 829 return ret; 822 - pm_runtime_get_noresume(dev); 823 - pm_runtime_enable(dev); 830 + 824 831 pm_runtime_set_autosuspend_delay(dev, INV_ICM42600_SUSPEND_DELAY_MS); 825 832 pm_runtime_use_autosuspend(dev); 826 - pm_runtime_put(dev); 827 833 828 - return devm_add_action_or_reset(dev, inv_icm42600_disable_pm, dev); 834 + return ret; 829 835 } 830 836 EXPORT_SYMBOL_NS_GPL(inv_icm42600_core_probe, "IIO_ICM42600"); 831 837