[PATCH v2 14/17] iio: light: pa12203001: Discard pm_runtime_put_autosuspend() return values

From: Brian Norris

Date: Wed Oct 21 2026 - 20:06:57 EST


This driver propagates the return value of pm_runtime_put_autosuspend(),
which is not particularly useful.

Returning an error code from pm_runtime_put_autosuspend() merely means
that it has not queued up a timer or work item to check whether or not
the device can be suspended and there are many perfectly valid
situations in which that can happen, like after writing "on" to the
device's runtime PM "control" attribute in sysfs for one example.

For this reason, modify this driver to simply discard the
pm_runtime_put_autosuspend() return value, and inline some of the
runtime PM helper function, now that it behaves the same with and
without CONFIG_PM.

This will facilitate a planned change of the
pm_runtime_put_autosuspend() return type to void in the future, similar
to commit 3afd8df02433 ("PM: runtime: Change pm_runtime_put() return
type to void").

Signed-off-by: Brian Norris <briannorris@xxxxxxxxxxxx>
---

Changes in v2:
* Split iio patch into per-driver patches
* Inlining

drivers/iio/light/pa12203001.c | 26 +++++++++-----------------
1 file changed, 9 insertions(+), 17 deletions(-)

diff --git a/drivers/iio/light/pa12203001.c b/drivers/iio/light/pa12203001.c
index c0f4db8d95f7..0a0502a60a06 100644
--- a/drivers/iio/light/pa12203001.c
+++ b/drivers/iio/light/pa12203001.c
@@ -154,13 +154,12 @@ static inline int pa12203001_px_enable(struct pa12203001_data *data, u8 enable)
return 0;
}

-static int pa12203001_set_power_state(struct pa12203001_data *data, bool on,
- u8 mask)
+static int pa12203001_runtime_resume_and_get(struct pa12203001_data *data, u8 mask)
{
#ifdef CONFIG_PM
int ret;

- if (on && (mask & PA12203001_ALS_EN_MASK)) {
+ if (mask & PA12203001_ALS_EN_MASK) {
mutex_lock(&data->lock);
if (data->px_enabled) {
ret = pa12203001_als_enable(data,
@@ -173,7 +172,7 @@ static int pa12203001_set_power_state(struct pa12203001_data *data, bool on,
mutex_unlock(&data->lock);
}

- if (on && (mask & PA12203001_PX_EN_MASK)) {
+ if (mask & PA12203001_PX_EN_MASK) {
mutex_lock(&data->lock);
if (data->als_enabled) {
ret = pa12203001_px_enable(data, PA12203001_PX_EN_MASK);
@@ -185,10 +184,7 @@ static int pa12203001_set_power_state(struct pa12203001_data *data, bool on,
mutex_unlock(&data->lock);
}

- if (on)
- return pm_runtime_resume_and_get(&data->client->dev);
-
- return pm_runtime_put_autosuspend(&data->client->dev);
+ return pm_runtime_resume_and_get(&data->client->dev);

err:
mutex_unlock(&data->lock);
@@ -213,7 +209,7 @@ static int pa12203001_read_raw(struct iio_dev *indio_dev,
switch (chan->type) {
case IIO_LIGHT:
dev_mask = PA12203001_ALS_EN_MASK;
- ret = pa12203001_set_power_state(data, true, dev_mask);
+ ret = pa12203001_runtime_resume_and_get(data, dev_mask);
if (ret < 0)
return ret;
/*
@@ -226,13 +222,11 @@ static int pa12203001_read_raw(struct iio_dev *indio_dev,
goto reg_err;

*val = le16_to_cpu(reg_word);
- ret = pa12203001_set_power_state(data, false, dev_mask);
- if (ret < 0)
- return ret;
+ pm_runtime_put_autosuspend(&data->client->dev);
break;
case IIO_PROXIMITY:
dev_mask = PA12203001_PX_EN_MASK;
- ret = pa12203001_set_power_state(data, true, dev_mask);
+ ret = pa12203001_runtime_resume_and_get(data, dev_mask);
if (ret < 0)
return ret;
ret = regmap_read(data->map, PA12203001_REG_PDH,
@@ -241,9 +235,7 @@ static int pa12203001_read_raw(struct iio_dev *indio_dev,
goto reg_err;

*val = reg_byte;
- ret = pa12203001_set_power_state(data, false, dev_mask);
- if (ret < 0)
- return ret;
+ pm_runtime_put_autosuspend(&data->client->dev);
break;
default:
return -EINVAL;
@@ -262,7 +254,7 @@ static int pa12203001_read_raw(struct iio_dev *indio_dev,
}

reg_err:
- pa12203001_set_power_state(data, false, dev_mask);
+ pm_runtime_put_autosuspend(&data->client->dev);
return ret;
}

--
2.56.0.218.g1ec904b173-goog