Re: [PATCH v2 03/17] iio: accel: mma8452: Discard pm_runtime_put_autosuspend() return values

From: Andy Shevchenko

Date: Thu Oct 22 2026 - 03:00:32 EST


On Wed, Oct 21, 2026 at 04:57:04PM -0700, Brian Norris 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 pm_runtime
> helper, since the behavior is the same with and without CONFIG_PM.
>
> While I'm at it: I see that mma8452_data_rdy_trigger_set_state() and
> mma8452_write_event_config() mismanage the runtime PM reference count,
> and instead rely on (racy) autosuspend delay for correct ordering.
> Undo this choice, and instead properly drop the reference count only
> after we're done touching the hardware.
>
> 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").

...

> static int mma8452_read(struct mma8452_data *data, __be16 buf[3])

> - ret = mma8452_set_runtime_pm_state(data->client, true);
> - if (ret)
> + ret = pm_runtime_resume_and_get(&data->client->dev);
> + if (ret < 0) {
> + dev_err(&data->client->dev, "failed to resume: %d\n", ret);
> return ret;
> + }
>
> ret = i2c_smbus_read_i2c_block_data(data->client, MMA8452_OUT_X,
> 3 * sizeof(__be16), (u8 *)buf);
> if (ret < 0)
> return ret;
>
> - ret = mma8452_set_runtime_pm_state(data->client, false);
> + pm_runtime_put_autosuspend(&data->client->dev);
>
> - return ret;
> + return 0;

Now it can use PM_RUNTIME_ACQUIRE*(), no?

> }

--
With Best Regards,
Andy Shevchenko