mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v6] auxdisplay: arm-charlcd: Use DEFINE_SIMPLE_DEV_PM_OPS for power management
@ 2026-08-27  0:28 Li Jun
  2026-08-27  8:03 ` Geert Uytterhoeven
  2026-09-03 11:57 ` Andy Shevchenko
  0 siblings, 2 replies; 4+ messages in thread
From: Li Jun @ 2026-08-27  0:28 UTC (permalink / raw)
  To: lijun01, andy, geert, fourier.thomas, bhelgaas, u.kleine-koenig,
	linux-kernel

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() in v5.
-Add pm_sleep_ptr(&charlcd_pm_ops) for charlcd_driver.
---
 drivers/auxdisplay/arm-charlcd.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/auxdisplay/arm-charlcd.c b/drivers/auxdisplay/arm-charlcd.c
index 70efda4f767e..ea684f3446c3 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", },
@@ -319,7 +316,7 @@ static const struct of_device_id charlcd_match[] = {
 static struct platform_driver charlcd_driver = {
 	.driver = {
 		.name = DRIVERNAME,
-		.pm = &charlcd_pm_ops,
+		.pm = pm_sleep_ptr(&charlcd_pm_ops),
 		.suppress_bind_attrs = true,
 		.of_match_table = charlcd_match,
 	},
-- 
2.25.1


^ permalink raw reply	[flat|nested] 4+ messages in thread
* [PATCH v6] auxdisplay: arm-charlcd: Use DEFINE_SIMPLE_DEV_PM_OPS for power management
@ 2026-08-27  0:40 Li Jun
  0 siblings, 0 replies; 4+ messages in thread
From: Li Jun @ 2026-08-27  0:40 UTC (permalink / raw)
  To: lijun01, andy, geert, fourier.thomas, bhelgaas, u.kleine-koenig,
	linux-kernel

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() in v5.
-Add pm_sleep_ptr(&charlcd_pm_ops) for charlcd_driver.
---
 drivers/auxdisplay/arm-charlcd.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/auxdisplay/arm-charlcd.c b/drivers/auxdisplay/arm-charlcd.c
index 70efda4f767e..ea684f3446c3 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", },
@@ -319,7 +316,7 @@ static const struct of_device_id charlcd_match[] = {
 static struct platform_driver charlcd_driver = {
 	.driver = {
 		.name = DRIVERNAME,
-		.pm = &charlcd_pm_ops,
+		.pm = pm_sleep_ptr(&charlcd_pm_ops),
 		.suppress_bind_attrs = true,
 		.of_match_table = charlcd_match,
 	},
-- 
2.25.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-09-03 11:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-27  0:28 [PATCH v6] auxdisplay: arm-charlcd: Use DEFINE_SIMPLE_DEV_PM_OPS for power management Li Jun
2026-08-27  8:03 ` Geert Uytterhoeven
2026-09-03 11:57 ` Andy Shevchenko
2026-08-27  0:40 Li Jun

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®