[PATCH v5] auxdisplay: arm-charlcd: Use DEFINE_SIMPLE_DEV_PM_OPS for power management

Li Jun posted 1 patch 1 month ago
There is a newer version of this series
drivers/auxdisplay/arm-charlcd.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
[PATCH v5] auxdisplay: arm-charlcd: Use DEFINE_SIMPLE_DEV_PM_OPS for power management
Posted by Li Jun 1 month ago
Replace the manually defined dev_pm_ops structure with the
DEFINE_SIMPLE_DEV_PM_OPS macro to simplify the power management
code, pm_sleep_ptr() to safely drop the references without
triggering compiler warnings. This macro automatically handles
CONFIG_PM_SLEEP configuration and generates freeze/thaw/poweroff/restore
callbacks, reducing boilerplate code.

Signed-off-by: Li Jun <lijun01@kylinos.cn>

---
Changes:
-Replace SIMPLE_DEV_PM_OPS() in v1 v2 with DEFINE_SIMPLE_DEV_PM_OPS() for pm.
-Corrected grammar errors in v1 v3 comment.
-Add a description of pm_sleep_ptr().
---
 drivers/auxdisplay/arm-charlcd.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/auxdisplay/arm-charlcd.c b/drivers/auxdisplay/arm-charlcd.c
index 70efda4f767e..cdd6a0bfca05 100644
--- a/drivers/auxdisplay/arm-charlcd.c
+++ b/drivers/auxdisplay/arm-charlcd.c
@@ -306,10 +306,7 @@ static int charlcd_resume(struct device *dev)
 	return 0;
 }
 
-static const struct dev_pm_ops charlcd_pm_ops = {
-	.suspend = charlcd_suspend,
-	.resume = charlcd_resume,
-};
+static DEFINE_SIMPLE_DEV_PM_OPS(charlcd_pm_ops, charlcd_suspend, charlcd_resume);
 
 static const struct of_device_id charlcd_match[] = {
 	{ .compatible = "arm,versatile-lcd", },
-- 
2.25.1
Re: [PATCH v5] auxdisplay: arm-charlcd: Use DEFINE_SIMPLE_DEV_PM_OPS for power management
Posted by Geert Uytterhoeven 1 month ago
Hi Li,

On Tue, 25 Aug 2026 at 12:37, Li Jun <lijun01@kylinos.cn> wrote:
> Replace the manually defined dev_pm_ops structure with the
> DEFINE_SIMPLE_DEV_PM_OPS macro to simplify the power management
> code, pm_sleep_ptr() to safely drop the references without
> triggering compiler warnings. This macro automatically handles
> CONFIG_PM_SLEEP configuration and generates freeze/thaw/poweroff/restore
> callbacks, reducing boilerplate code.
>
> Signed-off-by: Li Jun <lijun01@kylinos.cn>

Thanks for the update!

> Changes:
> -Replace SIMPLE_DEV_PM_OPS() in v1 v2 with DEFINE_SIMPLE_DEV_PM_OPS() for pm.
> -Corrected grammar errors in v1 v3 comment.
> -Add a description of pm_sleep_ptr().

But it is still not used?

> --- a/drivers/auxdisplay/arm-charlcd.c
> +++ b/drivers/auxdisplay/arm-charlcd.c
> @@ -306,10 +306,7 @@ static int charlcd_resume(struct device *dev)
>         return 0;
>  }
>
> -static const struct dev_pm_ops charlcd_pm_ops = {
> -       .suspend = charlcd_suspend,
> -       .resume = charlcd_resume,
> -};
> +static DEFINE_SIMPLE_DEV_PM_OPS(charlcd_pm_ops, charlcd_suspend, charlcd_resume);
>
>  static const struct of_device_id charlcd_match[] = {
>         { .compatible = "arm,versatile-lcd", },

Missing:

    -    .pm = &charlcd_pm_ops,
    +   .pm = pm_sleep_ptr(&charlcd_pm_ops),

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
Re: [PATCH v5] auxdisplay: arm-charlcd: Use DEFINE_SIMPLE_DEV_PM_OPS for power management
Posted by lijun 1 month ago
I forgot the most important thing, so sorry.

  2026/8/26 02:09, Geert Uytterhoeven :
> Hi Li,
>
> On Tue, 25 Aug 2026 at 12:37, Li Jun <lijun01@kylinos.cn> wrote:
>> Replace the manually defined dev_pm_ops structure with the
>> DEFINE_SIMPLE_DEV_PM_OPS macro to simplify the power management
>> code, pm_sleep_ptr() to safely drop the references without
>> triggering compiler warnings. This macro automatically handles
>> CONFIG_PM_SLEEP configuration and generates freeze/thaw/poweroff/restore
>> callbacks, reducing boilerplate code.
>>
>> Signed-off-by: Li Jun <lijun01@kylinos.cn>
> Thanks for the update!
>
>> Changes:
>> -Replace SIMPLE_DEV_PM_OPS() in v1 v2 with DEFINE_SIMPLE_DEV_PM_OPS() for pm.
>> -Corrected grammar errors in v1 v3 comment.
>> -Add a description of pm_sleep_ptr().
> But it is still not used?
>
>> --- a/drivers/auxdisplay/arm-charlcd.c
>> +++ b/drivers/auxdisplay/arm-charlcd.c
>> @@ -306,10 +306,7 @@ static int charlcd_resume(struct device *dev)
>>          return 0;
>>   }
>>
>> -static const struct dev_pm_ops charlcd_pm_ops = {
>> -       .suspend = charlcd_suspend,
>> -       .resume = charlcd_resume,
>> -};
>> +static DEFINE_SIMPLE_DEV_PM_OPS(charlcd_pm_ops, charlcd_suspend, charlcd_resume);
>>
>>   static const struct of_device_id charlcd_match[] = {
>>          { .compatible = "arm,versatile-lcd", },
> Missing:
>
>      -    .pm = &charlcd_pm_ops,
>      +   .pm = pm_sleep_ptr(&charlcd_pm_ops),
>
> Gr{oetje,eeting}s,
>
>                          Geert
>