Skip to content

Commit 0a2bf92

Browse files
jmaneyrol-invnjic23
authored andcommitted
iio: imu: inv_mpu6050: fix suspend/resume with runtime power
Suspend/resume were not working correctly with pm runtime. Now suspend check if the chip is already suspended, and resume put runtime pm in the correct state. Issues seen prior to this were: When entering suspend, there was an error in logs because we were disabling vddio regulator although it was already disabled. And when resuming, the chip was pull back to full power but the pm_runtime state was not updated. So it was believing it was still suspended. Fixes: 4599cac ("iio: imu: inv_mpu6050: use runtime pm with autosuspend") Signed-off-by: Jean-Baptiste Maneyrol <[email protected]> Signed-off-by: Jonathan Cameron <[email protected]>
1 parent e450e07 commit 0a2bf92

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

drivers/iio/imu/inv_mpu6050/inv_mpu_core.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1617,6 +1617,10 @@ static int __maybe_unused inv_mpu_resume(struct device *dev)
16171617
if (result)
16181618
goto out_unlock;
16191619

1620+
pm_runtime_disable(dev);
1621+
pm_runtime_set_active(dev);
1622+
pm_runtime_enable(dev);
1623+
16201624
result = inv_mpu6050_switch_engine(st, true, st->suspended_sensors);
16211625
if (result)
16221626
goto out_unlock;
@@ -1638,13 +1642,18 @@ static int __maybe_unused inv_mpu_suspend(struct device *dev)
16381642

16391643
mutex_lock(&st->lock);
16401644

1645+
st->suspended_sensors = 0;
1646+
if (pm_runtime_suspended(dev)) {
1647+
result = 0;
1648+
goto out_unlock;
1649+
}
1650+
16411651
if (iio_buffer_enabled(indio_dev)) {
16421652
result = inv_mpu6050_prepare_fifo(st, false);
16431653
if (result)
16441654
goto out_unlock;
16451655
}
16461656

1647-
st->suspended_sensors = 0;
16481657
if (st->chip_config.accl_en)
16491658
st->suspended_sensors |= INV_MPU6050_SENSOR_ACCL;
16501659
if (st->chip_config.gyro_en)

0 commit comments

Comments
 (0)