Commit 6fbaebae authored by Jonathan Cameron's avatar Jonathan Cameron

iio: light: tsl2583: Balance runtime pm + use pm_runtime_resume_and_get()

Error paths in read_raw() and write_raw() callbacks failed to perform and
type of runtime pm put().  Remove called pm_runtime_put_noidle()
but there is no equivalent get (this is safe because the reference
count is protected against going below zero, but it is misleading.

Whilst here use pm_runtime_resume_and_get() to replace boilerplate.
Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Brian Masney <masneyb@onstation.org>
Reviewed-by: default avatarBrian Masney <masneyb@onstation.org>
Reviewed-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Link: https://lore.kernel.org/r/20210509113354.660190-4-jic23@kernel.org
parent a2fa3deb
...@@ -644,9 +644,7 @@ static int tsl2583_set_pm_runtime_busy(struct tsl2583_chip *chip, bool on) ...@@ -644,9 +644,7 @@ static int tsl2583_set_pm_runtime_busy(struct tsl2583_chip *chip, bool on)
int ret; int ret;
if (on) { if (on) {
ret = pm_runtime_get_sync(&chip->client->dev); ret = pm_runtime_resume_and_get(&chip->client->dev);
if (ret < 0)
pm_runtime_put_noidle(&chip->client->dev);
} else { } else {
pm_runtime_mark_last_busy(&chip->client->dev); pm_runtime_mark_last_busy(&chip->client->dev);
ret = pm_runtime_put_autosuspend(&chip->client->dev); ret = pm_runtime_put_autosuspend(&chip->client->dev);
...@@ -729,8 +727,10 @@ static int tsl2583_read_raw(struct iio_dev *indio_dev, ...@@ -729,8 +727,10 @@ static int tsl2583_read_raw(struct iio_dev *indio_dev,
read_done: read_done:
mutex_unlock(&chip->als_mutex); mutex_unlock(&chip->als_mutex);
if (ret < 0) if (ret < 0) {
tsl2583_set_pm_runtime_busy(chip, false);
return ret; return ret;
}
/* /*
* Preserve the ret variable if the call to * Preserve the ret variable if the call to
...@@ -791,8 +791,10 @@ static int tsl2583_write_raw(struct iio_dev *indio_dev, ...@@ -791,8 +791,10 @@ static int tsl2583_write_raw(struct iio_dev *indio_dev,
mutex_unlock(&chip->als_mutex); mutex_unlock(&chip->als_mutex);
if (ret < 0) if (ret < 0) {
tsl2583_set_pm_runtime_busy(chip, false);
return ret; return ret;
}
ret = tsl2583_set_pm_runtime_busy(chip, false); ret = tsl2583_set_pm_runtime_busy(chip, false);
if (ret < 0) if (ret < 0)
...@@ -880,7 +882,6 @@ static int tsl2583_remove(struct i2c_client *client) ...@@ -880,7 +882,6 @@ static int tsl2583_remove(struct i2c_client *client)
pm_runtime_disable(&client->dev); pm_runtime_disable(&client->dev);
pm_runtime_set_suspended(&client->dev); pm_runtime_set_suspended(&client->dev);
pm_runtime_put_noidle(&client->dev);
return tsl2583_set_power_state(chip, TSL2583_CNTL_PWR_OFF); return tsl2583_set_power_state(chip, TSL2583_CNTL_PWR_OFF);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment