Re: [PATCH v3 08/10] iio: accel: mma8452: use pm_ptr() and direct runtime PM calls

Andy Shevchenko
2026-05-06T09:42:26Z

On Tue, May 05, 2026 at 11:16:38PM +0530, Sanjay Chitroda wrote:

> Use pm_ptr() together with DEFINE_RUNTIME_DEV_PM_OPS() so the PM ops
> pointer is automatically handled when CONFIG_PM is enabled or disabled.
>
> Switch to direct PM runtime calls and drop
> mma8452_set_runtime_pm_state() wrapper, which is no longer needed.
> This follows modern kernel power-management conventions.

...

> static int mma8452_data_rdy_trigger_set_state(struct iio_trigger *trig,

> {
> struct iio_dev *indio_dev = iio_trigger_get_drvdata(trig);
> struct mma8452_data *data = iio_priv(indio_dev);
> + struct device *dev = &data->client->dev;

> +

Stray blank line.

> int reg, ret;
>
> - ret = mma8452_set_runtime_pm_state(data->client, state);
> - if (ret)
> + if (state)
> + ret = pm_runtime_resume_and_get(dev);
> + else
> + ret = pm_runtime_put_autosuspend(dev);

Hmm... Do we care about autosuspend returned value? What is its meaning?

> + if (ret < 0)
> return ret;

...

> +static DEFINE_RUNTIME_DEV_PM_OPS(mma8452_pm_ops, mma8452_runtime_suspend,
> + mma8452_runtime_resume, NULL);

Use logical split

static DEFINE_RUNTIME_DEV_PM_OPS(mma8452_pm_ops,
mma8452_runtime_suspend, mma8452_runtime_resume, NULL);

OR

static DEFINE_RUNTIME_DEV_PM_OPS(mma8452_pm_ops,
mma8452_runtime_suspend,
mma8452_runtime_resume,
NULL);

--
With Best Regards,
Andy Shevchenko