[PATCH v2 07/17] iio: adc: ti-ads1015: Discard pm_runtime_put_autosuspend() return values

From: Brian Norris

Date: Wed Oct 21 2026 - 20:10:11 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. Inline
ads1015_set_power_state() while we're at it, since its behavior is now
the same with and without CONFIG_PM, and it is otherwise trivial.

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/adc/ti-ads1015.c | 50 +++++++++++++-----------------------
1 file changed, 18 insertions(+), 32 deletions(-)

diff --git a/drivers/iio/adc/ti-ads1015.c b/drivers/iio/adc/ti-ads1015.c
index 0f9244107c6d..a677ec7abda2 100644
--- a/drivers/iio/adc/ti-ads1015.c
+++ b/drivers/iio/adc/ti-ads1015.c
@@ -367,30 +367,6 @@ static const struct iio_chan_spec tla2024_channels[] = {
IIO_CHAN_SOFT_TIMESTAMP(ADS1015_TIMESTAMP),
};

-
-#ifdef CONFIG_PM
-static int ads1015_set_power_state(struct ads1015_data *data, bool on)
-{
- int ret;
- struct device *dev = regmap_get_device(data->regmap);
-
- if (on)
- ret = pm_runtime_resume_and_get(dev);
- else
- ret = pm_runtime_put_autosuspend(dev);
-
- return ret < 0 ? ret : 0;
-}
-
-#else /* !CONFIG_PM */
-
-static int ads1015_set_power_state(struct ads1015_data *data, bool on)
-{
- return 0;
-}
-
-#endif /* !CONFIG_PM */
-
static
int ads1015_get_adc_result(struct ads1015_data *data, int chan, int *val)
{
@@ -533,26 +509,29 @@ static int ads1015_read_avail(struct iio_dev *indio_dev,
static int __ads1015_read_info_raw(struct ads1015_data *data,
struct iio_chan_spec const *chan, int *val)
{
+ struct device *dev = regmap_get_device(data->regmap);
int ret;

if (ads1015_event_channel_enabled(data) &&
data->event_channel != chan->address)
return -EBUSY;

- ret = ads1015_set_power_state(data, true);
+ ret = pm_runtime_resume_and_get(dev);
if (ret < 0)
return ret;

ret = ads1015_get_adc_result(data, chan->address, val);
if (ret < 0) {
- ads1015_set_power_state(data, false);
+ pm_runtime_put_autosuspend(dev);
return ret;
}

*val = sign_extend32(*val >> chan->scan_type.shift,
chan->scan_type.realbits - 1);

- return ads1015_set_power_state(data, false);
+ pm_runtime_put_autosuspend(dev);
+
+ return 0;
}

static int ads1015_read_raw(struct iio_dev *indio_dev,
@@ -708,6 +687,7 @@ static int ads1015_read_event_config(struct iio_dev *indio_dev,
static int ads1015_enable_event_config(struct ads1015_data *data,
const struct iio_chan_spec *chan, int comp_mode)
{
+ struct device *dev = regmap_get_device(data->regmap);
int low_thresh = data->thresh_data[chan->address].low_thresh;
int high_thresh = data->thresh_data[chan->address].high_thresh;
int ret;
@@ -736,7 +716,7 @@ static int ads1015_enable_event_config(struct ads1015_data *data,
if (ret)
return ret;

- ret = ads1015_set_power_state(data, true);
+ ret = pm_runtime_resume_and_get(dev);
if (ret < 0)
return ret;

@@ -745,7 +725,7 @@ static int ads1015_enable_event_config(struct ads1015_data *data,
ret = ads1015_get_adc_result(data, chan->address, &val);
if (ret) {
ads1015_event_channel_disable(data, chan->address);
- ads1015_set_power_state(data, false);
+ pm_runtime_put_autosuspend(dev);
}

return ret;
@@ -775,7 +755,9 @@ static int ads1015_disable_event_config(struct ads1015_data *data,

ads1015_event_channel_disable(data, chan->address);

- return ads1015_set_power_state(data, false);
+ pm_runtime_put_autosuspend(regmap_get_device(data->regmap));
+
+ return 0;
}

static int ads1015_write_event_config(struct iio_dev *indio_dev,
@@ -836,12 +818,16 @@ static int ads1015_buffer_preenable(struct iio_dev *indio_dev)
if (ads1015_event_channel_enabled(data))
return -EBUSY;

- return ads1015_set_power_state(iio_priv(indio_dev), true);
+ return pm_runtime_resume_and_get(regmap_get_device(data->regmap));
}

static int ads1015_buffer_postdisable(struct iio_dev *indio_dev)
{
- return ads1015_set_power_state(iio_priv(indio_dev), false);
+ struct ads1015_data *data = iio_priv(indio_dev);
+
+ pm_runtime_put_autosuspend(regmap_get_device(data->regmap));
+
+ return 0;
}

static const struct iio_buffer_setup_ops ads1015_buffer_setup_ops = {
--
2.56.0.218.g1ec904b173-goog