[PATCH v2 5/6] iio: accel: mma8452: use pm_ptr() for dev_pm_ops
From: Sanjay Chitroda
Date: Wed Apr 22 2026 - 13:03:34 EST
From: Sanjay Chitroda <sanjayembeddedse@xxxxxxxxx>
Use pm_ptr() and DEFINE_RUNTIME_DEV_PM_OPS() so the PM ops pointer is
automatically handle when CONFIG_PM is enabled/disabled. This follows
modern kernel power-management conventions.
Signed-off-by: Sanjay Chitroda <sanjayembeddedse@xxxxxxxxx>
---
Changes in v2:
- Use DEFINE_RUNTIME_DEV_PM_OPS to address review comment and resolve 0-day bot warning
- Link to v1: https://lore.kernel.org/all/20260414192045.3598010-1-sanjayembedded@xxxxxxxxx/
---
drivers/iio/accel/mma8452.c | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c
index d1ae2bf37409..9983f76a8bcd 100644
--- a/drivers/iio/accel/mma8452.c
+++ b/drivers/iio/accel/mma8452.c
@@ -1747,7 +1747,6 @@ static void mma8452_remove(struct i2c_client *client)
regulator_disable(data->vdd_reg);
}
-#ifdef CONFIG_PM
static int mma8452_runtime_suspend(struct device *dev)
{
struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
@@ -1815,13 +1814,9 @@ static int mma8452_runtime_resume(struct device *dev)
return ret;
}
-#endif
-static const struct dev_pm_ops mma8452_pm_ops = {
- SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume)
- SET_RUNTIME_PM_OPS(mma8452_runtime_suspend,
- mma8452_runtime_resume, NULL)
-};
+static DEFINE_RUNTIME_DEV_PM_OPS(mma8452_pm_ops, mma8452_runtime_suspend,
+ mma8452_runtime_resume, NULL);
static const struct i2c_device_id mma8452_id[] = {
{ "fxls8471", (kernel_ulong_t)&mma_chip_info_table[fxls8471] },
@@ -1838,7 +1833,7 @@ static struct i2c_driver mma8452_driver = {
.driver = {
.name = "mma8452",
.of_match_table = mma8452_dt_ids,
- .pm = &mma8452_pm_ops,
+ .pm = pm_ptr(&mma8452_pm_ops),
},
.probe = mma8452_probe,
.remove = mma8452_remove,
--
2.34.1