Re: [PATCH] iio: accel: mma8452: use pm_ptr() for dev_pm_ops

From: Sanjay Chitroda

Date: Mon Apr 20 2026 - 21:53:42 EST




On 20 April 2026 1:36:14 pm IST, Geert Uytterhoeven <geert@xxxxxxxxxxxxxx> wrote:
>Hi Sanjay,
>
>On Tue, 14 Apr 2026 at 21:20, Sanjay Chitroda
><sanjayembeddedse@xxxxxxxxx> wrote:
>> From: Sanjay Chitroda <sanjayembeddedse@xxxxxxxxx>
>>
>> Use pm_ptr() so the PM ops pointer is automatically set to
>> NULL when CONFIG_PM is disabled. This avoids unused-function warnings
>> and follows modern kernel power-management conventions.
>>
>> Signed-off-by: Sanjay Chitroda <sanjayembeddedse@xxxxxxxxx>
>
>Thanks for your patch!
>
>> --- a/drivers/iio/accel/mma8452.c
>> +++ b/drivers/iio/accel/mma8452.c
>> @@ -1744,7 +1744,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));
>> @@ -1812,7 +1811,6 @@ 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)
>
>You are still getting defined but not used warnings, as reported by
>the kernel test robot, due to the use of SET_SYSTEM_SLEEP_PM_OPS()
>and SET_RUNTIME_PM_OPS(). Please define the structure using
>DEFINE_RUNTIME_DEV_PM_OPS() to fix this.
>
>> @@ -1835,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,
>
>Gr{oetje,eeting}s,
>
> Geert
>
Hi Greet,

Thank you for the review and feedback.
I will update changes in next version.

Thank,
Sanjay Chitroda