Skip to contentSkip to conversation

ACPI: button: use DEFINE_SIMPLE_DEV_PM_OPS

PATCH In review Triet Hoang 2 participants 3 messages Aug 20 – Sep 9 ACPI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ACPI: button: use DEFINE_SIMPLE_DEV_PM_OPS

Convert the deprecated SIMPLE_DEV_PM_OPS
to DEFINE_SIMPLE_DEV_PM_OPS

Also use pm_sleep_ptr() when assigning the ops to the driver. This allows the removal of the ifdef CONFIG_PM_SLEEP and unnecessary forward declarations of 4 functions.

No intentional functional impact.

---
 drivers/acpi/button.c | 36 ++++++++++++------------------------
 1 file changed, 12 insertions(+), 24 deletions(-)
drivers/acpi/button.c +12 -24
index 3836ee75dd66..d4cb942b754f 100644
@@ -147,28 +147,6 @@ 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 struct platform_driver acpi_button_driver = {
-	.probe = acpi_button_probe,
-	.remove = acpi_button_remove,
-	.driver = {
-		.name = "acpi-button",
-		.acpi_match_table = button_device_ids,
-		.pm = &acpi_button_pm,
-	},
-};
-
 struct acpi_button {
 	struct acpi_device *adev;
 	struct device *dev;		/* physical button device */
@@ -491,7 +469,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);
@@ -521,7 +498,6 @@ static int acpi_button_resume(struct device *dev)
 	}
 	return 0;
 }
-#endif
 
 static int acpi_lid_input_open(struct input_dev *input)
 {
@@ -753,6 +729,18 @@ static void acpi_button_remove(struct platform_device *pdev)
 		acpi_lid_forget(button->adev);
 }
 
+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,
+	.remove = acpi_button_remove,
+	.driver = {
+		.name = "acpi-button",
+		.acpi_match_table = button_device_ids,
+		.pm = pm_sleep_ptr(&acpi_button_pm),
+	},
+};
+
 static int param_set_lid_init_state(const char *val,
 				    const struct kernel_param *kp)
 {
Signature · 1 line
2.53.0
#1 lore raw
Quoted 57 lines · Triet Hoang

Convert the deprecated SIMPLE_DEV_PM_OPS
to DEFINE_SIMPLE_DEV_PM_OPS

Also use pm_sleep_ptr() when assigning the ops to the driver. This allows the removal of the ifdef CONFIG_PM_SLEEP and unnecessary forward declarations of 4 functions.

No intentional functional impact.

---
 drivers/acpi/button.c | 36 ++++++++++++------------------------
 1 file changed, 12 insertions(+), 24 deletions(-)
drivers/acpi/button.c +0 -23
index 3836ee75dd66..d4cb942b754f 100644
@@ -147,28 +147,6 @@ 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 struct platform_driver acpi_button_driver = {
-       .probe = acpi_button_probe,
-       .remove = acpi_button_remove,
-       .driver = {
-               .name = "acpi-button",
-               .acpi_match_table = button_device_ids,
-               .pm = &acpi_button_pm,
-       },
-};
-
 struct acpi_button {
        struct acpi_device *adev;
        struct device *dev;             /* physical button device */
@@ -491,7 +469,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);

drivers/acpi/button.c static int acpi_button_resume(struct device *dev) · line 524

Quoted 4 lines
drivers/acpi/button.c +0 -1
@@ -521,7 +498,6 @@ static int acpi_button_resume(struct device *dev)
        }
        return 0;
 }
-#endif

And the function above is going to be unused when CONFIG_PM_SLEEP is unset, causing the compiler to complain AFAICS.

Quoted 24 lines
drivers/acpi/button.c +12 -1
 static int acpi_lid_input_open(struct input_dev *input)
 {
@@ -753,6 +729,18 @@ static void acpi_button_remove(struct platform_device *pdev)
                acpi_lid_forget(button->adev);
 }
 
+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,
+       .remove = acpi_button_remove,
+       .driver = {
+               .name = "acpi-button",
+               .acpi_match_table = button_device_ids,
+               .pm = pm_sleep_ptr(&acpi_button_pm),
+       },
+};
+
 static int param_set_lid_init_state(const char *val,
                                    const struct kernel_param *kp)
 {
--

2.53.0

#2 lore raw
Quoted 54 lines · Rafael J. Wysocki (Intel)
Quoted 52 lines · Triet Hoang

Convert the deprecated SIMPLE_DEV_PM_OPS
to DEFINE_SIMPLE_DEV_PM_OPS

Also use pm_sleep_ptr() when assigning the ops to the driver. This allows the removal of the ifdef CONFIG_PM_SLEEP and unnecessary forward declarations of 4 functions.

No intentional functional impact.

---
 drivers/acpi/button.c | 36 ++++++++++++------------------------
 1 file changed, 12 insertions(+), 24 deletions(-)
drivers/acpi/button.c +0 -22
index 3836ee75dd66..d4cb942b754f 100644
@@ -147,28 +147,6 @@ 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 struct platform_driver acpi_button_driver = {
-       .probe = acpi_button_probe,
-       .remove = acpi_button_remove,
-       .driver = {
-               .name = "acpi-button",
-               .acpi_match_table = button_device_ids,
-               .pm = &acpi_button_pm,
-       },
-};
-
 struct acpi_button {
        struct acpi_device *adev;
        struct device *dev;             /* physical button device */
@@ -491,7 +469,6 @@ static u32 acpi_button_event(void *data)
        return ACPI_INTERRUPT_HANDLED;
 }
 
Quoted 12 lines

drivers/acpi/button.c static int acpi_button_resume(struct device *dev) · line 524

Quoted 9 lines
drivers/acpi/button.c +0 -2
-#ifdef CONFIG_PM_SLEEP
 static int acpi_button_suspend(struct device *dev)
 {
        struct acpi_button *button = dev_get_drvdata(dev);
@@ -521,7 +498,6 @@ static int acpi_button_resume(struct device *dev)
        }
        return 0;
 }
-#endif

And the function above is going to be unused when CONFIG_PM_SLEEP is unset, causing the compiler to complain AFAICS.

Scratch this, but you should mention in the changelog that the file is going to contain dead code for CONFIG_PM_SLEEP unset after this change.

And I'm not really sure if I like that.

Quoted 24 lines
Quoted 24 lines
drivers/acpi/button.c +12 -1
 static int acpi_lid_input_open(struct input_dev *input)
 {
@@ -753,6 +729,18 @@ static void acpi_button_remove(struct platform_device *pdev)
                acpi_lid_forget(button->adev);
 }
 
+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,
+       .remove = acpi_button_remove,
+       .driver = {
+               .name = "acpi-button",
+               .acpi_match_table = button_device_ids,
+               .pm = pm_sleep_ptr(&acpi_button_pm),
+       },
+};
+
 static int param_set_lid_init_state(const char *val,
                                    const struct kernel_param *kp)
 {
--

2.53.0