Skip to content

Commit 466f7a2

Browse files
sknseanjic23
authored andcommitted
iio: imu: inv_icm42600: Avoid configuring if already pm_runtime suspended
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]>
1 parent a95a0b4 commit 466f7a2

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
@@ -837,17 +837,15 @@ static int inv_icm42600_suspend(struct device *dev)
837837
struct device *accel_dev;
838838
bool wakeup;
839839
int accel_conf;
840-
int ret;
840+
int ret = 0;
841841

842842
mutex_lock(&st->lock);
843843

844844
st->suspended.gyro = st->conf.gyro.mode;
845845
st->suspended.accel = st->conf.accel.mode;
846846
st->suspended.temp = st->conf.temp_en;
847-
if (pm_runtime_suspended(dev)) {
848-
ret = 0;
847+
if (pm_runtime_suspended(dev))
849848
goto out_unlock;
850-
}
851849

852850
/* disable FIFO data streaming */
853851
if (st->fifo.on) {
@@ -900,10 +898,13 @@ static int inv_icm42600_resume(struct device *dev)
900898
struct inv_icm42600_sensor_state *accel_st = iio_priv(st->indio_accel);
901899
struct device *accel_dev;
902900
bool wakeup;
903-
int ret;
901+
int ret = 0;
904902

905903
mutex_lock(&st->lock);
906904

905+
if (pm_runtime_suspended(dev))
906+
goto out_unlock;
907+
907908
/* check wakeup capability */
908909
accel_dev = &st->indio_accel->dev;
909910
wakeup = st->apex.on && device_may_wakeup(accel_dev);

0 commit comments

Comments
 (0)