mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] watchdog: starfive: Remove #ifdef guards for PM related functions
@ 2023-07-06  8:29 Paul Cercueil
  2023-07-06 13:18 ` Guenter Roeck
  2023-07-07  7:34 ` Xingyu Wu
  0 siblings, 2 replies; 3+ messages in thread
From: Paul Cercueil @ 2023-07-06  8:29 UTC (permalink / raw)
  To: Xingyu Wu, Samin Guo, Wim Van Sebroeck, Guenter Roeck
  Cc: linux-watchdog, linux-kernel, Paul Cercueil

Use the new 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: Paul Cercueil <paul@crapouillou.net>
---
 drivers/watchdog/starfive-wdt.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/watchdog/starfive-wdt.c b/drivers/watchdog/starfive-wdt.c
index 8058fca4d05d..7c8a1c5e75be 100644
--- a/drivers/watchdog/starfive-wdt.c
+++ b/drivers/watchdog/starfive-wdt.c
@@ -526,7 +526,6 @@ static void starfive_wdt_shutdown(struct platform_device *pdev)
 	starfive_wdt_pm_stop(&wdt->wdd);
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int starfive_wdt_suspend(struct device *dev)
 {
 	struct starfive_wdt *wdt = dev_get_drvdata(dev);
@@ -556,9 +555,7 @@ static int starfive_wdt_resume(struct device *dev)
 
 	return starfive_wdt_start(wdt);
 }
-#endif /* CONFIG_PM_SLEEP */
 
-#ifdef CONFIG_PM
 static int starfive_wdt_runtime_suspend(struct device *dev)
 {
 	struct starfive_wdt *wdt = dev_get_drvdata(dev);
@@ -574,11 +571,10 @@ static int starfive_wdt_runtime_resume(struct device *dev)
 
 	return starfive_wdt_enable_clock(wdt);
 }
-#endif /* CONFIG_PM */
 
 static const struct dev_pm_ops starfive_wdt_pm_ops = {
-	SET_RUNTIME_PM_OPS(starfive_wdt_runtime_suspend, starfive_wdt_runtime_resume, NULL)
-	SET_SYSTEM_SLEEP_PM_OPS(starfive_wdt_suspend, starfive_wdt_resume)
+	RUNTIME_PM_OPS(starfive_wdt_runtime_suspend, starfive_wdt_runtime_resume, NULL)
+	SYSTEM_SLEEP_PM_OPS(starfive_wdt_suspend, starfive_wdt_resume)
 };
 
 static const struct of_device_id starfive_wdt_match[] = {
@@ -594,7 +590,7 @@ static struct platform_driver starfive_wdt_driver = {
 	.shutdown = starfive_wdt_shutdown,
 	.driver = {
 		.name = "starfive-wdt",
-		.pm = &starfive_wdt_pm_ops,
+		.pm = pm_ptr(&starfive_wdt_pm_ops),
 		.of_match_table = starfive_wdt_match,
 	},
 };
-- 
2.40.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] watchdog: starfive: Remove #ifdef guards for PM related functions
  2023-07-06  8:29 [PATCH] watchdog: starfive: Remove #ifdef guards for PM related functions Paul Cercueil
@ 2023-07-06 13:18 ` Guenter Roeck
  2023-07-07  7:34 ` Xingyu Wu
  1 sibling, 0 replies; 3+ messages in thread
From: Guenter Roeck @ 2023-07-06 13:18 UTC (permalink / raw)
  To: Paul Cercueil, Xingyu Wu, Samin Guo, Wim Van Sebroeck
  Cc: linux-watchdog, linux-kernel

On 7/6/23 01:29, Paul Cercueil wrote:
> Use the new 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: Paul Cercueil <paul@crapouillou.net>

Reviewed-by: Guenter Roeck <linux@roeck-us.net>

