[PATCH v2] ACPI: button: replace SIMPLE_DEV_PM_OPS with DEFINE_SIMPLE_DEV_PM_OPS

Subsystems: acpi, the rest

COOLING12d

3 messages, 2 authors, 12d ago · open the first message on its own page

[PATCH v2] ACPI: button: replace SIMPLE_DEV_PM_OPS with DEFINE_SIMPLE_DEV_PM_OPS

From: Li Jun <hidden>
Date: 2026-09-10 01:50:14

Replace `SIMPLE_DEV_PM_OPS` and `#ifdef CONFIG_PM_SLEEP`
boilerplate with the modern `DEFINE_SIMPLE_DEV_PM_OPS()`
macro in the acpi_button driver.

Signed-off-by: Li Jun <redacted>
---
Changes:
-Add pm_sleep_ptr for acpi_button_pm in acpi_button_driver.
-Fix the warning:
quoted
drivers/acpi/button.c:164:12: warning: function 'acpi_button_suspend' has internal linkage but is not defined [-Wundefined-internal]
     164 | static int acpi_button_suspend(struct device *dev);
         |            ^
   drivers/acpi/button.c:167:49: note: used here
     167 | static DEFINE_SIMPLE_DEV_PM_OPS(acpi_button_pm, acpi_button_suspend, acpi_button_resume);
         |                                                 ^
quoted
drivers/acpi/button.c:165:12: warning: function 'acpi_button_resume' has internal linkage but is not defined [-Wundefined-internal]
     165 | static int acpi_button_resume(struct device *dev);
         |            ^
   drivers/acpi/button.c:167:70: note: used here
     167 | static DEFINE_SIMPLE_DEV_PM_OPS(acpi_button_pm, acpi_button_suspend, acpi_button_resume);
         |                                                                      ^
   2 warnings generated.
---
 drivers/acpi/button.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)
diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c
index cdbb1023a8ee..1df7e268c4dd 100644
--- a/drivers/acpi/button.c
+++ b/drivers/acpi/button.c
@@ -161,14 +161,10 @@ static const struct dmi_system_id dmi_lid_quirks[] = {
 static int acpi_button_probe(struct platform_device *pdev);
 static void acpi_button_remove(struct platform_device *pdev);
 
-#ifdef CONFIG_PM_SLEEP
 static int acpi_button_suspend(struct device *dev);
 static int acpi_button_resume(struct device *dev);
-#else
-#define acpi_button_suspend NULL
-#define acpi_button_resume NULL
-#endif
-static SIMPLE_DEV_PM_OPS(acpi_button_pm, acpi_button_suspend, acpi_button_resume);
+
+static DEFINE_SIMPLE_DEV_PM_OPS(acpi_button_pm, acpi_button_suspend, acpi_button_resume);
 
 static struct platform_driver acpi_button_driver = {
 	.probe = acpi_button_probe,
@@ -176,7 +172,7 @@ static struct platform_driver acpi_button_driver = {
 	.driver = {
 		.name = "acpi-button",
 		.acpi_match_table = button_device_ids,
-		.pm = &acpi_button_pm,
+		.pm = pm_sleep_ptr(&acpi_button_pm),
 	},
 };
 
@@ -502,7 +498,6 @@ static u32 acpi_button_event(void *data)
 	return ACPI_INTERRUPT_HANDLED;
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int acpi_button_suspend(struct device *dev)
 {
 	struct acpi_button *button = dev_get_drvdata(dev);
@@ -532,7 +527,6 @@ static int acpi_button_resume(struct device *dev)
 	}
 	return 0;
 }
-#endif
 
 static int acpi_lid_input_open(struct input_dev *input)
 {
-- 
2.25.1

Re: [PATCH v2] ACPI: button: replace SIMPLE_DEV_PM_OPS with DEFINE_SIMPLE_DEV_PM_OPS

From: "Rafael J. Wysocki (Intel)" <rafael@kernel.org>
Date: 2026-09-10 10:34:06

On Thu, Sep 10, 2026 at 3:50 AM Li Jun [off-list ref] wrote:
Replace `SIMPLE_DEV_PM_OPS` and `#ifdef CONFIG_PM_SLEEP`
boilerplate with the modern `DEFINE_SIMPLE_DEV_PM_OPS()`
macro in the acpi_button driver.
So again, this is not a replacement as it actively makes the kernel
waste memory in certain configurations.
Signed-off-by: Li Jun <redacted>
I guess my previous comment that I didn't see any point in making
these changes was not clear enough.

I'm not going to apply this.
quoted hunk
---
Changes:
-Add pm_sleep_ptr for acpi_button_pm in acpi_button_driver.
-Fix the warning:
quoted
quoted
drivers/acpi/button.c:164:12: warning: function 'acpi_button_suspend' has internal linkage but is not defined [-Wundefined-internal]
     164 | static int acpi_button_suspend(struct device *dev);
         |            ^
   drivers/acpi/button.c:167:49: note: used here
     167 | static DEFINE_SIMPLE_DEV_PM_OPS(acpi_button_pm, acpi_button_suspend, acpi_button_resume);
         |                                                 ^
quoted
quoted
drivers/acpi/button.c:165:12: warning: function 'acpi_button_resume' has internal linkage but is not defined [-Wundefined-internal]
     165 | static int acpi_button_resume(struct device *dev);
         |            ^
   drivers/acpi/button.c:167:70: note: used here
     167 | static DEFINE_SIMPLE_DEV_PM_OPS(acpi_button_pm, acpi_button_suspend, acpi_button_resume);
         |                                                                      ^
   2 warnings generated.
---
 drivers/acpi/button.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)
diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c
index cdbb1023a8ee..1df7e268c4dd 100644
--- a/drivers/acpi/button.c
+++ b/drivers/acpi/button.c
@@ -161,14 +161,10 @@ static const struct dmi_system_id dmi_lid_quirks[] = {
 static int acpi_button_probe(struct platform_device *pdev);
 static void acpi_button_remove(struct platform_device *pdev);

-#ifdef CONFIG_PM_SLEEP
 static int acpi_button_suspend(struct device *dev);
 static int acpi_button_resume(struct device *dev);
-#else
-#define acpi_button_suspend NULL
-#define acpi_button_resume NULL
-#endif
-static SIMPLE_DEV_PM_OPS(acpi_button_pm, acpi_button_suspend, acpi_button_resume);
+
+static DEFINE_SIMPLE_DEV_PM_OPS(acpi_button_pm, acpi_button_suspend, acpi_button_resume);

 static struct platform_driver acpi_button_driver = {
        .probe = acpi_button_probe,
@@ -176,7 +172,7 @@ static struct platform_driver acpi_button_driver = {
        .driver = {
                .name = "acpi-button",
                .acpi_match_table = button_device_ids,
-               .pm = &acpi_button_pm,
+               .pm = pm_sleep_ptr(&acpi_button_pm),
        },
 };
@@ -502,7 +498,6 @@ static u32 acpi_button_event(void *data)
        return ACPI_INTERRUPT_HANDLED;
 }

-#ifdef CONFIG_PM_SLEEP
 static int acpi_button_suspend(struct device *dev)
 {
        struct acpi_button *button = dev_get_drvdata(dev);
@@ -532,7 +527,6 @@ static int acpi_button_resume(struct device *dev)
        }
        return 0;
 }
-#endif

 static int acpi_lid_input_open(struct input_dev *input)
 {
--
2.25.1

Re: [PATCH v2] ACPI: button: replace SIMPLE_DEV_PM_OPS with DEFINE_SIMPLE_DEV_PM_OPS

From: lijun <hidden>
Date: 2026-09-10 11:03:42

Apologies missing your earlier point.

Thanks for the patience.

  2026/9/10 18:32, Rafael J. Wysocki (Intel) :
On Thu, Sep 10, 2026 at 3:50 AM Li Jun [off-list ref] wrote:
quoted
Replace `SIMPLE_DEV_PM_OPS` and `#ifdef CONFIG_PM_SLEEP`
boilerplate with the modern `DEFINE_SIMPLE_DEV_PM_OPS()`
macro in the acpi_button driver.
So again, this is not a replacement as it actively makes the kernel
waste memory in certain configurations.
quoted
Signed-off-by: Li Jun <redacted>
I guess my previous comment that I didn't see any point in making
these changes was not clear enough.

I'm not going to apply this.
quoted
---
Changes:
-Add pm_sleep_ptr for acpi_button_pm in acpi_button_driver.
-Fix the warning:
quoted
quoted
drivers/acpi/button.c:164:12: warning: function 'acpi_button_suspend' has internal linkage but is not defined [-Wundefined-internal]
      164 | static int acpi_button_suspend(struct device *dev);
          |            ^
    drivers/acpi/button.c:167:49: note: used here
      167 | static DEFINE_SIMPLE_DEV_PM_OPS(acpi_button_pm, acpi_button_suspend, acpi_button_resume);
          |                                                 ^
quoted
quoted
drivers/acpi/button.c:165:12: warning: function 'acpi_button_resume' has internal linkage but is not defined [-Wundefined-internal]
      165 | static int acpi_button_resume(struct device *dev);
          |            ^
    drivers/acpi/button.c:167:70: note: used here
      167 | static DEFINE_SIMPLE_DEV_PM_OPS(acpi_button_pm, acpi_button_suspend, acpi_button_resume);
          |                                                                      ^
    2 warnings generated.
---
  drivers/acpi/button.c | 12 +++---------
  1 file changed, 3 insertions(+), 9 deletions(-)
diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c
index cdbb1023a8ee..1df7e268c4dd 100644
--- a/drivers/acpi/button.c
+++ b/drivers/acpi/button.c
@@ -161,14 +161,10 @@ static const struct dmi_system_id dmi_lid_quirks[] = {
  static int acpi_button_probe(struct platform_device *pdev);
  static void acpi_button_remove(struct platform_device *pdev);

-#ifdef CONFIG_PM_SLEEP
  static int acpi_button_suspend(struct device *dev);
  static int acpi_button_resume(struct device *dev);
-#else
-#define acpi_button_suspend NULL
-#define acpi_button_resume NULL
-#endif
-static SIMPLE_DEV_PM_OPS(acpi_button_pm, acpi_button_suspend, acpi_button_resume);
+
+static DEFINE_SIMPLE_DEV_PM_OPS(acpi_button_pm, acpi_button_suspend, acpi_button_resume);

  static struct platform_driver acpi_button_driver = {
         .probe = acpi_button_probe,
@@ -176,7 +172,7 @@ static struct platform_driver acpi_button_driver = {
         .driver = {
                 .name = "acpi-button",
                 .acpi_match_table = button_device_ids,
-               .pm = &acpi_button_pm,
+               .pm = pm_sleep_ptr(&acpi_button_pm),
         },
  };
@@ -502,7 +498,6 @@ static u32 acpi_button_event(void *data)
         return ACPI_INTERRUPT_HANDLED;
  }

-#ifdef CONFIG_PM_SLEEP
  static int acpi_button_suspend(struct device *dev)
  {
         struct acpi_button *button = dev_get_drvdata(dev);
@@ -532,7 +527,6 @@ static int acpi_button_resume(struct device *dev)
         }
         return 0;
  }
-#endif

  static int acpi_lid_input_open(struct input_dev *input)
  {
--
2.25.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help