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

gpio: dwapb: 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: Jisheng Zhang <jszhang@kernel.org>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Link: https://lore.kernel.org/r/20251124002105.25429-2-jszhang@kernel.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

authored by

Jisheng Zhang and committed by
Bartosz Golaszewski
3f19e57c 4cfe6cdb

+4 -14
+4 -14
drivers/gpio/gpio-dwapb.c
··· 79 79 unsigned int nports; 80 80 }; 81 81 82 - #ifdef CONFIG_PM_SLEEP 83 82 /* Store GPIO context across system-wide suspend/resume transitions */ 84 83 struct dwapb_context { 85 84 u32 data; ··· 91 92 u32 int_deb; 92 93 u32 wake_en; 93 94 }; 94 - #endif 95 95 96 96 struct dwapb_gpio_port_irqchip { 97 97 unsigned int nr_irqs; ··· 101 103 struct gpio_generic_chip chip; 102 104 struct dwapb_gpio_port_irqchip *pirq; 103 105 struct dwapb_gpio *gpio; 104 - #ifdef CONFIG_PM_SLEEP 105 106 struct dwapb_context *ctx; 106 - #endif 107 107 unsigned int idx; 108 108 }; 109 109 ··· 359 363 return 0; 360 364 } 361 365 362 - #ifdef CONFIG_PM_SLEEP 363 366 static int dwapb_irq_set_wake(struct irq_data *d, unsigned int enable) 364 367 { 365 368 struct gpio_chip *gc = irq_data_get_irq_chip_data(d); ··· 373 378 374 379 return 0; 375 380 } 376 - #else 377 - #define dwapb_irq_set_wake NULL 378 - #endif 379 381 380 382 static const struct irq_chip dwapb_irq_chip = { 381 383 .name = DWAPB_DRIVER_NAME, ··· 382 390 .irq_set_type = dwapb_irq_set_type, 383 391 .irq_enable = dwapb_irq_enable, 384 392 .irq_disable = dwapb_irq_disable, 385 - .irq_set_wake = dwapb_irq_set_wake, 393 + .irq_set_wake = pm_sleep_ptr(dwapb_irq_set_wake), 386 394 .flags = IRQCHIP_IMMUTABLE, 387 395 GPIOCHIP_IRQ_RESOURCE_HELPERS, 388 396 }; ··· 751 759 return 0; 752 760 } 753 761 754 - #ifdef CONFIG_PM_SLEEP 755 762 static int dwapb_gpio_suspend(struct device *dev) 756 763 { 757 764 struct dwapb_gpio *gpio = dev_get_drvdata(dev); ··· 835 844 836 845 return 0; 837 846 } 838 - #endif 839 847 840 - static SIMPLE_DEV_PM_OPS(dwapb_gpio_pm_ops, dwapb_gpio_suspend, 841 - dwapb_gpio_resume); 848 + static DEFINE_SIMPLE_DEV_PM_OPS(dwapb_gpio_pm_ops, 849 + dwapb_gpio_suspend, dwapb_gpio_resume); 842 850 843 851 static struct platform_driver dwapb_gpio_driver = { 844 852 .driver = { 845 853 .name = DWAPB_DRIVER_NAME, 846 - .pm = &dwapb_gpio_pm_ops, 854 + .pm = pm_sleep_ptr(&dwapb_gpio_pm_ops), 847 855 .of_match_table = dwapb_of_match, 848 856 .acpi_match_table = dwapb_acpi_match, 849 857 },