]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
gpio: htc-egpio: Use modern PM macros
authorJisheng Zhang <jszhang@kernel.org>
Mon, 24 Nov 2025 00:20:54 +0000 (08:20 +0800)
committerBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Tue, 25 Nov 2025 13:10:06 +0000 (14:10 +0100)
Use the modern PM macros for the suspend and resume functions to be
automatically dropped by the compiler when CONFIG_PM or
CONFIG_PM_SLEEP are 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: Jisheng Zhang <jszhang@kernel.org>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Link: https://lore.kernel.org/r/20251124002105.25429-4-jszhang@kernel.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
drivers/gpio/gpio-htc-egpio.c

index 2eaed83214d82898ec2dddfe4b190cda3e340531..72935d6dbebf080242882c43c084bcf64db4a1f3 100644 (file)
@@ -364,21 +364,20 @@ static int __init egpio_probe(struct platform_device *pdev)
        return 0;
 }
 
-#ifdef CONFIG_PM
-static int egpio_suspend(struct platform_device *pdev, pm_message_t state)
+static int egpio_suspend(struct device *dev)
 {
-       struct egpio_info *ei = platform_get_drvdata(pdev);
+       struct egpio_info *ei = dev_get_drvdata(dev);
 
-       if (ei->chained_irq && device_may_wakeup(&pdev->dev))
+       if (ei->chained_irq && device_may_wakeup(dev))
                enable_irq_wake(ei->chained_irq);
        return 0;
 }
 
-static int egpio_resume(struct platform_device *pdev)
+static int egpio_resume(struct device *dev)
 {
-       struct egpio_info *ei = platform_get_drvdata(pdev);
+       struct egpio_info *ei = dev_get_drvdata(dev);
 
-       if (ei->chained_irq && device_may_wakeup(&pdev->dev))
+       if (ei->chained_irq && device_may_wakeup(dev))
                disable_irq_wake(ei->chained_irq);
 
        /* Update registers from the cache, in case
@@ -386,19 +385,15 @@ static int egpio_resume(struct platform_device *pdev)
        egpio_write_cache(ei);
        return 0;
 }
-#else
-#define egpio_suspend NULL
-#define egpio_resume NULL
-#endif
 
+static DEFINE_SIMPLE_DEV_PM_OPS(egpio_pm_ops, egpio_suspend, egpio_resume);
 
 static struct platform_driver egpio_driver = {
        .driver = {
                .name = "htc-egpio",
                .suppress_bind_attrs = true,
+               .pm = pm_sleep_ptr(&egpio_pm_ops),
        },
-       .suspend      = egpio_suspend,
-       .resume       = egpio_resume,
 };
 
 static int __init egpio_init(void)