[PATCH v2 12/17] iio: imu: kmx61: Discard pm_runtime_put_autosuspend() return values

From: Brian Norris

Date: Wed Oct 21 2026 - 20:04:34 EST


The kmx61 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.

Note: kmx61_set_power_state() is a possible inlining candidate, but it
performs some non-trivial logic on the {acc,mag}_ps fields, so I leave
it alone.

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

drivers/iio/imu/kmx61.c | 25 ++++++++++---------------
1 file changed, 10 insertions(+), 15 deletions(-)

diff --git a/drivers/iio/imu/kmx61.c b/drivers/iio/imu/kmx61.c
index a4962b88ef58..9d626882adb0 100644
--- a/drivers/iio/imu/kmx61.c
+++ b/drivers/iio/imu/kmx61.c
@@ -747,16 +747,15 @@ static int kmx61_set_power_state(struct kmx61_data *data, bool on, u8 device)
data->mag_ps = on;
}

- if (on)
+ if (on) {
ret = pm_runtime_resume_and_get(&data->client->dev);
- else
- ret = pm_runtime_put_autosuspend(&data->client->dev);
- if (ret < 0) {
- dev_err(&data->client->dev,
- "Failed: kmx61_set_power_state for %d, ret %d\n",
- on, ret);
-
- return ret;
+ if (ret < 0) {
+ dev_err(&data->client->dev,
+ "%s: failed to resume: %d\n", __func__, ret);
+ return ret;
+ }
+ } else {
+ pm_runtime_put_autosuspend(&data->client->dev);
}
#endif
return 0;
@@ -801,15 +800,11 @@ static int kmx61_read_raw(struct iio_dev *indio_dev,
return ret;

ret = kmx61_read_measurement(data, base_reg, chan->scan_index);
- if (ret < 0) {
- kmx61_set_power_state(data, false, chan->address);
+ kmx61_set_power_state(data, false, chan->address);
+ if (ret < 0)
return ret;
- }
*val = sign_extend32(ret >> chan->scan_type.shift,
chan->scan_type.realbits - 1);
- ret = kmx61_set_power_state(data, false, chan->address);
- if (ret)
- return ret;
return IIO_VAL_INT;
}
case IIO_CHAN_INFO_SCALE:
--
2.56.0.218.g1ec904b173-goog