> ---
>   drivers/watchdog/starfive-wdt.c | 10 +++-------
>   1 file changed, 3 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/watchdog/starfive-wdt.c b/drivers/watchdog/starfive-wdt.c
> index 8058fca4d05d..7c8a1c5e75be 100644
> --- a/drivers/watchdog/starfive-wdt.c
> +++ b/drivers/watchdog/starfive-wdt.c
> @@ -526,7 +526,6 @@ static void starfive_wdt_shutdown(struct platform_device *pdev)
>   	starfive_wdt_pm_stop(&wdt->wdd);
>   }
>   
> -#ifdef CONFIG_PM_SLEEP
>   static int starfive_wdt_suspend(struct device *dev)
>   {
>   	struct starfive_wdt *wdt = dev_get_drvdata(dev);
> @@ -556,9 +555,7 @@ static int starfive_wdt_resume(struct device *dev)
>   
>   	return starfive_wdt_start(wdt);
>   }
> -#endif /* CONFIG_PM_SLEEP */
>   
> -#ifdef CONFIG_PM
>   static int starfive_wdt_runtime_suspend(struct device *dev)
>   {
>   	struct starfive_wdt *wdt = dev_get_drvdata(dev);
> @@ -574,11 +571,10 @@ static int starfive_wdt_runtime_resume(struct device *dev)
>   
>   	return starfive_wdt_enable_clock(wdt);
>   }
> -#endif /* CONFIG_PM */
>   
>   static const struct dev_pm_ops starfive_wdt_pm_ops = {
> -	SET_RUNTIME_PM_OPS(starfive_wdt_runtime_suspend, starfive_wdt_runtime_resume, NULL)
> -	SET_SYSTEM_SLEEP_PM_OPS(starfive_wdt_suspend, starfive_wdt_resume)
> +	RUNTIME_PM_OPS(starfive_wdt_runtime_suspend, starfive_wdt_runtime_resume, NULL)
> +	SYSTEM_SLEEP_PM_OPS(starfive_wdt_suspend, starfive_wdt_resume)
>   };
>   
>   static const struct of_device_id starfive_wdt_match[] = {
> @@ -594,7 +590,7 @@ static struct platform_driver starfive_wdt_driver = {
>   	.shutdown = starfive_wdt_shutdown,
>   	.driver = {
>   		.name = "starfive-wdt",
> -		.pm = &starfive_wdt_pm_ops,
> +		.pm = pm_ptr(&starfive_wdt_pm_ops),
>   		.of_match_table = starfive_wdt_match,
>   	},
>   };


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] watchdog: starfive: Remove #ifdef guards for PM related functions
  2023-07-06  8:29 [PATCH] watchdog: starfive: Remove #ifdef guards for PM related functions Paul Cercueil
  2023-07-06 13:18 ` Guenter Roeck
@ 2023-07-07  7:34 ` Xingyu Wu
  1 sibling, 0 replies; 3+ messages in thread
From: Xingyu Wu @ 2023-07-07  7:34 UTC (permalink / raw)
  To: Paul Cercueil
  Cc: Samin Guo, Wim Van Sebroeck, Guenter Roeck, linux-watchdog, linux-kernel

On 2023/7/6 16:29, Paul Cercueil wrote:
> Use the new 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: Paul Cercueil <paul@crapouillou.net>
> ---
>  drivers/watchdog/starfive-wdt.c | 10 +++-------
>  1 file changed, 3 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/watchdog/starfive-wdt.c b/drivers/watchdog/starfive-wdt.c
> index 8058fca4d05d..7c8a1c5e75be 100644
> --- a/drivers/watchdog/starfive-wdt.c
> +++ b/drivers/watchdog/starfive-wdt.c
> @@ -526,7 +526,6 @@ static void starfive_wdt_shutdown(struct platform_device *pdev)
>  	starfive_wdt_pm_stop(&wdt->wdd);
>  }
>  
> -#ifdef CONFIG_PM_SLEEP
>  static int starfive_wdt_suspend(struct device *dev)
>  {
>  	struct starfive_wdt *wdt = dev_get_drvdata(dev);
> @@ -556,9 +555,7 @@ static int starfive_wdt_resume(struct device *dev)
>  
>  	return starfive_wdt_start(wdt);
>  }
> -#endif /* CONFIG_PM_SLEEP */
>  
> -#ifdef CONFIG_PM
>  static int starfive_wdt_runtime_suspend(struct device *dev)
>  {
>  	struct starfive_wdt *wdt = dev_get_drvdata(dev);
> @@ -574,11 +571,10 @@ static int starfive_wdt_runtime_resume(struct device *dev)
>  
>  	return starfive_wdt_enable_clock(wdt);
>  }
> -#endif /* CONFIG_PM */
>  
>  static const struct dev_pm_ops starfive_wdt_pm_ops = {
> -	SET_RUNTIME_PM_OPS(starfive_wdt_runtime_suspend, starfive_wdt_runtime_resume, NULL)
> -	SET_SYSTEM_SLEEP_PM_OPS(starfive_wdt_suspend, starfive_wdt_resume)
> +	RUNTIME_PM_OPS(starfive_wdt_runtime_suspend, starfive_wdt_runtime_resume, NULL)
> +	SYSTEM_SLEEP_PM_OPS(starfive_wdt_suspend, starfive_wdt_resume)
>  };
>  
>  static const struct of_device_id starfive_wdt_match[] = {
> @@ -594,7 +590,7 @@ static struct platform_driver starfive_wdt_driver = {
>  	.shutdown = starfive_wdt_shutdown,
>  	.driver = {
>  		.name = "starfive-wdt",
> -		.pm = &starfive_wdt_pm_ops,
> +		.pm = pm_ptr(&starfive_wdt_pm_ops),
>  		.of_match_table = starfive_wdt_match,
>  	},
>  };

Great, Thank you for the improvements.

Best regards,
Xingyu Wu

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-07-07  7:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-06  8:29 [PATCH] watchdog: starfive: Remove #ifdef guards for PM related functions Paul Cercueil
2023-07-06 13:18 ` Guenter Roeck
2023-07-07  7:34 ` Xingyu Wu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®