Skip to content

Commit b40c4da

Browse files
xhackerustcBartosz Golaszewski
authored andcommitted
gpio: pl061: 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. The pl061_context_save_regs structure is always embedded into struct pl061 to simplify code, so this brings a tiny 8 bytes memory overhead for !CONFIG_PM_SLEEP. Signed-off-by: Jisheng Zhang <jszhang@kernel.org> Reviewed-by: Linus Walleij <linus.walleij@linaro.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-5-jszhang@kernel.org Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
1 parent 2557b1f commit b40c4da

1 file changed

Lines changed: 2 additions & 15 deletions

File tree

drivers/gpio/gpio-pl061.c

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737

3838
#define PL061_GPIO_NR 8
3939

40-
#ifdef CONFIG_PM
4140
struct pl061_context_save_regs {
4241
u8 gpio_data;
4342
u8 gpio_dir;
@@ -46,7 +45,6 @@ struct pl061_context_save_regs {
4645
u8 gpio_iev;
4746
u8 gpio_ie;
4847
};
49-
#endif
5048

5149
struct pl061 {
5250
raw_spinlock_t lock;
@@ -55,9 +53,7 @@ struct pl061 {
5553
struct gpio_chip gc;
5654
int parent_irq;
5755

58-
#ifdef CONFIG_PM
5956
struct pl061_context_save_regs csave_regs;
60-
#endif
6157
};
6258

6359
static int pl061_get_direction(struct gpio_chip *gc, unsigned offset)
@@ -367,7 +363,6 @@ static int pl061_probe(struct amba_device *adev, const struct amba_id *id)
367363
return 0;
368364
}
369365

370-
#ifdef CONFIG_PM
371366
static int pl061_suspend(struct device *dev)
372367
{
373368
struct pl061 *pl061 = dev_get_drvdata(dev);
@@ -411,13 +406,7 @@ static int pl061_resume(struct device *dev)
411406
return 0;
412407
}
413408

414-
static const struct dev_pm_ops pl061_dev_pm_ops = {
415-
.suspend = pl061_suspend,
416-
.resume = pl061_resume,
417-
.freeze = pl061_suspend,
418-
.restore = pl061_resume,
419-
};
420-
#endif
409+
static DEFINE_SIMPLE_DEV_PM_OPS(pl061_dev_pm_ops, pl061_suspend, pl061_resume);
421410

422411
static const struct amba_id pl061_ids[] = {
423412
{
@@ -431,9 +420,7 @@ MODULE_DEVICE_TABLE(amba, pl061_ids);
431420
static struct amba_driver pl061_gpio_driver = {
432421
.drv = {
433422
.name = "pl061_gpio",
434-
#ifdef CONFIG_PM
435-
.pm = &pl061_dev_pm_ops,
436-
#endif
423+
.pm = pm_sleep_ptr(&pl061_dev_pm_ops),
437424
},
438425
.id_table = pl061_ids,
439426
.probe = pl061_probe,

0 commit comments

Comments
 (0)