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

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>

authored by

Jisheng Zhang and committed by
Bartosz Golaszewski
b40c4dac 2557b1f4

+2 -15
+2 -15
drivers/gpio/gpio-pl061.c
··· 37 37 38 38 #define PL061_GPIO_NR 8 39 39 40 - #ifdef CONFIG_PM 41 40 struct pl061_context_save_regs { 42 41 u8 gpio_data; 43 42 u8 gpio_dir; ··· 45 46 u8 gpio_iev; 46 47 u8 gpio_ie; 47 48 }; 48 - #endif 49 49 50 50 struct pl061 { 51 51 raw_spinlock_t lock; ··· 53 55 struct gpio_chip gc; 54 56 int parent_irq; 55 57 56 - #ifdef CONFIG_PM 57 58 struct pl061_context_save_regs csave_regs; 58 - #endif 59 59 }; 60 60 61 61 static int pl061_get_direction(struct gpio_chip *gc, unsigned offset) ··· 363 367 return 0; 364 368 } 365 369 366 - #ifdef CONFIG_PM 367 370 static int pl061_suspend(struct device *dev) 368 371 { 369 372 struct pl061 *pl061 = dev_get_drvdata(dev); ··· 406 411 return 0; 407 412 } 408 413 409 - static const struct dev_pm_ops pl061_dev_pm_ops = { 410 - .suspend = pl061_suspend, 411 - .resume = pl061_resume, 412 - .freeze = pl061_suspend, 413 - .restore = pl061_resume, 414 - }; 415 - #endif 414 + static DEFINE_SIMPLE_DEV_PM_OPS(pl061_dev_pm_ops, pl061_suspend, pl061_resume); 416 415 417 416 static const struct amba_id pl061_ids[] = { 418 417 { ··· 420 431 static struct amba_driver pl061_gpio_driver = { 421 432 .drv = { 422 433 .name = "pl061_gpio", 423 - #ifdef CONFIG_PM 424 - .pm = &pl061_dev_pm_ops, 425 - #endif 434 + .pm = pm_sleep_ptr(&pl061_dev_pm_ops), 426 435 }, 427 436 .id_table = pl061_ids, 428 437 .probe = pl061_probe,