Commit 2557b1f4 authored by Jisheng Zhang's avatar Jisheng Zhang Committed by Bartosz Golaszewski
Browse files

gpio: htc-egpio: Use modern PM macros



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: default avatarJisheng Zhang <jszhang@kernel.org>
Reviewed-by: default avatarFlorian Fainelli <florian.fainelli@broadcom.com>
Reviewed-by: default avatarAndy Shevchenko <andriy.shevchenko@intel.com>
Link: https://lore.kernel.org/r/20251124002105.25429-4-jszhang@kernel.org


Signed-off-by: default avatarBartosz Golaszewski <bartosz.golaszewski@linaro.org>
parent 56f3a6d7
Loading
Loading
Loading
Loading
+8 −13
Original line number Diff line number Diff line
@@ -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)