Re: [PATCH v2 11/17] iio: gyro: fxas21002c: Discard pm_runtime_put_autosuspend() return values
From: Jonathan Cameron
Date: Sun Oct 25 2026 - 23:22:23 EST
On Wed, 21 Oct 2026 16:57:12 -0700
Brian Norris <briannorris@xxxxxxxxxxxx> wrote:
> 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 the helpers now
> that they're even more 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>
This one I think does deserve a tweak.
Whether to jump to guard() and ACQUIRE() for 2 out of the 3 cases
is a more complex decision - I messed with it and I think it
makes sense. I'll send out a suggested v3 in a sec with a follow up
doing broader conversion to guard.
> ---
>
> Changes in v2:
> * Split iio patch into per-driver patches
> * Inlining
>
> drivers/iio/gyro/fxas21002c_core.c | 33 ++++++++----------------------
> 1 file changed, 9 insertions(+), 24 deletions(-)
>
> diff --git a/drivers/iio/gyro/fxas21002c_core.c b/drivers/iio/gyro/fxas21002c_core.c
> index a88670207cec..1d891387b121 100644
> --- a/drivers/iio/gyro/fxas21002c_core.c
> +++ b/drivers/iio/gyro/fxas21002c_core.c
> static int fxas21002c_temp_get(struct fxas21002c_data *data, int *val)
> {
> struct device *dev = regmap_get_device(data->regmap);
> @@ -383,22 +371,20 @@ static int fxas21002c_temp_get(struct fxas21002c_data *data, int *val)
> int ret;
>
> mutex_lock(&data->lock);
> - ret = fxas21002c_pm_get(data);
> + ret = pm_runtime_resume_and_get(dev);
> if (ret < 0)
> goto data_unlock;
>
> ret = regmap_field_read(data->regmap_fields[F_TEMP], &temp);
> if (ret < 0) {
> dev_err(dev, "failed to read temp: %d\n", ret);
> - fxas21002c_pm_put(data);
> + pm_runtime_put_autosuspend(dev);
> goto data_unlock;
> }
>
> *val = sign_extend32(temp, 7);
>
> - ret = fxas21002c_pm_put(data);
> - if (ret < 0)
> - goto data_unlock;
> + pm_runtime_put_autosuspend(dev);
Similar to below.
>
> ret = IIO_VAL_INT;
>
> @@ -416,7 +402,7 @@ static int fxas21002c_axis_get(struct fxas21002c_data *data,
> int ret;
>
> mutex_lock(&data->lock);
> - ret = fxas21002c_pm_get(data);
> + ret = pm_runtime_resume_and_get(dev);
> if (ret < 0)
> goto data_unlock;
>
> @@ -424,15 +410,13 @@ static int fxas21002c_axis_get(struct fxas21002c_data *data,
> &axis_be, sizeof(axis_be));
> if (ret < 0) {
> dev_err(dev, "failed to read axis: %d: %d\n", index, ret);
> - fxas21002c_pm_put(data);
> + pm_runtime_put_autosuspend(dev);
See below - tiny tweak and this isn't needed.
> goto data_unlock;
> }
>
> *val = sign_extend32(be16_to_cpu(axis_be), 15);
>
> - ret = fxas21002c_pm_put(data);
> - if (ret < 0)
> - goto data_unlock;
> + pm_runtime_put_autosuspend(dev);
This wants pushing a few lines later as then it can be after
a new label just above data_unlock. With that done we can drop the call of
the same above.
>
> ret = IIO_VAL_INT;
>