Skip to content

Commit 3f19e57

Browse files
xhackerustcBartosz Golaszewski
authored andcommitted
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>
1 parent 4cfe6cd commit 3f19e57

1 file changed

Lines changed: 4 additions & 14 deletions

File tree

drivers/gpio/gpio-dwapb.c

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ struct dwapb_platform_data {
7979
unsigned int nports;
8080
};
8181

82-
#ifdef CONFIG_PM_SLEEP
8382
/* Store GPIO context across system-wide suspend/resume transitions */
8483
struct dwapb_context {
8584
u32 data;
@@ -92,7 +91,6 @@ struct dwapb_context {
9291
u32 int_deb;
9392
u32 wake_en;
9493
};
95-
#endif
9694

9795
struct dwapb_gpio_port_irqchip {
9896
unsigned int nr_irqs;
@@ -103,9 +101,7 @@ struct dwapb_gpio_port {
103101
struct gpio_generic_chip chip;
104102
struct dwapb_gpio_port_irqchip *pirq;
105103
struct dwapb_gpio *gpio;
106-
#ifdef CONFIG_PM_SLEEP
107104
struct dwapb_context *ctx;
108-
#endif
109105
unsigned int idx;
110106
};
111107

@@ -363,7 +359,6 @@ static int dwapb_irq_set_type(struct irq_data *d, u32 type)
363359
return 0;
364360
}
365361

366-
#ifdef CONFIG_PM_SLEEP
367362
static int dwapb_irq_set_wake(struct irq_data *d, unsigned int enable)
368363
{
369364
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
@@ -378,9 +373,6 @@ static int dwapb_irq_set_wake(struct irq_data *d, unsigned int enable)
378373

379374
return 0;
380375
}
381-
#else
382-
#define dwapb_irq_set_wake NULL
383-
#endif
384376

385377
static const struct irq_chip dwapb_irq_chip = {
386378
.name = DWAPB_DRIVER_NAME,
@@ -390,7 +382,7 @@ static const struct irq_chip dwapb_irq_chip = {
390382
.irq_set_type = dwapb_irq_set_type,
391383
.irq_enable = dwapb_irq_enable,
392384
.irq_disable = dwapb_irq_disable,
393-
.irq_set_wake = dwapb_irq_set_wake,
385+
.irq_set_wake = pm_sleep_ptr(dwapb_irq_set_wake),
394386
.flags = IRQCHIP_IMMUTABLE,
395387
GPIOCHIP_IRQ_RESOURCE_HELPERS,
396388
};
@@ -759,7 +751,6 @@ static int dwapb_gpio_probe(struct platform_device *pdev)
759751
return 0;
760752
}
761753

762-
#ifdef CONFIG_PM_SLEEP
763754
static int dwapb_gpio_suspend(struct device *dev)
764755
{
765756
struct dwapb_gpio *gpio = dev_get_drvdata(dev);
@@ -844,15 +835,14 @@ static int dwapb_gpio_resume(struct device *dev)
844835

845836
return 0;
846837
}
847-
#endif
848838

849-
static SIMPLE_DEV_PM_OPS(dwapb_gpio_pm_ops, dwapb_gpio_suspend,
850-
dwapb_gpio_resume);
839+
static DEFINE_SIMPLE_DEV_PM_OPS(dwapb_gpio_pm_ops,
840+
dwapb_gpio_suspend, dwapb_gpio_resume);
851841

852842
static struct platform_driver dwapb_gpio_driver = {
853843
.driver = {
854844
.name = DWAPB_DRIVER_NAME,
855-
.pm = &dwapb_gpio_pm_ops,
845+
.pm = pm_sleep_ptr(&dwapb_gpio_pm_ops),
856846
.of_match_table = dwapb_of_match,
857847
.acpi_match_table = dwapb_acpi_match,
858848
},

0 commit comments

Comments
 (0)