mfd: 88pm80x: Remove #ifdef guards for PM related functions
authorPaul Cercueil <paul@crapouillou.net>
Sun, 23 Oct 2022 09:48:25 +0000 (10:48 +0100)
committerLee Jones <lee@kernel.org>
Wed, 7 Dec 2022 13:28:10 +0000 (13:28 +0000)
Use the new EXPORT_GPL_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr() macros
to handle the .suspend/.resume callbacks.

These macros allow the suspend and resume functions to be automatically
dropped by the compiler when CONFIG_SUSPEND is disabled, without having
to use #ifdef guards.

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>
Signed-off-by: Lee Jones <lee@kernel.org>
drivers/mfd/88pm800.c
drivers/mfd/88pm805.c
drivers/mfd/88pm80x.c

index 5236c06..4d139cc 100644 (file)
@@ -596,7 +596,7 @@ static void pm800_remove(struct i2c_client *client)
 static struct i2c_driver pm800_driver = {
        .driver = {
                .name = "88PM800",
-               .pm = &pm80x_pm_ops,
+               .pm = pm_sleep_ptr(&pm80x_pm_ops),
                },
        .probe_new = pm800_probe,
        .remove = pm800_remove,
index c274f18..352f13c 100644 (file)
@@ -251,7 +251,7 @@ static void pm805_remove(struct i2c_client *client)
 static struct i2c_driver pm805_driver = {
        .driver = {
                .name = "88PM805",
-               .pm = &pm80x_pm_ops,
+               .pm = pm_sleep_ptr(&pm80x_pm_ops),
                },
        .probe_new = pm805_probe,
        .remove = pm805_remove,
index be036e7..ac4f085 100644 (file)
@@ -129,7 +129,6 @@ int pm80x_deinit(void)
 }
 EXPORT_SYMBOL_GPL(pm80x_deinit);
 
-#ifdef CONFIG_PM_SLEEP
 static int pm80x_suspend(struct device *dev)
 {
        struct i2c_client *client = to_i2c_client(dev);
@@ -153,10 +152,8 @@ static int pm80x_resume(struct device *dev)
 
        return 0;
 }
-#endif
 
-SIMPLE_DEV_PM_OPS(pm80x_pm_ops, pm80x_suspend, pm80x_resume);
-EXPORT_SYMBOL_GPL(pm80x_pm_ops);
+EXPORT_GPL_SIMPLE_DEV_PM_OPS(pm80x_pm_ops, pm80x_suspend, pm80x_resume);
 
 MODULE_DESCRIPTION("I2C Driver for Marvell 88PM80x");
 MODULE_AUTHOR("Qiao Zhou <zhouqiao@marvell.com>");