[PATCH v4 02/15] gpio: brcmstb: Use modern PM macros

Jisheng Zhang posted 15 patches 1 week, 5 days ago
There is a newer version of this series
[PATCH v4 02/15] gpio: brcmstb: Use modern PM macros
Posted by Jisheng Zhang 1 week, 5 days ago
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: Doug Berger <opendmb@gmail.com>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/gpio/gpio-brcmstb.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/drivers/gpio/gpio-brcmstb.c b/drivers/gpio/gpio-brcmstb.c
index f40c9472588b..af9287ff5dc4 100644
--- a/drivers/gpio/gpio-brcmstb.c
+++ b/drivers/gpio/gpio-brcmstb.c
@@ -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,
-- 
2.51.0
Re: [PATCH v4 02/15] gpio: brcmstb: Use modern PM macros
Posted by Andy Shevchenko 1 week, 5 days ago
On Thu, Nov 20, 2025 at 12:33:14AM +0800, Jisheng Zhang wrote:
> 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.

...

>  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),

Can it be DEFINE_NOIRQ_DEV_PM_OPS() / NOIRQ_SYSTEM_SLEEP_PM_OPS()?

>  };

-- 
With Best Regards,
Andy Shevchenko
Re: [PATCH v4 02/15] gpio: brcmstb: Use modern PM macros
Posted by Jisheng Zhang 1 week, 5 days ago
On Wed, Nov 19, 2025 at 07:45:17PM +0200, Andy Shevchenko wrote:
> On Thu, Nov 20, 2025 at 12:33:14AM +0800, Jisheng Zhang wrote:
> > 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.
> 
> ...
> 
> >  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),
> 
> Can it be DEFINE_NOIRQ_DEV_PM_OPS() / NOIRQ_SYSTEM_SLEEP_PM_OPS()?

Yep I agree with you. But IMHO, it's better to make the
DEFINE_NOIRQ_DEV_PM_OPS() switching as a seperate patch and merge this
series which wants to clean up various #ifdef #endif usages
Re: [PATCH v4 02/15] gpio: brcmstb: Use modern PM macros
Posted by Andy Shevchenko 1 week, 4 days ago
On Thu, Nov 20, 2025 at 2:46 AM Jisheng Zhang <jszhang@kernel.org> wrote:
> On Wed, Nov 19, 2025 at 07:45:17PM +0200, Andy Shevchenko wrote:
> > On Thu, Nov 20, 2025 at 12:33:14AM +0800, Jisheng Zhang wrote:

...

> > >  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),
> >
> > Can it be DEFINE_NOIRQ_DEV_PM_OPS() / NOIRQ_SYSTEM_SLEEP_PM_OPS()?
>
> Yep I agree with you. But IMHO, it's better to make the
> DEFINE_NOIRQ_DEV_PM_OPS() switching as a seperate patch and merge this
> series which wants to clean up various #ifdef #endif usages

OK.


-- 
With Best Regards,
Andy Shevchenko