gpio: Use modern PM macros
Subsystems (11)
v5 cover gpio: 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 or __maybe_unused.
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.
Almost all drivers are converted, only gpio-tegra and gpio-mlxbf are left as is, because the memory for saving HW context is not trivial, if we convert them, then the two drivers' users may complain for !CONFIG_PM && !CONFIG_PM_SLEEP case. So I didn't touch them.
patch to gpio-dwapb.c is tested on real HW, others are compile-tested only.
since v4:
- collect Reviewed-by tags.
- use pm_ptr() instead of pm_sleep_ptr() for gpio-tqmx86
- drop patch5 for gpio-pxa due to maintainer's conern with memory waste
since v3:
- fix typos.
- fix the stray change in gpio-pxa driver.
since v2:
- collect Acked-by, Reviewed-by tags.
- move the embeddng the structure for pm in gpio-dwapb out, will send it as a separate patch.
since v1:
- rebase on the latest gpio/for-next branch.
- collect Acked-by, Reviewed-by tags.
- clarify the trival memory wasted numbers with CONFIG_PM=n in the dwapb's patch commit message as suggested by Andy.
- drop patch to bt8xxx since the clean up is acchieved when switching to generic PCI pm framework.
Jisheng Zhang (14):
gpio: dwapb: Use modern PM macros
gpio: brcmstb: Use modern PM macros
gpio: htc-egpio: Use modern PM macros
gpio: pl061: Use modern PM macros
gpio: ml-ioh: Use modern PM macros
gpio: mlxbf2: Use modern PM macros
gpio: msc313: Use modern PM macros
gpio: omap: Use modern PM macros
gpio: pch: Use modern PM macros
gpio: tqmx86: Use modern PM macros
gpio: uniphier: Use modern PM macros
gpio: xgene: Use modern PM macros
gpio: xilinx: Use modern PM macros
gpio: zynq: Use modern PM macros
drivers/gpio/gpio-brcmstb.c | 12 +++--------- drivers/gpio/gpio-dwapb.c | 18 ++++-------------- drivers/gpio/gpio-htc-egpio.c | 21 ++++++++------------- drivers/gpio/gpio-ml-ioh.c | 12 ++++++------ drivers/gpio/gpio-mlxbf2.c | 8 ++++---- drivers/gpio/gpio-msc313.c | 8 ++++---- drivers/gpio/gpio-omap.c | 15 +++++++-------- drivers/gpio/gpio-pch.c | 12 ++++++------ drivers/gpio/gpio-pl061.c | 17 ++--------------- drivers/gpio/gpio-tqmx86.c | 9 ++++----- drivers/gpio/gpio-uniphier.c | 9 ++++----- drivers/gpio/gpio-xgene.c | 8 ++++---- drivers/gpio/gpio-xilinx.c | 15 +++++++-------- drivers/gpio/gpio-zynq.c | 15 +++++++-------- 14 files changed, 70 insertions(+), 109 deletions(-)
Signature · 1 line
2.51.0
PATCH v5 1/14 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.
--- drivers/gpio/gpio-dwapb.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-)
drivers/gpio/gpio-dwapb.c +4 -14
@@ -79,7 +79,6 @@ struct dwapb_platform_data {unsigned int nports; }; -#ifdef CONFIG_PM_SLEEP/* Store GPIO context across system-wide suspend/resume transitions */ struct dwapb_context {u32 data;
@@ -92,7 +91,6 @@ struct dwapb_context {u32 int_deb;u32 wake_en; }; -#endif struct dwapb_gpio_port_irqchip {unsigned int nr_irqs;
@@ -103,9 +101,7 @@ struct dwapb_gpio_port {struct gpio_generic_chip chip;struct dwapb_gpio_port_irqchip *pirq;struct dwapb_gpio *gpio; -#ifdef CONFIG_PM_SLEEP struct dwapb_context *ctx; -#endif unsigned int idx; };
@@ -363,7 +359,6 @@ static int dwapb_irq_set_type(struct irq_data *d, u32 type)return 0 ; } -#ifdef CONFIG_PM_SLEEP static int dwapb_irq_set_wake (struct irq_data *d,unsigned int enable) {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)return 0 ; } -#else -#define dwapb_irq_set_wake NULL -#endif static const struct irq_chip dwapb_irq_chip = { .name =DWAPB_DRIVER_NAME ,
@@ -390,7 +382,7 @@ static const struct irq_chip dwapb_irq_chip = { .irq_set_type = dwapb_irq_set_type, .irq_enable = dwapb_irq_enable, .irq_disable = dwapb_irq_disable, - .irq_set_wake = dwapb_irq_set_wake, + .irq_set_wake = pm_sleep_ptr(dwapb_irq_set_wake), .flags = IRQCHIP_IMMUTABLE, GPIOCHIP_IRQ_RESOURCE_HELPERS, };
@@ -759,7 +751,6 @@ static int dwapb_gpio_probe(struct platform_device *pdev)return 0 ; } -#ifdef CONFIG_PM_SLEEP static int dwapb_gpio_suspend (struct device *dev) {struct dwapb_gpio *gpio =dev_get_drvdata (dev);
@@ -844,15 +835,14 @@ static int dwapb_gpio_resume(struct device *dev)return 0 ; } -#endif -static SIMPLE_DEV_PM_OPS(dwapb_gpio_pm_ops, dwapb_gpio_suspend, - dwapb_gpio_resume); +static DEFINE_SIMPLE_DEV_PM_OPS(dwapb_gpio_pm_ops, + dwapb_gpio_suspend, dwapb_gpio_resume);static struct platform_driver dwapb_gpio_driver = { .driver = { .name =DWAPB_DRIVER_NAME , - .pm = &dwapb_gpio_pm_ops, + .pm =pm_sleep_ptr (&dwapb_gpio_pm_ops), .of_match_table = dwapb_of_match, .acpi_match_table = dwapb_acpi_match, },
Signature · 1 line
2.51.0
PATCH v5 2/14 gpio: brcmstb: Use modern PM macros
In reply to Jisheng ZhangUse 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.
--- drivers/gpio/gpio-brcmstb.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-)
drivers/gpio/gpio-brcmstb.c +3 -9
@@ -533,7 +533,6 @@ static void brcmstb_gpio_shutdown(struct platform_device *pdev)brcmstb_gpio_quiesce (&pdev->dev, false); } -#ifdef CONFIG_PM_SLEEP static void brcmstb_gpio_bank_restore (struct brcmstb_gpio_priv *priv,struct brcmstb_gpio_bank *bank) {
@@ -572,14 +571,9 @@ static int brcmstb_gpio_resume(struct device *dev)return 0 ; } -#else -#define brcmstb_gpio_suspend NULL -#define brcmstb_gpio_resume NULL -#endif /* CONFIG_PM_SLEEP */ -static const struct dev_pm_ops brcmstb_gpio_pm_ops = { - .suspend_noirq = brcmstb_gpio_suspend, - .resume_noirq = brcmstb_gpio_resume, + .suspend_noirq =pm_sleep_ptr (brcmstb_gpio_suspend), + .resume_noirq =pm_sleep_ptr (brcmstb_gpio_resume), };static int brcmstb_gpio_probe (struct platform_device *pdev)
@@ -755,7 +749,7 @@ static struct platform_driver brcmstb_gpio_driver = { .driver = { .name = "brcmstb-gpio", .of_match_table = brcmstb_gpio_of_match, - .pm = &brcmstb_gpio_pm_ops, + .pm = pm_sleep_ptr(&brcmstb_gpio_pm_ops), }, .probe = brcmstb_gpio_probe, .remove = brcmstb_gpio_remove,
Signature · 1 line
2.51.0
Re: [PATCH v5 02/14] gpio: brcmstb: Use modern PM macros
Quoted 7 lines · Jisheng Zhang
Use the modern PM macros for the suspend and resume functions to be automatically dropped by the compiler when
CONFIG_PMorCONFIG_PM_SLEEPare disabled, without having to use #ifdef guards.This has the advantage of always compiling these functions in, independently of any
Kconfigoption. Thanks to that, bugs and other regressions are subsequently easier to catch.
I think converting to the respective macros for NO_IRQ case makes sense in the same patch. But I leave this to Bart, I'm not going to give tag here due to the above.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v5 02/14] gpio: brcmstb: Use modern PM macros
In reply to Jisheng ZhangHi,
Quoted 47 lines · Jisheng Zhang
Use the modern PM macros for the suspend and resume functions to be automatically dropped by the compiler when
CONFIG_PMorCONFIG_PM_SLEEPare disabled, without having to use #ifdef guards.This has the advantage of always compiling these functions in, independently of any
Kconfigoption. Thanks to that, bugs and other regressions are subsequently easier to catch.Signed-off-by Jisheng Zhang <[email protected]>Acked-by Doug Berger <[email protected]>Reviewed-by Florian Fainelli <[email protected]>Acked-by Linus Walleij <[email protected]>--- drivers/gpio/gpio-brcmstb.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-)drivers/gpio/gpio-brcmstb.c +2
-8@@ -533,7 +533,6 @@ static void brcmstb_gpio_shutdown(struct platform_device *pdev)brcmstb_gpio_quiesce (&pdev->dev, false); } -#ifdef CONFIG_PM_SLEEP static void brcmstb_gpio_bank_restore (struct brcmstb_gpio_priv *priv,struct brcmstb_gpio_bank *bank) {@@ -572,14 +571,9 @@ static int brcmstb_gpio_resume(struct device *dev)return 0 ; } -#else -#define brcmstb_gpio_suspend NULL -#define brcmstb_gpio_resume NULL -#endif /* CONFIG_PM_SLEEP */ -static const struct dev_pm_ops brcmstb_gpio_pm_ops = { - .suspend_noirq = brcmstb_gpio_suspend, - .resume_noirq = brcmstb_gpio_resume, + .suspend_noirq =pm_sleep_ptr (brcmstb_gpio_suspend), + .resume_noirq =pm_sleep_ptr (brcmstb_gpio_resume), };static int brcmstb_gpio_probe (struct platform_device *pdev)
drivers/gpio/gpio-brcmstb.c static struct platform_driver brcmstb_gpio_driver = { · line 752
Quoted 5 lines
drivers/gpio/gpio-brcmstb.c +1
-1@@ -755,7 +749,7 @@ static struct platform_driver brcmstb_gpio_driver = { .driver = { .name = "brcmstb-gpio", .of_match_table = brcmstb_gpio_of_match, - .pm = &brcmstb_gpio_pm_ops, + .pm = pm_sleep_ptr(&brcmstb_gpio_pm_ops),
won't this cause a "brcmstb_gpio_pm_ops is unused" compile warning for !CONFIG_PM_SLEEP?
You probably need to add a __maybe_unused to brcmstb_gpio_pm_ops (which incidentally DEFINE_NOIRQ_DEV_PM_OPS() also doesn't set, but all other *_DEV_PM_OPS() macros do).
Best regards,
Jonas
Re: [PATCH v5 02/14] gpio: brcmstb: Use modern PM macros
Quoted 1 line · Jonas Gorski
On Mon, Nov 24, 2025 at 1:39 AM Jisheng Zhang <[email protected]> wrote:
...
Quoted 6 lines
Quoted 6 lines
static const struct
dev_pm_opsbrcmstb_gpio_pm_ops= {drivers/gpio/gpio-brcmstb.c +2
-2- .suspend_noirq = brcmstb_gpio_suspend, - .resume_noirq = brcmstb_gpio_resume, + .suspend_noirq = pm_sleep_ptr(brcmstb_gpio_suspend), + .resume_noirq = pm_sleep_ptr(brcmstb_gpio_resume), };
...
Quoted 9 lines
drivers/gpio/gpio-brcmstb.c static struct platform_driver brcmstb_gpio_driver = { · line 752
Quoted 2 lines
drivers/gpio/gpio-brcmstb.c +1
-1- .pm = &brcmstb_gpio_pm_ops, + .pm = pm_sleep_ptr(&brcmstb_gpio_pm_ops),won't this cause a "
brcmstb_gpio_pm_opsis unused" compile warning for !CONFIG_PM_SLEEP?You probably need to add a
__maybe_unusedtobrcmstb_gpio_pm_ops(which incidentallyDEFINE_NOIRQ_DEV_PM_OPS()also doesn't set, but all other*_DEV_PM_OPS()macros do).
Shouldn't it be covered by the same trick as pm_sleep_ptr() does for functions?
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v5 02/14] gpio: brcmstb: Use modern PM macros
Quoted 17 lines · Andy Shevchenko
Quoted 1 line · Jonas Gorski
On Mon, Nov 24, 2025 at 1:39 AM Jisheng Zhang <[email protected]> wrote:
...
Quoted 6 lines
Quoted 6 lines
static const struct
dev_pm_opsbrcmstb_gpio_pm_ops= {drivers/gpio/gpio-brcmstb.c +2
-2- .suspend_noirq = brcmstb_gpio_suspend, - .resume_noirq = brcmstb_gpio_resume, + .suspend_noirq = pm_sleep_ptr(brcmstb_gpio_suspend), + .resume_noirq = pm_sleep_ptr(brcmstb_gpio_resume), };...
Quoted 3 lines
Quoted 2 lines
drivers/gpio/gpio-brcmstb.c +1
-1- .pm = &brcmstb_gpio_pm_ops, + .pm = pm_sleep_ptr(&brcmstb_gpio_pm_ops),
Quoted 8 lines
Quoted 6 lines
won't this cause a "
brcmstb_gpio_pm_opsis unused" compile warning for !CONFIG_PM_SLEEP?You probably need to add a
__maybe_unusedtobrcmstb_gpio_pm_ops(which incidentallyDEFINE_NOIRQ_DEV_PM_OPS()also doesn't set, but all other*_DEV_PM_OPS()macros do).Shouldn't it be covered by the same trick as
pm_sleep_ptr()does for functions?
pm_sleep_ptr() becomes NULL for !CONFIG_PM_SLEEP, so there is no reference then anymore to brcmstb_gpio_pm_ops. You would need a wrapper for brcmstb_gpio_pm_ops itself to conditionally define it to avoid the warning, or add __maybe_unused to it to silence it.
Note how SIMPLE_DEV_PM_OPS() and UNIVERSAL_DEV_PM_OPS() tag the struct with it (for that reason I assume).
Best regards,
Jonas
Re: [PATCH v5 02/14] gpio: brcmstb: Use modern PM macros
Quoted 4 lines · Jonas Gorski
Quoted 2 lines · Andy Shevchenko
Quoted 1 line · Jonas Gorski
On Mon, Nov 24, 2025 at 1:39 AM Jisheng Zhang <[email protected]> wrote:
...
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
static const struct
dev_pm_opsbrcmstb_gpio_pm_ops= {drivers/gpio/gpio-brcmstb.c +2
-2- .suspend_noirq = brcmstb_gpio_suspend, - .resume_noirq = brcmstb_gpio_resume, + .suspend_noirq = pm_sleep_ptr(brcmstb_gpio_suspend), + .resume_noirq = pm_sleep_ptr(brcmstb_gpio_resume), };
...
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
drivers/gpio/gpio-brcmstb.c static struct platform_driver brcmstb_gpio_driver = { · line 752
Quoted 2 lines
drivers/gpio/gpio-brcmstb.c +1
-1- .pm = &brcmstb_gpio_pm_ops, + .pm = pm_sleep_ptr(&brcmstb_gpio_pm_ops),won't this cause a "
brcmstb_gpio_pm_opsis unused" compile warning for !CONFIG_PM_SLEEP?You probably need to add a
__maybe_unusedtobrcmstb_gpio_pm_ops(which incidentallyDEFINE_NOIRQ_DEV_PM_OPS()also doesn't set, but all other*_DEV_PM_OPS()macros do).
Do they? I mean the modern ones and not that are deprecated.
Quoted 6 lines
Quoted 1 line
Shouldn't it be covered by the same trick as
pm_sleep_ptr()does for functions?
pm_sleep_ptr()becomes NULL for !CONFIG_PM_SLEEP, so there is no reference then anymore tobrcmstb_gpio_pm_ops. You would need a wrapper forbrcmstb_gpio_pm_opsitself to conditionally define it to avoid the warning, or add__maybe_unusedto it to silence it.
PTR_IF() magic is exactly to make sure compiler will have a visibility while dropping a dead code. Did I miss anything?
Quoted 2 lines
Note how
SIMPLE_DEV_PM_OPS()andUNIVERSAL_DEV_PM_OPS()tag the struct with it (for that reason I assume).
Both are deprecated. Not a good orienteer.
None of the new approach uses __maybe_unused. (See DEFINE_*() macros in pm.h.)
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v5 02/14] gpio: brcmstb: Use modern PM macros
Quoted 32 lines · Andy Shevchenko
Quoted 4 lines · Jonas Gorski
Quoted 2 lines · Andy Shevchenko
Quoted 1 line · Jonas Gorski
On Mon, Nov 24, 2025 at 1:39 AM Jisheng Zhang <[email protected]> wrote:
...
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
static const struct
dev_pm_opsbrcmstb_gpio_pm_ops= {drivers/gpio/gpio-brcmstb.c +2
-2- .suspend_noirq = brcmstb_gpio_suspend, - .resume_noirq = brcmstb_gpio_resume, + .suspend_noirq = pm_sleep_ptr(brcmstb_gpio_suspend), + .resume_noirq = pm_sleep_ptr(brcmstb_gpio_resume), };...
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
drivers/gpio/gpio-brcmstb.c static struct platform_driver brcmstb_gpio_driver = { · line 752
Quoted 2 lines
drivers/gpio/gpio-brcmstb.c +1
-1- .pm = &brcmstb_gpio_pm_ops, + .pm = pm_sleep_ptr(&brcmstb_gpio_pm_ops),won't this cause a "
brcmstb_gpio_pm_opsis unused" compile warning for !CONFIG_PM_SLEEP?You probably need to add a
__maybe_unusedtobrcmstb_gpio_pm_ops(which incidentallyDEFINE_NOIRQ_DEV_PM_OPS()also doesn't set, but all other*_DEV_PM_OPS()macros do).Do they? I mean the modern ones and not that are deprecated.
Quoted 2 lines
Quoted 1 line
Shouldn't it be covered by the same trick as
pm_sleep_ptr()does for functions?
Quoted 7 lines
Quoted 4 lines
pm_sleep_ptr()becomes NULL for !CONFIG_PM_SLEEP, so there is no reference then anymore tobrcmstb_gpio_pm_ops. You would need a wrapper forbrcmstb_gpio_pm_opsitself to conditionally define it to avoid the warning, or add__maybe_unusedto it to silence it.
PTR_IF()magic is exactly to make sure compiler will have a visibility while dropping a dead code. Did I miss anything?
No, I just was working with old assumptions, so my bad. I faintly remember that they used to work that way, but maybe I also misremember. TIL. So disregard my comment.
Quoted 5 lines
Quoted 2 lines
Note how
SIMPLE_DEV_PM_OPS()andUNIVERSAL_DEV_PM_OPS()tag the struct with it (for that reason I assume).Both are deprecated. Not a good orienteer.
None of the new approach uses__maybe_unused. (See DEFINE_*() macros inpm.h.)
Maybe that some were using it was confusing me into thinking it is required.
Best regards,
Jonas
Re: [PATCH v5 02/14] gpio: brcmstb: Use modern PM macros
Quoted 7 lines · Jonas Gorski
Quoted 5 lines · Andy Shevchenko
Quoted 4 lines · Jonas Gorski
Quoted 2 lines · Andy Shevchenko
Quoted 1 line · Jonas Gorski
On Mon, Nov 24, 2025 at 1:39 AM Jisheng Zhang <[email protected]> wrote:
...
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
static const struct
dev_pm_opsbrcmstb_gpio_pm_ops= {drivers/gpio/gpio-brcmstb.c +2
-2- .suspend_noirq = brcmstb_gpio_suspend, - .resume_noirq = brcmstb_gpio_resume, + .suspend_noirq = pm_sleep_ptr(brcmstb_gpio_suspend), + .resume_noirq = pm_sleep_ptr(brcmstb_gpio_resume), };
...
Quoted 19 lines
Quoted 19 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
drivers/gpio/gpio-brcmstb.c static struct platform_driver brcmstb_gpio_driver = { · line 752
Quoted 2 lines
drivers/gpio/gpio-brcmstb.c +1
-1- .pm = &brcmstb_gpio_pm_ops, + .pm = pm_sleep_ptr(&brcmstb_gpio_pm_ops),won't this cause a "
brcmstb_gpio_pm_opsis unused" compile warning for !CONFIG_PM_SLEEP?You probably need to add a
__maybe_unusedtobrcmstb_gpio_pm_ops(which incidentallyDEFINE_NOIRQ_DEV_PM_OPS()also doesn't set, but all other*_DEV_PM_OPS()macros do).Do they? I mean the modern ones and not that are deprecated.
Quoted 6 lines
Quoted 1 line
Shouldn't it be covered by the same trick as
pm_sleep_ptr()does for functions?
pm_sleep_ptr()becomes NULL for !CONFIG_PM_SLEEP, so there is no reference then anymore tobrcmstb_gpio_pm_ops. You would need a wrapper forbrcmstb_gpio_pm_opsitself to conditionally define it to avoid the warning, or add__maybe_unusedto it to silence it.
Quoted 6 lines
Quoted 2 lines
PTR_IF()magic is exactly to make sure compiler will have a visibility while dropping a dead code. Did I miss anything?No, I just was working with old assumptions, so my bad. I faintly remember that they used to work that way, but maybe I also misremember. TIL. So disregard my comment.
NP. I'm glad everything is clear now about them.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Note how
SIMPLE_DEV_PM_OPS()andUNIVERSAL_DEV_PM_OPS()tag the struct with it (for that reason I assume).Both are deprecated. Not a good orienteer.
None of the new approach uses__maybe_unused. (See DEFINE_*() macros inpm.h.)Maybe that some were using it was confusing me into thinking it is required.
Signature · 2 lines
With Best Regards, Andy Shevchenko
PATCH v5 3/14 gpio: htc-egpio: Use modern PM macros
In reply to Jisheng ZhangUse 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.
--- drivers/gpio/gpio-htc-egpio.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-)
drivers/gpio/gpio-htc-egpio.c +8 -13
@@ -364,21 +364,20 @@ static int __init egpio_probe(struct platform_device *pdev)return 0 ; } -#ifdef CONFIG_PM -static int egpio_suspend (struct platform_device *pdev,pm_message_t state) +static int egpio_suspend (struct device *dev) { -struct egpio_info *ei =platform_get_drvdata (pdev); +struct egpio_info *ei =dev_get_drvdata (dev); -if (ei->chained_irq &&device_may_wakeup (&pdev->dev)) +if (ei->chained_irq &&device_may_wakeup (dev))enable_irq_wake (ei->chained_irq);return 0 ; } -static int egpio_resume (struct platform_device *pdev) +static int egpio_resume (struct device *dev) { -struct egpio_info *ei =platform_get_drvdata (pdev); +struct egpio_info *ei =dev_get_drvdata (dev); -if (ei->chained_irq &&device_may_wakeup (&pdev->dev)) +if (ei->chained_irq &&device_may_wakeup (dev))disable_irq_wake (ei->chained_irq);/* Update registers from the cache, in case
@@ -386,19 +385,15 @@ static int egpio_resume(struct platform_device *pdev)egpio_write_cache (ei);return 0 ; } -#else -#define egpio_suspend NULL -#define egpio_resume NULL -#endif +static DEFINE_SIMPLE_DEV_PM_OPS(egpio_pm_ops, egpio_suspend, egpio_resume);static struct platform_driver egpio_driver = { .driver = { .name ="htc-egpio" , .suppress_bind_attrs = true, + .pm =pm_sleep_ptr (&egpio_pm_ops), }, - .suspend = egpio_suspend, - .resume = egpio_resume, };static int __init egpio_init (void )
Signature · 1 line
2.51.0
PATCH v5 4/14 gpio: pl061: Use modern PM macros
In reply to Jisheng ZhangUse 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.
--- drivers/gpio/gpio-pl061.c | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-)
drivers/gpio/gpio-pl061.c +2 -15
@@ -37,7 +37,6 @@#define PL061_GPIO_NR 8 -#ifdef CONFIG_PMstruct pl061_context_save_regs {u8 gpio_data;u8 gpio_dir;
@@ -46,7 +45,6 @@ struct pl061_context_save_regs {u8 gpio_iev;u8 gpio_ie; }; -#endif struct pl061 {raw_spinlock_t lock;
@@ -55,9 +53,7 @@ struct pl061 {struct gpio_chip gc;int parent_irq; -#ifdef CONFIG_PM struct pl061_context_save_regs csave_regs; -#endif };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)return 0 ; } -#ifdef CONFIG_PM static int pl061_suspend (struct device *dev) {struct pl061 *pl061 =dev_get_drvdata (dev);
@@ -411,13 +406,7 @@ static int pl061_resume(struct device *dev)return 0 ; } -static const struct dev_pm_ops pl061_dev_pm_ops = { - .suspend = pl061_suspend, - .resume = pl061_resume, - .freeze = pl061_suspend, - .restore = pl061_resume, -}; -#endif +static DEFINE_SIMPLE_DEV_PM_OPS(pl061_dev_pm_ops, pl061_suspend, pl061_resume);static const struct amba_id pl061_ids[] = { {
@@ -431,9 +420,7 @@ MODULE_DEVICE_TABLE(amba, pl061_ids);static struct amba_driver pl061_gpio_driver = { .drv = { .name ="pl061_gpio" , -#ifdef CONFIG_PM - .pm = &pl061_dev_pm_ops, -#endif + .pm =pm_sleep_ptr (&pl061_dev_pm_ops), }, .id_table = pl061_ids, .probe = pl061_probe,
Signature · 1 line
2.51.0
PATCH v5 5/14 gpio: ml-ioh: Use modern PM macros
In reply to Jisheng ZhangUse 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 __maybe_unused
--- drivers/gpio/gpio-ml-ioh.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/gpio/gpio-ml-ioh.c +6 -6
@@ -160,7 +160,7 @@ static int ioh_gpio_direction_input(struct gpio_chip *gpio, unsigned nr)/* * Save register configuration and disable interrupts. */ -static void __maybe_unused ioh_gpio_save_reg_conf (struct ioh_gpio *chip) +static void ioh_gpio_save_reg_conf (struct ioh_gpio *chip) {int i;
@@ -186,7 +186,7 @@ static void __maybe_unused ioh_gpio_save_reg_conf(struct ioh_gpio *chip)/* * This function restores the register configuration of the GPIO device. */ -static void __maybe_unused ioh_gpio_restore_reg_conf (struct ioh_gpio *chip) +static void ioh_gpio_restore_reg_conf (struct ioh_gpio *chip) {int i;
@@ -479,7 +479,7 @@ static int ioh_gpio_probe(struct pci_dev *pdev,return 0 ; } -static int __maybe_unused ioh_gpio_suspend (struct device *dev) +static int ioh_gpio_suspend (struct device *dev) {struct ioh_gpio *chip =dev_get_drvdata (dev);unsigned long flags;
@@ -491,7 +491,7 @@ static int __maybe_unused ioh_gpio_suspend(struct device *dev)return 0 ; } -static int __maybe_unused ioh_gpio_resume (struct device *dev) +static int ioh_gpio_resume (struct device *dev) {struct ioh_gpio *chip =dev_get_drvdata (dev);unsigned long flags;
@@ -505,7 +505,7 @@ static int __maybe_unused ioh_gpio_resume(struct device *dev)return 0 ; } -static SIMPLE_DEV_PM_OPS(ioh_gpio_pm_ops, ioh_gpio_suspend, ioh_gpio_resume); +static DEFINE_SIMPLE_DEV_PM_OPS(ioh_gpio_pm_ops, ioh_gpio_suspend, ioh_gpio_resume);static const struct pci_device_id ioh_gpio_pcidev_id[] = { {PCI_DEVICE (PCI_VENDOR_ID_ROHM ,0x802E ) },
@@ -518,7 +518,7 @@ static struct pci_driver ioh_gpio_driver = { .id_table = ioh_gpio_pcidev_id, .probe = ioh_gpio_probe, .driver = { - .pm = &ioh_gpio_pm_ops, + .pm = pm_sleep_ptr(&ioh_gpio_pm_ops), }, };
Signature · 1 line
2.51.0
PATCH v5 6/14 gpio: mlxbf2: Use modern PM macros
In reply to Jisheng ZhangUse 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 __maybe_unused
--- drivers/gpio/gpio-mlxbf2.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpio/gpio-mlxbf2.c +4 -4
@@ -424,7 +424,7 @@ mlxbf2_gpio_probe(struct platform_device *pdev)return 0 ; } -static int __maybe_unused mlxbf2_gpio_suspend (struct device *dev) +static int mlxbf2_gpio_suspend (struct device *dev) {struct mlxbf2_gpio_context *gs =dev_get_drvdata (dev);
@@ -436,7 +436,7 @@ static int __maybe_unused mlxbf2_gpio_suspend(struct device *dev)return 0 ; } -static int __maybe_unused mlxbf2_gpio_resume (struct device *dev) +static int mlxbf2_gpio_resume (struct device *dev) {struct mlxbf2_gpio_context *gs =dev_get_drvdata (dev);
@@ -447,7 +447,7 @@ static int __maybe_unused mlxbf2_gpio_resume(struct device *dev)return 0 ; } -static SIMPLE_DEV_PM_OPS(mlxbf2_pm_ops, mlxbf2_gpio_suspend, mlxbf2_gpio_resume); +static DEFINE_SIMPLE_DEV_PM_OPS(mlxbf2_pm_ops, mlxbf2_gpio_suspend, mlxbf2_gpio_resume);static const struct acpi_device_id __maybe_unused mlxbf2_gpio_acpi_match[] = { {"MLNXBF22" ,0 },
@@ -459,7 +459,7 @@ static struct platform_driver mlxbf2_gpio_driver = { .driver = { .name = "mlxbf2_gpio", .acpi_match_table = mlxbf2_gpio_acpi_match, - .pm = &mlxbf2_pm_ops, + .pm = pm_sleep_ptr(&mlxbf2_pm_ops), }, .probe = mlxbf2_gpio_probe, };
Signature · 1 line
2.51.0
PATCH v5 7/14 gpio: msc313: Use modern PM macros
In reply to Jisheng ZhangUse 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 __maybe_unused
--- drivers/gpio/gpio-msc313.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpio/gpio-msc313.c +4 -4
@@ -694,7 +694,7 @@ static const struct of_device_id msc313_gpio_of_match[] = {* SoC goes into suspend to memory mode so we need to save some * of the register bits before suspending and put it back when resuming */ -static int __maybe_unused msc313_gpio_suspend (struct device *dev) +static int msc313_gpio_suspend (struct device *dev) {struct msc313_gpio *gpio =dev_get_drvdata (dev);int i;
@@ -705,7 +705,7 @@ static int __maybe_unused msc313_gpio_suspend(struct device *dev)return 0 ; } -static int __maybe_unused msc313_gpio_resume (struct device *dev) +static int msc313_gpio_resume (struct device *dev) {struct msc313_gpio *gpio =dev_get_drvdata (dev);int i;
@@ -716,13 +716,13 @@ static int __maybe_unused msc313_gpio_resume(struct device *dev)return 0 ; } -static SIMPLE_DEV_PM_OPS(msc313_gpio_ops, msc313_gpio_suspend, msc313_gpio_resume); +static DEFINE_SIMPLE_DEV_PM_OPS(msc313_gpio_ops, msc313_gpio_suspend, msc313_gpio_resume);static struct platform_driver msc313_gpio_driver = { .driver = { .name =DRIVER_NAME , .of_match_table = msc313_gpio_of_match, - .pm = &msc313_gpio_ops, + .pm =pm_sleep_ptr (&msc313_gpio_ops), }, .probe = msc313_gpio_probe, };
Signature · 1 line
2.51.0
Re: [PATCH v5 07/14] gpio: msc313: Use modern PM macros
Hi Jisheng,
Sorry I missed this. This looks fine to me.
Quoted 4 lines · Jisheng Zhang
Use the modern PM macros for the suspend and resume functions to be automatically dropped by the compiler when
CONFIG_PMorCONFIG_PM_SLEEPare disabled, without having to use__maybe_unused
PATCH v5 8/14 gpio: omap: Use modern PM macros
In reply to Jisheng ZhangUse 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 __maybe_unused
--- drivers/gpio/gpio-omap.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
drivers/gpio/gpio-omap.c +7 -8
@@ -1503,7 +1503,7 @@ static void omap_gpio_remove(struct platform_device *pdev)clk_unprepare (bank->dbck); } -static int __maybe_unused omap_gpio_runtime_suspend (struct device *dev) +static int omap_gpio_runtime_suspend (struct device *dev) {struct gpio_bank *bank =dev_get_drvdata (dev);unsigned long flags;
@@ -1516,7 +1516,7 @@ static int __maybe_unused omap_gpio_runtime_suspend(struct device *dev)return 0 ; } -static int __maybe_unused omap_gpio_runtime_resume (struct device *dev) +static int omap_gpio_runtime_resume (struct device *dev) {struct gpio_bank *bank =dev_get_drvdata (dev);unsigned long flags;
@@ -1529,7 +1529,7 @@ static int __maybe_unused omap_gpio_runtime_resume(struct device *dev)return 0 ; } -static int __maybe_unused omap_gpio_suspend (struct device *dev) +static int omap_gpio_suspend (struct device *dev) {struct gpio_bank *bank =dev_get_drvdata (dev);
@@ -1541,7 +1541,7 @@ static int __maybe_unused omap_gpio_suspend(struct device *dev)return omap_gpio_runtime_suspend (dev); } -static int __maybe_unused omap_gpio_resume (struct device *dev) +static int omap_gpio_resume (struct device *dev) {struct gpio_bank *bank =dev_get_drvdata (dev);
@@ -1554,9 +1554,8 @@ static int __maybe_unused omap_gpio_resume(struct device *dev) }static const struct dev_pm_ops gpio_pm_ops = { - SET_RUNTIME_PM_OPS(omap_gpio_runtime_suspend, omap_gpio_runtime_resume, - NULL) -SET_LATE_SYSTEM_SLEEP_PM_OPS (omap_gpio_suspend, omap_gpio_resume) + RUNTIME_PM_OPS(omap_gpio_runtime_suspend, omap_gpio_runtime_resume, NULL) +LATE_SYSTEM_SLEEP_PM_OPS (omap_gpio_suspend, omap_gpio_resume) };static struct platform_driver omap_gpio_driver = {
@@ -1564,7 +1563,7 @@ static struct platform_driver omap_gpio_driver = { .remove = omap_gpio_remove, .driver = { .name = "omap_gpio", - .pm = &gpio_pm_ops, + .pm = pm_ptr(&gpio_pm_ops), .of_match_table = omap_gpio_match, }, };
Signature · 1 line
2.51.0
PATCH v5 9/14 gpio: pch: Use modern PM macros
In reply to Jisheng ZhangUse 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 __maybe_unused
--- drivers/gpio/gpio-pch.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/gpio/gpio-pch.c +6 -6
@@ -171,7 +171,7 @@ static int pch_gpio_direction_input(struct gpio_chip *gpio, unsigned int nr)/* * Save register configuration and disable interrupts. */ -static void __maybe_unused pch_gpio_save_reg_conf (struct pch_gpio *chip) +static void pch_gpio_save_reg_conf (struct pch_gpio *chip) { chip->pch_gpio_reg.ien_reg =ioread32 (&chip->reg->ien); chip->pch_gpio_reg.imask_reg =ioread32 (&chip->reg->imask);
@@ -187,7 +187,7 @@ static void __maybe_unused pch_gpio_save_reg_conf(struct pch_gpio *chip)/* * This function restores the register configuration of the GPIO device. */ -static void __maybe_unused pch_gpio_restore_reg_conf (struct pch_gpio *chip) +static void pch_gpio_restore_reg_conf (struct pch_gpio *chip) {iowrite32 (chip->pch_gpio_reg.ien_reg, &chip->reg->ien);iowrite32 (chip->pch_gpio_reg.imask_reg, &chip->reg->imask);
@@ -402,7 +402,7 @@ static int pch_gpio_probe(struct pci_dev *pdev,return pch_gpio_alloc_generic_chip (chip, irq_base, gpio_pins[chip->ioh]); } -static int __maybe_unused pch_gpio_suspend (struct device *dev) +static int pch_gpio_suspend (struct device *dev) {struct pch_gpio *chip =dev_get_drvdata (dev);unsigned long flags;
@@ -414,7 +414,7 @@ static int __maybe_unused pch_gpio_suspend(struct device *dev)return 0 ; } -static int __maybe_unused pch_gpio_resume (struct device *dev) +static int pch_gpio_resume (struct device *dev) {struct pch_gpio *chip =dev_get_drvdata (dev);unsigned long flags;
@@ -428,7 +428,7 @@ static int __maybe_unused pch_gpio_resume(struct device *dev)return 0 ; } -static SIMPLE_DEV_PM_OPS(pch_gpio_pm_ops, pch_gpio_suspend, pch_gpio_resume); +static DEFINE_SIMPLE_DEV_PM_OPS(pch_gpio_pm_ops, pch_gpio_suspend, pch_gpio_resume);static const struct pci_device_id pch_gpio_pcidev_id[] = { {PCI_DEVICE_DATA (INTEL ,EG20T_PCH ,INTEL_EG20T_PCH ) },
@@ -444,7 +444,7 @@ static struct pci_driver pch_gpio_driver = { .id_table = pch_gpio_pcidev_id, .probe = pch_gpio_probe, .driver = { - .pm = &pch_gpio_pm_ops, + .pm = pm_sleep_ptr(&pch_gpio_pm_ops), }, };
Signature · 1 line
2.51.0
PATCH v5 10/14 gpio: tqmx86: Use modern PM macros
In reply to Jisheng ZhangUse 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 __maybe_unused
--- drivers/gpio/gpio-tqmx86.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/gpio/gpio-tqmx86.c +4 -5
@@ -279,19 +279,18 @@ static void tqmx86_gpio_irq_handler(struct irq_desc *desc) }/* Minimal runtime PM is needed by the IRQ subsystem */ -static int __maybe_unused tqmx86_gpio_runtime_suspend (struct device *dev) +static int tqmx86_gpio_runtime_suspend (struct device *dev) {return 0 ; } -static int __maybe_unused tqmx86_gpio_runtime_resume (struct device *dev) +static int tqmx86_gpio_runtime_resume (struct device *dev) {return 0 ; }static const struct dev_pm_ops tqmx86_gpio_dev_pm_ops = { -SET_RUNTIME_PM_OPS (tqmx86_gpio_runtime_suspend, - tqmx86_gpio_runtime_resume,NULL ) +RUNTIME_PM_OPS (tqmx86_gpio_runtime_suspend, tqmx86_gpio_runtime_resume,NULL ) }; static void tqmx86_init_irq_valid_mask(struct gpio_chip *chip,
@@ -425,7 +424,7 @@ static int tqmx86_gpio_probe(struct platform_device *pdev)static struct platform_driver tqmx86_gpio_driver = { .driver = { .name ="tqmx86-gpio" , - .pm = &tqmx86_gpio_dev_pm_ops, + .pm =pm_ptr (&tqmx86_gpio_dev_pm_ops), }, .probe = tqmx86_gpio_probe, };
Signature · 1 line
2.51.0
PATCH v5 11/14 gpio: uniphier: Use modern PM macros
In reply to Jisheng ZhangUse 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 __maybe_unused
--- drivers/gpio/gpio-uniphier.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/gpio/gpio-uniphier.c +4 -5
@@ -426,7 +426,7 @@ static void uniphier_gpio_remove(struct platform_device *pdev)irq_domain_remove (priv->domain); } -static int __maybe_unused uniphier_gpio_suspend (struct device *dev) +static int uniphier_gpio_suspend (struct device *dev) {struct uniphier_gpio_priv *priv =dev_get_drvdata (dev);unsigned int nbanks =uniphier_gpio_get_nbanks (priv->chip.ngpio);
@@ -448,7 +448,7 @@ static int __maybe_unused uniphier_gpio_suspend(struct device *dev)return 0 ; } -static int __maybe_unused uniphier_gpio_resume (struct device *dev) +static int uniphier_gpio_resume (struct device *dev) {struct uniphier_gpio_priv *priv =dev_get_drvdata (dev);unsigned int nbanks =uniphier_gpio_get_nbanks (priv->chip.ngpio);
@@ -473,8 +473,7 @@ static int __maybe_unused uniphier_gpio_resume(struct device *dev) }static const struct dev_pm_ops uniphier_gpio_pm_ops = { -SET_LATE_SYSTEM_SLEEP_PM_OPS (uniphier_gpio_suspend, - uniphier_gpio_resume) +LATE_SYSTEM_SLEEP_PM_OPS (uniphier_gpio_suspend, uniphier_gpio_resume) };static const struct of_device_id uniphier_gpio_match[] = {
@@ -489,7 +488,7 @@ static struct platform_driver uniphier_gpio_driver = { .driver = { .name = "uniphier-gpio", .of_match_table = uniphier_gpio_match, - .pm = &uniphier_gpio_pm_ops, + .pm = pm_sleep_ptr(&uniphier_gpio_pm_ops), }, };module_platform_driver (uniphier_gpio_driver);
Signature · 1 line
2.51.0
PATCH v5 12/14 gpio: xgene: Use modern PM macros
In reply to Jisheng ZhangUse 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 __maybe_unused
--- drivers/gpio/gpio-xgene.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpio/gpio-xgene.c +4 -4
@@ -130,7 +130,7 @@ static int xgene_gpio_dir_out(struct gpio_chip *gc,return 0 ; } -static __maybe_unused int xgene_gpio_suspend (struct device *dev) +static int xgene_gpio_suspend (struct device *dev) {struct xgene_gpio *gpio =dev_get_drvdata (dev);unsigned long bank_offset;
@@ -143,7 +143,7 @@ static __maybe_unused int xgene_gpio_suspend(struct device *dev)return 0 ; } -static __maybe_unused int xgene_gpio_resume (struct device *dev) +static int xgene_gpio_resume (struct device *dev) {struct xgene_gpio *gpio =dev_get_drvdata (dev);unsigned long bank_offset;
@@ -156,7 +156,7 @@ static __maybe_unused int xgene_gpio_resume(struct device *dev)return 0 ; } -static SIMPLE_DEV_PM_OPS(xgene_gpio_pm, xgene_gpio_suspend, xgene_gpio_resume); +static DEFINE_SIMPLE_DEV_PM_OPS(xgene_gpio_pm, xgene_gpio_suspend, xgene_gpio_resume);static int xgene_gpio_probe (struct platform_device *pdev) {
@@ -204,7 +204,7 @@ static struct platform_driver xgene_gpio_driver = { .name = "xgene-gpio", .of_match_table = xgene_gpio_of_match, .acpi_match_table = ACPI_PTR(xgene_gpio_acpi_match), - .pm = &xgene_gpio_pm, + .pm = pm_sleep_ptr(&xgene_gpio_pm), }, .probe = xgene_gpio_probe, };
Signature · 1 line
2.51.0
PATCH v5 13/14 gpio: xilinx: Use modern PM macros
In reply to Jisheng ZhangUse 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 __maybe_unused
--- drivers/gpio/gpio-xilinx.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
drivers/gpio/gpio-xilinx.c +7 -8
@@ -286,7 +286,7 @@ static void xgpio_free(struct gpio_chip *chip, unsigned int offset)pm_runtime_put (chip->parent); } -static int __maybe_unused xgpio_suspend (struct device *dev) +static int xgpio_suspend (struct device *dev) {struct xgpio_instance *gpio =dev_get_drvdata (dev);struct irq_data *data =irq_get_irq_data (gpio->irq);
@@ -327,7 +327,7 @@ static void xgpio_irq_ack(struct irq_data *irq_data) { } -static int __maybe_unused xgpio_resume (struct device *dev) +static int xgpio_resume (struct device *dev) {struct xgpio_instance *gpio =dev_get_drvdata (dev);struct irq_data *data =irq_get_irq_data (gpio->irq);
@@ -343,7 +343,7 @@ static int __maybe_unused xgpio_resume(struct device *dev)return 0 ; } -static int __maybe_unused xgpio_runtime_suspend (struct device *dev) +static int xgpio_runtime_suspend (struct device *dev) {struct xgpio_instance *gpio =dev_get_drvdata (dev);
@@ -352,7 +352,7 @@ static int __maybe_unused xgpio_runtime_suspend(struct device *dev)return 0 ; } -static int __maybe_unused xgpio_runtime_resume (struct device *dev) +static int xgpio_runtime_resume (struct device *dev) {struct xgpio_instance *gpio =dev_get_drvdata (dev);
@@ -360,9 +360,8 @@ static int __maybe_unused xgpio_runtime_resume(struct device *dev) }static const struct dev_pm_ops xgpio_dev_pm_ops = { - SET_SYSTEM_SLEEP_PM_OPS(xgpio_suspend, xgpio_resume) -SET_RUNTIME_PM_OPS (xgpio_runtime_suspend, - xgpio_runtime_resume,NULL ) + SYSTEM_SLEEP_PM_OPS(xgpio_suspend, xgpio_resume) +RUNTIME_PM_OPS (xgpio_runtime_suspend, xgpio_runtime_resume,NULL ) };/**
@@ -682,7 +681,7 @@ static struct platform_driver xgpio_plat_driver = { .driver = { .name = "gpio-xilinx", .of_match_table = xgpio_of_match, - .pm = &xgpio_dev_pm_ops, + .pm = pm_ptr(&xgpio_dev_pm_ops), }, };
Signature · 1 line
2.51.0
PATCH v5 14/14 gpio: zynq: Use modern PM macros
In reply to Jisheng ZhangUse 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 __maybe_unused
--- drivers/gpio/gpio-zynq.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
drivers/gpio/gpio-zynq.c +7 -8
@@ -735,7 +735,7 @@ static void zynq_gpio_restore_context(struct zynq_gpio *gpio) } } -static int __maybe_unused zynq_gpio_suspend (struct device *dev) +static int zynq_gpio_suspend (struct device *dev) {struct zynq_gpio *gpio =dev_get_drvdata (dev);struct irq_data *data =irq_get_irq_data (gpio->irq);
@@ -756,7 +756,7 @@ static int __maybe_unused zynq_gpio_suspend(struct device *dev)return 0 ; } -static int __maybe_unused zynq_gpio_resume (struct device *dev) +static int zynq_gpio_resume (struct device *dev) {struct zynq_gpio *gpio =dev_get_drvdata (dev);struct irq_data *data =irq_get_irq_data (gpio->irq);
@@ -779,7 +779,7 @@ static int __maybe_unused zynq_gpio_resume(struct device *dev)return 0 ; } -static int __maybe_unused zynq_gpio_runtime_suspend (struct device *dev) +static int zynq_gpio_runtime_suspend (struct device *dev) {struct zynq_gpio *gpio =dev_get_drvdata (dev);
@@ -788,7 +788,7 @@ static int __maybe_unused zynq_gpio_runtime_suspend(struct device *dev)return 0 ; } -static int __maybe_unused zynq_gpio_runtime_resume (struct device *dev) +static int zynq_gpio_runtime_resume (struct device *dev) {struct zynq_gpio *gpio =dev_get_drvdata (dev);
@@ -814,9 +814,8 @@ static void zynq_gpio_free(struct gpio_chip *chip, unsigned int offset) }static const struct dev_pm_ops zynq_gpio_dev_pm_ops = { - SET_SYSTEM_SLEEP_PM_OPS(zynq_gpio_suspend, zynq_gpio_resume) -SET_RUNTIME_PM_OPS (zynq_gpio_runtime_suspend, - zynq_gpio_runtime_resume,NULL ) + SYSTEM_SLEEP_PM_OPS(zynq_gpio_suspend, zynq_gpio_resume) +RUNTIME_PM_OPS (zynq_gpio_runtime_suspend, zynq_gpio_runtime_resume,NULL ) };static const struct zynq_platform_data versal_gpio_def = {
@@ -1022,7 +1021,7 @@ static void zynq_gpio_remove(struct platform_device *pdev)static struct platform_driver zynq_gpio_driver = { .driver = { .name =DRIVER_NAME , - .pm = &zynq_gpio_dev_pm_ops, + .pm =pm_ptr (&zynq_gpio_dev_pm_ops), .of_match_table = zynq_gpio_of_match, }, .probe = zynq_gpio_probe,
Signature · 1 line
2.51.0
From: Bartosz Golaszewski <[email protected]>
Quoted 10 lines · Jisheng Zhang
Use the modern PM macros for the suspend and resume functions to be automatically dropped by the compiler when
CONFIG_PMorCONFIG_PM_SLEEPare disabled, without having to use #ifdef guards or__maybe_unused.This has the advantage of always compiling these functions in, independently of any
Kconfigoption. Thanks to that, bugs and other regressions are subsequently easier to catch.[...]
Let's give it some time in linux-next to spot any potential build issues.
[01/14] gpio: dwapb: Use modern PM macros
https://git.kernel.org/brgl/linux/c/3f19e57cbfb55d743d60aeebf5d5c48cc7fd5d4e [02/14] gpio: brcmstb: Use modern PM macros https://git.kernel.org/brgl/linux/c/56f3a6d7538d2e0dfb8d9df7871d2a9aec3115ac [03/14] gpio: htc-egpio: Use modern PM macros https://git.kernel.org/brgl/linux/c/2557b1f4f21a75650a03c74a56ea30bd4214866e [04/14] gpio: pl061: Use modern PM macros https://git.kernel.org/brgl/linux/c/b40c4dacf48a42ddcd701552575945e90f5c8060 [05/14] gpio: ml-ioh: Use modern PM macros https://git.kernel.org/brgl/linux/c/1f37a9f7d1fa582833cc8e226d77e5b2397df9fa [06/14] gpio: mlxbf2: Use modern PM macros https://git.kernel.org/brgl/linux/c/a92f492a1473eb2255be9b7b767d0720c5c3b2a9 [07/14] gpio: msc313: Use modern PM macros https://git.kernel.org/brgl/linux/c/07a251bfe3b690ebfaef7c46f6ce25ea9ccba8da [08/14] gpio: omap: Use modern PM macros https://git.kernel.org/brgl/linux/c/2b3c8bd8e13bd101fe8833b1f02ef5e5a6e9920b [09/14] gpio: pch: Use modern PM macros https://git.kernel.org/brgl/linux/c/0ed358a87d6ef9782dca161ef3f1311d21f257d2 [10/14] gpio: tqmx86: Use modern PM macros https://git.kernel.org/brgl/linux/c/75ff16234bf3af747b9c77b81d7ce3df5c09df8c [11/14] gpio: uniphier: Use modern PM macros https://git.kernel.org/brgl/linux/c/46e90d3924cb58b161c2dd57ba05f3a706c1c0e2 [12/14] gpio: xgene: Use modern PM macros https://git.kernel.org/brgl/linux/c/353fdaebdc6991f1cf03ae3aaec266ad0516859b [13/14] gpio: xilinx: Use modern PM macros https://git.kernel.org/brgl/linux/c/dbedf93d1082b4e755eb62338e5f6566f4e31fb8 [14/14] gpio: zynq: Use modern PM macros https://git.kernel.org/brgl/linux/c/23ac52a4a2dceb704d8dc1674abb8beefd93bf1a
Best regards,
Signature · 1 line
Bartosz Golaszewski <[email protected]>