pm_runtime_get_sync() increments the usage counter even on failure, so every successful call must be paired with a put. Both sensor read failures returned early and skipped the paired pm_runtime_put_autosuspend(), permanently preventing runtime suspend. Fixes: 0c3a333524a3 ("iio: pressure: mpl115: Implementing low power mode by shutdown gpio") Cc: stable@vger.kernel.org Signed-off-by: Wentao Liang --- drivers/iio/pressure/mpl115.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/iio/pressure/mpl115.c b/drivers/iio/pressure/mpl115.c index 830a5065c008..3266b79bdab8 100644 --- a/drivers/iio/pressure/mpl115.c +++ b/drivers/iio/pressure/mpl115.c @@ -106,8 +106,10 @@ static int mpl115_read_raw(struct iio_dev *indio_dev, case IIO_CHAN_INFO_PROCESSED: pm_runtime_get_sync(data->dev); ret = mpl115_comp_pressure(data, val, val2); - if (ret < 0) + if (ret < 0) { + pm_runtime_put_autosuspend(data->dev); return ret; + } pm_runtime_put_autosuspend(data->dev); return IIO_VAL_INT_PLUS_MICRO; @@ -115,8 +117,10 @@ static int mpl115_read_raw(struct iio_dev *indio_dev, pm_runtime_get_sync(data->dev); /* temperature -5.35 C / LSB, 472 LSB is 25 C */ ret = mpl115_read_temp(data); - if (ret < 0) + if (ret < 0) { + pm_runtime_put_autosuspend(data->dev); return ret; + } pm_runtime_put_autosuspend(data->dev); *val = ret >> 6; -- 2.34.1