Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

watchdog: kempld: Remove #ifdef guards for PM related functions

Use the pm_ptr() macro to handle the .suspend/.resume callbacks.

This macro allows the suspend and resume functions to be automatically
dropped by the compiler when CONFIG_SUSPEND is disabled, without having
to use #ifdef guards. Not using #ifdef guards means that the code is
always compiled independently of any Kconfig option, and thanks to that
bugs and regressions are easier to catch.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20221020185047.1001522-5-paul@crapouillou.net
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Wim Van Sebroeck <wim@linux-watchdog.org>

authored by

Paul Cercueil and committed by
Wim Van Sebroeck
758f46c2 0327476d

+2 -9
+2 -9
drivers/watchdog/kempld_wdt.c
··· 75 75 struct watchdog_device wdd; 76 76 unsigned int pretimeout; 77 77 struct kempld_wdt_stage stage[KEMPLD_WDT_MAX_STAGES]; 78 - #ifdef CONFIG_PM 79 78 u8 pm_status_store; 80 - #endif 81 79 }; 82 80 83 81 #define DEFAULT_TIMEOUT 30 /* seconds */ ··· 493 495 return 0; 494 496 } 495 497 496 - #ifdef CONFIG_PM 497 498 /* Disable watchdog if it is active during suspend */ 498 499 static int kempld_wdt_suspend(struct platform_device *pdev, 499 500 pm_message_t message) ··· 528 531 else 529 532 return kempld_wdt_stop(wdd); 530 533 } 531 - #else 532 - #define kempld_wdt_suspend NULL 533 - #define kempld_wdt_resume NULL 534 - #endif 535 534 536 535 static struct platform_driver kempld_wdt_driver = { 537 536 .driver = { 538 537 .name = "kempld-wdt", 539 538 }, 540 539 .probe = kempld_wdt_probe, 541 - .suspend = kempld_wdt_suspend, 542 - .resume = kempld_wdt_resume, 540 + .suspend = pm_ptr(kempld_wdt_suspend), 541 + .resume = pm_ptr(kempld_wdt_resume), 543 542 }; 544 543 545 544 module_platform_driver(kempld_wdt_driver);