Skip to content

Commit 7e708db

Browse files
sknseangregkh
authored andcommitted
iio: imu: inv_icm42600: Avoid configuring if already pm_runtime suspended
[ Upstream commit 466f7a2 ] Do as in suspend, skip resume configuration steps if the device is already pm_runtime suspended. This avoids reconfiguring a device that is already in the correct low-power state and ensures that pm_runtime handles the power state transitions properly. 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]> [ removed apex/wakeup variable declarations ] Signed-off-by: Sasha Levin <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 29c57a6 commit 7e708db

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

drivers/iio/imu/inv_icm42600/inv_icm42600_core.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -787,17 +787,15 @@ EXPORT_SYMBOL_NS_GPL(inv_icm42600_core_probe, IIO_ICM42600);
787787
static int inv_icm42600_suspend(struct device *dev)
788788
{
789789
struct inv_icm42600_state *st = dev_get_drvdata(dev);
790-
int ret;
790+
int ret = 0;
791791

792792
mutex_lock(&st->lock);
793793

794794
st->suspended.gyro = st->conf.gyro.mode;
795795
st->suspended.accel = st->conf.accel.mode;
796796
st->suspended.temp = st->conf.temp_en;
797-
if (pm_runtime_suspended(dev)) {
798-
ret = 0;
797+
if (pm_runtime_suspended(dev))
799798
goto out_unlock;
800-
}
801799

802800
/* disable FIFO data streaming */
803801
if (st->fifo.on) {
@@ -829,10 +827,13 @@ static int inv_icm42600_resume(struct device *dev)
829827
struct inv_icm42600_state *st = dev_get_drvdata(dev);
830828
struct inv_icm42600_sensor_state *gyro_st = iio_priv(st->indio_gyro);
831829
struct inv_icm42600_sensor_state *accel_st = iio_priv(st->indio_accel);
832-
int ret;
830+
int ret = 0;
833831

834832
mutex_lock(&st->lock);
835833

834+
if (pm_runtime_suspended(dev))
835+
goto out_unlock;
836+
836837
ret = inv_icm42600_enable_regulator_vddio(st);
837838
if (ret)
838839
goto out_unlock;

0 commit comments

Comments
 (0)