mfd: arizona: Remove #ifdef guards for PM related functions
authorPaul Cercueil <paul@crapouillou.net>
Sun, 23 Oct 2022 09:48:43 +0000 (10:48 +0100)
committerLee Jones <lee@kernel.org>
Wed, 7 Dec 2022 13:28:12 +0000 (13:28 +0000)
Only export the arizona_pm_ops if CONFIG_PM is set, but leave the
suspend/resume functions (and related code) outside #ifdef guards.

If CONFIG_PM is not set, the arizona_pm_ops will be defined as
"static __maybe_unused", and the structure plus all the callbacks will
be automatically dropped by the compiler.

This has the advantage of always compiling these functions in,
independently of any Kconfig option. Thanks to that, bugs and other
regressions are subsequently easier to catch.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Signed-off-by: Lee Jones <lee@kernel.org>
drivers/mfd/arizona-core.c
drivers/mfd/arizona-i2c.c
drivers/mfd/arizona-spi.c

index cbf1dd9..bd7ee32 100644 (file)
@@ -480,7 +480,6 @@ static int wm5102_clear_write_sequencer(struct arizona *arizona)
        return 0;
 }
 
-#ifdef CONFIG_PM
 static int arizona_isolate_dcvdd(struct arizona *arizona)
 {
        int ret;
@@ -742,9 +741,7 @@ static int arizona_runtime_suspend(struct device *dev)
 
        return 0;
 }
-#endif
 
-#ifdef CONFIG_PM_SLEEP
 static int arizona_suspend(struct device *dev)
 {
        struct arizona *arizona = dev_get_drvdata(dev);
@@ -784,17 +781,15 @@ static int arizona_resume(struct device *dev)
 
        return 0;
 }
-#endif
 
-const struct dev_pm_ops arizona_pm_ops = {
-       SET_RUNTIME_PM_OPS(arizona_runtime_suspend,
-                          arizona_runtime_resume,
-                          NULL)
-       SET_SYSTEM_SLEEP_PM_OPS(arizona_suspend, arizona_resume)
-       SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(arizona_suspend_noirq,
-                                     arizona_resume_noirq)
+EXPORT_GPL_DEV_PM_OPS(arizona_pm_ops) = {
+       RUNTIME_PM_OPS(arizona_runtime_suspend,
+                      arizona_runtime_resume,
+                      NULL)
+       SYSTEM_SLEEP_PM_OPS(arizona_suspend, arizona_resume)
+       NOIRQ_SYSTEM_SLEEP_PM_OPS(arizona_suspend_noirq,
+                                 arizona_resume_noirq)
 };
-EXPORT_SYMBOL_GPL(arizona_pm_ops);
 
 #ifdef CONFIG_OF
 static int arizona_of_get_core_pdata(struct arizona *arizona)
index 20dd1b1..b230158 100644 (file)
@@ -117,7 +117,7 @@ static const struct of_device_id arizona_i2c_of_match[] = {
 static struct i2c_driver arizona_i2c_driver = {
        .driver = {
                .name   = "arizona",
-               .pm     = &arizona_pm_ops,
+               .pm     = pm_ptr(&arizona_pm_ops),
                .of_match_table = of_match_ptr(arizona_i2c_of_match),
        },
        .probe_new      = arizona_i2c_probe,
index 941b026..da05b96 100644 (file)
@@ -282,7 +282,7 @@ static const struct of_device_id arizona_spi_of_match[] = {
 static struct spi_driver arizona_spi_driver = {
        .driver = {
                .name   = "arizona",
-               .pm     = &arizona_pm_ops,
+               .pm     = pm_ptr(&arizona_pm_ops),
                .of_match_table = of_match_ptr(arizona_spi_of_match),
                .acpi_match_table = ACPI_PTR(arizona_acpi_match),
        },