linux-watchdog.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] watchdog: Remove #ifdef guards for PM functions
@ 2022-10-20 18:50 Paul Cercueil
  2022-10-20 18:50 ` [PATCH 1/4] watchdog: at91rm9200: Remove #ifdef guards for PM related functions Paul Cercueil
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Paul Cercueil @ 2022-10-20 18:50 UTC (permalink / raw)
  To: Wim Van Sebroeck, Guenter Roeck
  Cc: linux-watchdog, linux-kernel, Paul Cercueil

Hi,

A finishing touch of my previous work that removed #ifdef guards around
PM functions. Some drivers were not updated.

With this patchset all watchdog drivers are now converted to use the new
PM macros.

Cheers,
-Paul

Paul Cercueil (4):
  watchdog: at91rm9200: Remove #ifdef guards for PM related functions
  watchdog: twl4030: Remove #ifdef guards for PM related functions
  watchdog: omap: Remove #ifdef guards for PM related functions
  watchdog: kempld: Remove #ifdef guards for PM related functions

 drivers/watchdog/at91rm9200_wdt.c | 11 ++---------
 drivers/watchdog/db8500_wdt.c     |  9 ++-------
 drivers/watchdog/kempld_wdt.c     | 11 ++---------
 drivers/watchdog/omap_wdt.c       | 11 ++---------
 drivers/watchdog/twl4030_wdt.c    |  9 ++-------
 5 files changed, 10 insertions(+), 41 deletions(-)

-- 
2.35.1


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

* [PATCH 1/4] watchdog: at91rm9200: Remove #ifdef guards for PM related functions
  2022-10-20 18:50 [PATCH 0/4] watchdog: Remove #ifdef guards for PM functions Paul Cercueil
@ 2022-10-20 18:50 ` Paul Cercueil
  2022-10-20 21:59   ` Guenter Roeck
  2022-10-21  7:21   ` Claudiu.Beznea
  2022-10-20 18:50 ` [PATCH 2/4] watchdog: twl4030: " Paul Cercueil
                   ` (2 subsequent siblings)
  3 siblings, 2 replies; 11+ messages in thread
From: Paul Cercueil @ 2022-10-20 18:50 UTC (permalink / raw)
  To: Wim Van Sebroeck, Guenter Roeck
  Cc: linux-watchdog, linux-kernel, Paul Cercueil, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, linux-arm-kernel

Use the pm_ptr() macro to handle the .suspend/.resume callbacks.

This macro allows the suspend and resume functions to be automatically
dropped by the compiler when CONFIG_SUSPEND is disabled, without having
to use #ifdef guards. Not using #ifdef guards means that the code is
always compiled independently of any Kconfig option, and thanks to that
bugs and regressions are easier to catch.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
---
Cc: Nicolas Ferre <nicolas.ferre@microchip.com>
Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: Claudiu Beznea <claudiu.beznea@microchip.com>
Cc: linux-arm-kernel@lists.infradead.org

 drivers/watchdog/at91rm9200_wdt.c | 11 ++---------
 drivers/watchdog/db8500_wdt.c     |  9 ++-------
 2 files changed, 4 insertions(+), 16 deletions(-)

diff --git a/drivers/watchdog/at91rm9200_wdt.c b/drivers/watchdog/at91rm9200_wdt.c
index 6d751eb8191d..5126454bb861 100644
--- a/drivers/watchdog/at91rm9200_wdt.c
+++ b/drivers/watchdog/at91rm9200_wdt.c
@@ -278,8 +278,6 @@ static void at91wdt_shutdown(struct platform_device *pdev)
 	at91_wdt_stop();
 }
 
-#ifdef CONFIG_PM
-
 static int at91wdt_suspend(struct platform_device *pdev, pm_message_t message)
 {
 	at91_wdt_stop();
@@ -293,11 +291,6 @@ static int at91wdt_resume(struct platform_device *pdev)
 	return 0;
 }
 
-#else
-#define at91wdt_suspend NULL
-#define at91wdt_resume	NULL
-#endif
-
 static const struct of_device_id at91_wdt_dt_ids[] = {
 	{ .compatible = "atmel,at91rm9200-wdt" },
 	{ /* sentinel */ }
@@ -308,8 +301,8 @@ static struct platform_driver at91wdt_driver = {
 	.probe		= at91wdt_probe,
 	.remove		= at91wdt_remove,
 	.shutdown	= at91wdt_shutdown,
-	.suspend	= at91wdt_suspend,
-	.resume		= at91wdt_resume,
+	.suspend	= pm_ptr(at91wdt_suspend),
+	.resume		= pm_ptr(at91wdt_resume),
 	.driver		= {
 		.name	= "atmel_st_watchdog",
 		.of_match_table = at91_wdt_dt_ids,
diff --git a/drivers/watchdog/db8500_wdt.c b/drivers/watchdog/db8500_wdt.c
index 6ed8b63d310d..97148ac0aa54 100644
--- a/drivers/watchdog/db8500_wdt.c
+++ b/drivers/watchdog/db8500_wdt.c
@@ -105,7 +105,6 @@ static int db8500_wdt_probe(struct platform_device *pdev)
 	return 0;
 }
 
-#ifdef CONFIG_PM
 static int db8500_wdt_suspend(struct platform_device *pdev,
 			     pm_message_t state)
 {
@@ -130,15 +129,11 @@ static int db8500_wdt_resume(struct platform_device *pdev)
 	}
 	return 0;
 }
-#else
-#define db8500_wdt_suspend NULL
-#define db8500_wdt_resume NULL
-#endif
 
 static struct platform_driver db8500_wdt_driver = {
 	.probe		= db8500_wdt_probe,
-	.suspend	= db8500_wdt_suspend,
-	.resume		= db8500_wdt_resume,
+	.suspend	= pm_ptr(db8500_wdt_suspend),
+	.resume		= pm_ptr(db8500_wdt_resume),
 	.driver		= {
 		.name	= "db8500_wdt",
 	},
-- 
2.35.1


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

* [PATCH 2/4] watchdog: twl4030: Remove #ifdef guards for PM related functions
  2022-10-20 18:50 [PATCH 0/4] watchdog: Remove #ifdef guards for PM functions Paul Cercueil
  2022-10-20 18:50 ` [PATCH 1/4] watchdog: at91rm9200: Remove #ifdef guards for PM related functions Paul Cercueil
@ 2022-10-20 18:50 ` Paul Cercueil
  2022-10-20 21:59   ` Guenter Roeck
  2022-10-20 18:50 ` [PATCH 3/4] watchdog: omap: " Paul Cercueil
  2022-10-20 18:50 ` [PATCH 4/4] watchdog: kempld: " Paul Cercueil
  3 siblings, 1 reply; 11+ messages in thread
From: Paul Cercueil @ 2022-10-20 18:50 UTC (permalink / raw)
  To: Wim Van Sebroeck, Guenter Roeck
  Cc: linux-watchdog, linux-kernel, Paul Cercueil

Use the pm_ptr() macro to handle the .suspend/.resume callbacks.

This macro allows the suspend and resume functions to be automatically
dropped by the compiler when CONFIG_SUSPEND is disabled, without having
to use #ifdef guards. Not using #ifdef guards means that the code is
always compiled independently of any Kconfig option, and thanks to that
bugs and regressions are easier to catch.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
---
 drivers/watchdog/twl4030_wdt.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/watchdog/twl4030_wdt.c b/drivers/watchdog/twl4030_wdt.c
index 36b4a660928d..09d17e20f4a7 100644
--- a/drivers/watchdog/twl4030_wdt.c
+++ b/drivers/watchdog/twl4030_wdt.c
@@ -81,7 +81,6 @@ static int twl4030_wdt_probe(struct platform_device *pdev)
 	return devm_watchdog_register_device(dev, wdt);
 }
 
-#ifdef CONFIG_PM
 static int twl4030_wdt_suspend(struct platform_device *pdev, pm_message_t state)
 {
 	struct watchdog_device *wdt = platform_get_drvdata(pdev);
@@ -99,10 +98,6 @@ static int twl4030_wdt_resume(struct platform_device *pdev)
 
 	return 0;
 }
-#else
-#define twl4030_wdt_suspend        NULL
-#define twl4030_wdt_resume         NULL
-#endif
 
 static const struct of_device_id twl_wdt_of_match[] = {
 	{ .compatible = "ti,twl4030-wdt", },
@@ -112,8 +107,8 @@ MODULE_DEVICE_TABLE(of, twl_wdt_of_match);
 
 static struct platform_driver twl4030_wdt_driver = {
 	.probe		= twl4030_wdt_probe,
-	.suspend	= twl4030_wdt_suspend,
-	.resume		= twl4030_wdt_resume,
+	.suspend	= pm_ptr(twl4030_wdt_suspend),
+	.resume		= pm_ptr(twl4030_wdt_resume),
 	.driver		= {
 		.name		= "twl4030_wdt",
 		.of_match_table	= twl_wdt_of_match,
-- 
2.35.1


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

* [PATCH 3/4] watchdog: omap: Remove #ifdef guards for PM related functions
  2022-10-20 18:50 [PATCH 0/4] watchdog: Remove #ifdef guards for PM functions Paul Cercueil
  2022-10-20 18:50 ` [PATCH 1/4] watchdog: at91rm9200: Remove #ifdef guards for PM related functions Paul Cercueil
  2022-10-20 18:50 ` [PATCH 2/4] watchdog: twl4030: " Paul Cercueil
@ 2022-10-20 18:50 ` Paul Cercueil
  2022-10-20 19:22   ` Aaro Koskinen
  2022-10-20 22:00   ` Guenter Roeck
  2022-10-20 18:50 ` [PATCH 4/4] watchdog: kempld: " Paul Cercueil
  3 siblings, 2 replies; 11+ messages in thread
From: Paul Cercueil @ 2022-10-20 18:50 UTC (permalink / raw)
  To: Wim Van Sebroeck, Guenter Roeck
  Cc: linux-watchdog, linux-kernel, Paul Cercueil

Use the pm_ptr() macro to handle the .suspend/.resume callbacks.

This macro allows the suspend and resume functions to be automatically
dropped by the compiler when CONFIG_SUSPEND is disabled, without having
to use #ifdef guards. Not using #ifdef guards means that the code is
always compiled independently of any Kconfig option, and thanks to that
bugs and regressions are easier to catch.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
---
 drivers/watchdog/omap_wdt.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/drivers/watchdog/omap_wdt.c b/drivers/watchdog/omap_wdt.c
index 74d785b2b478..e75aa86f63cb 100644
--- a/drivers/watchdog/omap_wdt.c
+++ b/drivers/watchdog/omap_wdt.c
@@ -316,8 +316,6 @@ static int omap_wdt_remove(struct platform_device *pdev)
 	return 0;
 }
 
-#ifdef	CONFIG_PM
-
 /* REVISIT ... not clear this is the best way to handle system suspend; and
  * it's very inappropriate for selective device suspend (e.g. suspending this
  * through sysfs rather than by stopping the watchdog daemon).  Also, this
@@ -353,11 +351,6 @@ static int omap_wdt_resume(struct platform_device *pdev)
 	return 0;
 }
 
-#else
-#define	omap_wdt_suspend	NULL
-#define	omap_wdt_resume		NULL
-#endif
-
 static const struct of_device_id omap_wdt_of_match[] = {
 	{ .compatible = "ti,omap3-wdt", },
 	{},
@@ -368,8 +361,8 @@ static struct platform_driver omap_wdt_driver = {
 	.probe		= omap_wdt_probe,
 	.remove		= omap_wdt_remove,
 	.shutdown	= omap_wdt_shutdown,
-	.suspend	= omap_wdt_suspend,
-	.resume		= omap_wdt_resume,
+	.suspend	= pm_ptr(omap_wdt_suspend),
+	.resume		= pm_ptr(omap_wdt_resume),
 	.driver		= {
 		.name	= "omap_wdt",
 		.of_match_table = omap_wdt_of_match,
-- 
2.35.1


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

* [PATCH 4/4] watchdog: kempld: Remove #ifdef guards for PM related functions
  2022-10-20 18:50 [PATCH 0/4] watchdog: Remove #ifdef guards for PM functions Paul Cercueil
                   ` (2 preceding siblings ...)
  2022-10-20 18:50 ` [PATCH 3/4] watchdog: omap: " Paul Cercueil
@ 2022-10-20 18:50 ` Paul Cercueil
  2022-10-20 22:00   ` Guenter Roeck
  3 siblings, 1 reply; 11+ messages in thread
From: Paul Cercueil @ 2022-10-20 18:50 UTC (permalink / raw)
  To: Wim Van Sebroeck, Guenter Roeck
  Cc: linux-watchdog, linux-kernel, Paul Cercueil

Use the pm_ptr() macro to handle the .suspend/.resume callbacks.

This macro allows the suspend and resume functions to be automatically
dropped by the compiler when CONFIG_SUSPEND is disabled, without having
to use #ifdef guards. Not using #ifdef guards means that the code is
always compiled independently of any Kconfig option, and thanks to that
bugs and regressions are easier to catch.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
---
 drivers/watchdog/kempld_wdt.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/drivers/watchdog/kempld_wdt.c b/drivers/watchdog/kempld_wdt.c
index 40bd518ed873..e6c7a2906680 100644
--- a/drivers/watchdog/kempld_wdt.c
+++ b/drivers/watchdog/kempld_wdt.c
@@ -75,9 +75,7 @@ struct kempld_wdt_data {
 	struct watchdog_device		wdd;
 	unsigned int			pretimeout;
 	struct kempld_wdt_stage		stage[KEMPLD_WDT_MAX_STAGES];
-#ifdef CONFIG_PM
 	u8				pm_status_store;
-#endif
 };
 
 #define DEFAULT_TIMEOUT		30 /* seconds */
@@ -495,7 +493,6 @@ static int kempld_wdt_probe(struct platform_device *pdev)
 	return 0;
 }
 
-#ifdef CONFIG_PM
 /* Disable watchdog if it is active during suspend */
 static int kempld_wdt_suspend(struct platform_device *pdev,
 				pm_message_t message)
@@ -531,18 +528,14 @@ static int kempld_wdt_resume(struct platform_device *pdev)
 	else
 		return kempld_wdt_stop(wdd);
 }
-#else
-#define kempld_wdt_suspend	NULL
-#define kempld_wdt_resume	NULL
-#endif
 
 static struct platform_driver kempld_wdt_driver = {
 	.driver		= {
 		.name	= "kempld-wdt",
 	},
 	.probe		= kempld_wdt_probe,
-	.suspend	= kempld_wdt_suspend,
-	.resume		= kempld_wdt_resume,
+	.suspend	= pm_ptr(kempld_wdt_suspend),
+	.resume		= pm_ptr(kempld_wdt_resume),
 };
 
 module_platform_driver(kempld_wdt_driver);
-- 
2.35.1


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

* Re: [PATCH 3/4] watchdog: omap: Remove #ifdef guards for PM related functions
  2022-10-20 18:50 ` [PATCH 3/4] watchdog: omap: " Paul Cercueil
@ 2022-10-20 19:22   ` Aaro Koskinen
  2022-10-20 22:00   ` Guenter Roeck
  1 sibling, 0 replies; 11+ messages in thread
From: Aaro Koskinen @ 2022-10-20 19:22 UTC (permalink / raw)
  To: Paul Cercueil
  Cc: Wim Van Sebroeck, Guenter Roeck, linux-watchdog, linux-kernel

On Thu, Oct 20, 2022 at 07:50:46PM +0100, Paul Cercueil wrote:
> Use the pm_ptr() macro to handle the .suspend/.resume callbacks.
> 
> This macro allows the suspend and resume functions to be automatically
> dropped by the compiler when CONFIG_SUSPEND is disabled, without having
> to use #ifdef guards. Not using #ifdef guards means that the code is
> always compiled independently of any Kconfig option, and thanks to that
> bugs and regressions are easier to catch.
> 
> Signed-off-by: Paul Cercueil <paul@crapouillou.net>

Acked-by: Aaro Koskinen <aaro.koskinen@iki.fi>

> ---
>  drivers/watchdog/omap_wdt.c | 11 ++---------
>  1 file changed, 2 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/watchdog/omap_wdt.c b/drivers/watchdog/omap_wdt.c
> index 74d785b2b478..e75aa86f63cb 100644
> --- a/drivers/watchdog/omap_wdt.c
> +++ b/drivers/watchdog/omap_wdt.c
> @@ -316,8 +316,6 @@ static int omap_wdt_remove(struct platform_device *pdev)
>  	return 0;
>  }
>  
> -#ifdef	CONFIG_PM
> -
>  /* REVISIT ... not clear this is the best way to handle system suspend; and
>   * it's very inappropriate for selective device suspend (e.g. suspending this
>   * through sysfs rather than by stopping the watchdog daemon).  Also, this
> @@ -353,11 +351,6 @@ static int omap_wdt_resume(struct platform_device *pdev)
>  	return 0;
>  }
>  
> -#else
> -#define	omap_wdt_suspend	NULL
> -#define	omap_wdt_resume		NULL
> -#endif
> -
>  static const struct of_device_id omap_wdt_of_match[] = {
>  	{ .compatible = "ti,omap3-wdt", },
>  	{},
> @@ -368,8 +361,8 @@ static struct platform_driver omap_wdt_driver = {
>  	.probe		= omap_wdt_probe,
>  	.remove		= omap_wdt_remove,
>  	.shutdown	= omap_wdt_shutdown,
> -	.suspend	= omap_wdt_suspend,
> -	.resume		= omap_wdt_resume,
> +	.suspend	= pm_ptr(omap_wdt_suspend),
> +	.resume		= pm_ptr(omap_wdt_resume),
>  	.driver		= {
>  		.name	= "omap_wdt",
>  		.of_match_table = omap_wdt_of_match,
> -- 
> 2.35.1
> 

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

* Re: [PATCH 1/4] watchdog: at91rm9200: Remove #ifdef guards for PM related functions
  2022-10-20 18:50 ` [PATCH 1/4] watchdog: at91rm9200: Remove #ifdef guards for PM related functions Paul Cercueil
@ 2022-10-20 21:59   ` Guenter Roeck
  2022-10-21  7:21   ` Claudiu.Beznea
  1 sibling, 0 replies; 11+ messages in thread
From: Guenter Roeck @ 2022-10-20 21:59 UTC (permalink / raw)
  To: Paul Cercueil
  Cc: Wim Van Sebroeck, linux-watchdog, linux-kernel, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, linux-arm-kernel

On Thu, Oct 20, 2022 at 07:50:44PM +0100, Paul Cercueil wrote:
> Use the pm_ptr() macro to handle the .suspend/.resume callbacks.
> 
> This macro allows the suspend and resume functions to be automatically
> dropped by the compiler when CONFIG_SUSPEND is disabled, without having
> to use #ifdef guards. Not using #ifdef guards means that the code is
> always compiled independently of any Kconfig option, and thanks to that
> bugs and regressions are easier to catch.
> 
> Signed-off-by: Paul Cercueil <paul@crapouillou.net>

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

> ---
> Cc: Nicolas Ferre <nicolas.ferre@microchip.com>
> Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
> Cc: Claudiu Beznea <claudiu.beznea@microchip.com>
> Cc: linux-arm-kernel@lists.infradead.org
> 
>  drivers/watchdog/at91rm9200_wdt.c | 11 ++---------
>  drivers/watchdog/db8500_wdt.c     |  9 ++-------
>  2 files changed, 4 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/watchdog/at91rm9200_wdt.c b/drivers/watchdog/at91rm9200_wdt.c
> index 6d751eb8191d..5126454bb861 100644
> --- a/drivers/watchdog/at91rm9200_wdt.c
> +++ b/drivers/watchdog/at91rm9200_wdt.c
> @@ -278,8 +278,6 @@ static void at91wdt_shutdown(struct platform_device *pdev)
>  	at91_wdt_stop();
>  }
>  
> -#ifdef CONFIG_PM
> -
>  static int at91wdt_suspend(struct platform_device *pdev, pm_message_t message)
>  {
>  	at91_wdt_stop();
> @@ -293,11 +291,6 @@ static int at91wdt_resume(struct platform_device *pdev)
>  	return 0;
>  }
>  
> -#else
> -#define at91wdt_suspend NULL
> -#define at91wdt_resume	NULL
> -#endif
> -
>  static const struct of_device_id at91_wdt_dt_ids[] = {
>  	{ .compatible = "atmel,at91rm9200-wdt" },
>  	{ /* sentinel */ }
> @@ -308,8 +301,8 @@ static struct platform_driver at91wdt_driver = {
>  	.probe		= at91wdt_probe,
>  	.remove		= at91wdt_remove,
>  	.shutdown	= at91wdt_shutdown,
> -	.suspend	= at91wdt_suspend,
> -	.resume		= at91wdt_resume,
> +	.suspend	= pm_ptr(at91wdt_suspend),
> +	.resume		= pm_ptr(at91wdt_resume),
>  	.driver		= {
>  		.name	= "atmel_st_watchdog",
>  		.of_match_table = at91_wdt_dt_ids,
> diff --git a/drivers/watchdog/db8500_wdt.c b/drivers/watchdog/db8500_wdt.c
> index 6ed8b63d310d..97148ac0aa54 100644
> --- a/drivers/watchdog/db8500_wdt.c
> +++ b/drivers/watchdog/db8500_wdt.c
> @@ -105,7 +105,6 @@ static int db8500_wdt_probe(struct platform_device *pdev)
>  	return 0;
>  }
>  
> -#ifdef CONFIG_PM
>  static int db8500_wdt_suspend(struct platform_device *pdev,
>  			     pm_message_t state)
>  {
> @@ -130,15 +129,11 @@ static int db8500_wdt_resume(struct platform_device *pdev)
>  	}
>  	return 0;
>  }
> -#else
> -#define db8500_wdt_suspend NULL
> -#define db8500_wdt_resume NULL
> -#endif
>  
>  static struct platform_driver db8500_wdt_driver = {
>  	.probe		= db8500_wdt_probe,
> -	.suspend	= db8500_wdt_suspend,
> -	.resume		= db8500_wdt_resume,
> +	.suspend	= pm_ptr(db8500_wdt_suspend),
> +	.resume		= pm_ptr(db8500_wdt_resume),
>  	.driver		= {
>  		.name	= "db8500_wdt",
>  	},
> -- 
> 2.35.1
> 

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

* Re: [PATCH 2/4] watchdog: twl4030: Remove #ifdef guards for PM related functions
  2022-10-20 18:50 ` [PATCH 2/4] watchdog: twl4030: " Paul Cercueil
@ 2022-10-20 21:59   ` Guenter Roeck
  0 siblings, 0 replies; 11+ messages in thread
From: Guenter Roeck @ 2022-10-20 21:59 UTC (permalink / raw)
  To: Paul Cercueil; +Cc: Wim Van Sebroeck, linux-watchdog, linux-kernel

On Thu, Oct 20, 2022 at 07:50:45PM +0100, Paul Cercueil wrote:
> Use the pm_ptr() macro to handle the .suspend/.resume callbacks.
> 
> This macro allows the suspend and resume functions to be automatically
> dropped by the compiler when CONFIG_SUSPEND is disabled, without having
> to use #ifdef guards. Not using #ifdef guards means that the code is
> always compiled independently of any Kconfig option, and thanks to that
> bugs and regressions are easier to catch.
> 
> Signed-off-by: Paul Cercueil <paul@crapouillou.net>

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

> ---
>  drivers/watchdog/twl4030_wdt.c | 9 ++-------
>  1 file changed, 2 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/watchdog/twl4030_wdt.c b/drivers/watchdog/twl4030_wdt.c
> index 36b4a660928d..09d17e20f4a7 100644
> --- a/drivers/watchdog/twl4030_wdt.c
> +++ b/drivers/watchdog/twl4030_wdt.c
> @@ -81,7 +81,6 @@ static int twl4030_wdt_probe(struct platform_device *pdev)
>  	return devm_watchdog_register_device(dev, wdt);
>  }
>  
> -#ifdef CONFIG_PM
>  static int twl4030_wdt_suspend(struct platform_device *pdev, pm_message_t state)
>  {
>  	struct watchdog_device *wdt = platform_get_drvdata(pdev);
> @@ -99,10 +98,6 @@ static int twl4030_wdt_resume(struct platform_device *pdev)
>  
>  	return 0;
>  }
> -#else
> -#define twl4030_wdt_suspend        NULL
> -#define twl4030_wdt_resume         NULL
> -#endif
>  
>  static const struct of_device_id twl_wdt_of_match[] = {
>  	{ .compatible = "ti,twl4030-wdt", },
> @@ -112,8 +107,8 @@ MODULE_DEVICE_TABLE(of, twl_wdt_of_match);
>  
>  static struct platform_driver twl4030_wdt_driver = {
>  	.probe		= twl4030_wdt_probe,
> -	.suspend	= twl4030_wdt_suspend,
> -	.resume		= twl4030_wdt_resume,
> +	.suspend	= pm_ptr(twl4030_wdt_suspend),
> +	.resume		= pm_ptr(twl4030_wdt_resume),
>  	.driver		= {
>  		.name		= "twl4030_wdt",
>  		.of_match_table	= twl_wdt_of_match,
> -- 
> 2.35.1
> 

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

* Re: [PATCH 3/4] watchdog: omap: Remove #ifdef guards for PM related functions
  2022-10-20 18:50 ` [PATCH 3/4] watchdog: omap: " Paul Cercueil
  2022-10-20 19:22   ` Aaro Koskinen
@ 2022-10-20 22:00   ` Guenter Roeck
  1 sibling, 0 replies; 11+ messages in thread
From: Guenter Roeck @ 2022-10-20 22:00 UTC (permalink / raw)
  To: Paul Cercueil; +Cc: Wim Van Sebroeck, linux-watchdog, linux-kernel

On Thu, Oct 20, 2022 at 07:50:46PM +0100, Paul Cercueil wrote:
> Use the pm_ptr() macro to handle the .suspend/.resume callbacks.
> 
> This macro allows the suspend and resume functions to be automatically
> dropped by the compiler when CONFIG_SUSPEND is disabled, without having
> to use #ifdef guards. Not using #ifdef guards means that the code is
> always compiled independently of any Kconfig option, and thanks to that
> bugs and regressions are easier to catch.
> 
> Signed-off-by: Paul Cercueil <paul@crapouillou.net>

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

> ---
>  drivers/watchdog/omap_wdt.c | 11 ++---------
>  1 file changed, 2 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/watchdog/omap_wdt.c b/drivers/watchdog/omap_wdt.c
> index 74d785b2b478..e75aa86f63cb 100644
> --- a/drivers/watchdog/omap_wdt.c
> +++ b/drivers/watchdog/omap_wdt.c
> @@ -316,8 +316,6 @@ static int omap_wdt_remove(struct platform_device *pdev)
>  	return 0;
>  }
>  
> -#ifdef	CONFIG_PM
> -
>  /* REVISIT ... not clear this is the best way to handle system suspend; and
>   * it's very inappropriate for selective device suspend (e.g. suspending this
>   * through sysfs rather than by stopping the watchdog daemon).  Also, this
> @@ -353,11 +351,6 @@ static int omap_wdt_resume(struct platform_device *pdev)
>  	return 0;
>  }
>  
> -#else
> -#define	omap_wdt_suspend	NULL
> -#define	omap_wdt_resume		NULL
> -#endif
> -
>  static const struct of_device_id omap_wdt_of_match[] = {
>  	{ .compatible = "ti,omap3-wdt", },
>  	{},
> @@ -368,8 +361,8 @@ static struct platform_driver omap_wdt_driver = {
>  	.probe		= omap_wdt_probe,
>  	.remove		= omap_wdt_remove,
>  	.shutdown	= omap_wdt_shutdown,
> -	.suspend	= omap_wdt_suspend,
> -	.resume		= omap_wdt_resume,
> +	.suspend	= pm_ptr(omap_wdt_suspend),
> +	.resume		= pm_ptr(omap_wdt_resume),
>  	.driver		= {
>  		.name	= "omap_wdt",
>  		.of_match_table = omap_wdt_of_match,
> -- 
> 2.35.1
> 

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

* Re: [PATCH 4/4] watchdog: kempld: Remove #ifdef guards for PM related functions
  2022-10-20 18:50 ` [PATCH 4/4] watchdog: kempld: " Paul Cercueil
@ 2022-10-20 22:00   ` Guenter Roeck
  0 siblings, 0 replies; 11+ messages in thread
From: Guenter Roeck @ 2022-10-20 22:00 UTC (permalink / raw)
  To: Paul Cercueil; +Cc: Wim Van Sebroeck, linux-watchdog, linux-kernel

On Thu, Oct 20, 2022 at 07:50:47PM +0100, Paul Cercueil wrote:
> Use the pm_ptr() macro to handle the .suspend/.resume callbacks.
> 
> This macro allows the suspend and resume functions to be automatically
> dropped by the compiler when CONFIG_SUSPEND is disabled, without having
> to use #ifdef guards. Not using #ifdef guards means that the code is
> always compiled independently of any Kconfig option, and thanks to that
> bugs and regressions are easier to catch.
> 
> Signed-off-by: Paul Cercueil <paul@crapouillou.net>

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

> ---
>  drivers/watchdog/kempld_wdt.c | 11 ++---------
>  1 file changed, 2 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/watchdog/kempld_wdt.c b/drivers/watchdog/kempld_wdt.c
> index 40bd518ed873..e6c7a2906680 100644
> --- a/drivers/watchdog/kempld_wdt.c
> +++ b/drivers/watchdog/kempld_wdt.c
> @@ -75,9 +75,7 @@ struct kempld_wdt_data {
>  	struct watchdog_device		wdd;
>  	unsigned int			pretimeout;
>  	struct kempld_wdt_stage		stage[KEMPLD_WDT_MAX_STAGES];
> -#ifdef CONFIG_PM
>  	u8				pm_status_store;
> -#endif
>  };
>  
>  #define DEFAULT_TIMEOUT		30 /* seconds */
> @@ -495,7 +493,6 @@ static int kempld_wdt_probe(struct platform_device *pdev)
>  	return 0;
>  }
>  
> -#ifdef CONFIG_PM
>  /* Disable watchdog if it is active during suspend */
>  static int kempld_wdt_suspend(struct platform_device *pdev,
>  				pm_message_t message)
> @@ -531,18 +528,14 @@ static int kempld_wdt_resume(struct platform_device *pdev)
>  	else
>  		return kempld_wdt_stop(wdd);
>  }
> -#else
> -#define kempld_wdt_suspend	NULL
> -#define kempld_wdt_resume	NULL
> -#endif
>  
>  static struct platform_driver kempld_wdt_driver = {
>  	.driver		= {
>  		.name	= "kempld-wdt",
>  	},
>  	.probe		= kempld_wdt_probe,
> -	.suspend	= kempld_wdt_suspend,
> -	.resume		= kempld_wdt_resume,
> +	.suspend	= pm_ptr(kempld_wdt_suspend),
> +	.resume		= pm_ptr(kempld_wdt_resume),
>  };
>  
>  module_platform_driver(kempld_wdt_driver);
> -- 
> 2.35.1
> 

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

* Re: [PATCH 1/4] watchdog: at91rm9200: Remove #ifdef guards for PM related functions
  2022-10-20 18:50 ` [PATCH 1/4] watchdog: at91rm9200: Remove #ifdef guards for PM related functions Paul Cercueil
  2022-10-20 21:59   ` Guenter Roeck
@ 2022-10-21  7:21   ` Claudiu.Beznea
  1 sibling, 0 replies; 11+ messages in thread
From: Claudiu.Beznea @ 2022-10-21  7:21 UTC (permalink / raw)
  To: paul, wim, linux
  Cc: linux-watchdog, linux-kernel, Nicolas.Ferre, alexandre.belloni,
	linux-arm-kernel

On 20.10.2022 21:50, Paul Cercueil wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
> 
> Use the pm_ptr() macro to handle the .suspend/.resume callbacks.
> 
> This macro allows the suspend and resume functions to be automatically
> dropped by the compiler when CONFIG_SUSPEND is disabled, without having
> to use #ifdef guards. Not using #ifdef guards means that the code is
> always compiled independently of any Kconfig option, and thanks to that
> bugs and regressions are easier to catch.
> 
> Signed-off-by: Paul Cercueil <paul@crapouillou.net>
> ---
> Cc: Nicolas Ferre <nicolas.ferre@microchip.com>
> Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
> Cc: Claudiu Beznea <claudiu.beznea@microchip.com>
> Cc: linux-arm-kernel@lists.infradead.org

Reviewed-by: Claudiu Beznea <claudiu.beznea@microchip.com>


> 
>  drivers/watchdog/at91rm9200_wdt.c | 11 ++---------
>  drivers/watchdog/db8500_wdt.c     |  9 ++-------
>  2 files changed, 4 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/watchdog/at91rm9200_wdt.c b/drivers/watchdog/at91rm9200_wdt.c
> index 6d751eb8191d..5126454bb861 100644
> --- a/drivers/watchdog/at91rm9200_wdt.c
> +++ b/drivers/watchdog/at91rm9200_wdt.c
> @@ -278,8 +278,6 @@ static void at91wdt_shutdown(struct platform_device *pdev)
>         at91_wdt_stop();
>  }
> 
> -#ifdef CONFIG_PM
> -
>  static int at91wdt_suspend(struct platform_device *pdev, pm_message_t message)
>  {
>         at91_wdt_stop();
> @@ -293,11 +291,6 @@ static int at91wdt_resume(struct platform_device *pdev)
>         return 0;
>  }
> 
> -#else
> -#define at91wdt_suspend NULL
> -#define at91wdt_resume NULL
> -#endif
> -
>  static const struct of_device_id at91_wdt_dt_ids[] = {
>         { .compatible = "atmel,at91rm9200-wdt" },
>         { /* sentinel */ }
> @@ -308,8 +301,8 @@ static struct platform_driver at91wdt_driver = {
>         .probe          = at91wdt_probe,
>         .remove         = at91wdt_remove,
>         .shutdown       = at91wdt_shutdown,
> -       .suspend        = at91wdt_suspend,
> -       .resume         = at91wdt_resume,
> +       .suspend        = pm_ptr(at91wdt_suspend),
> +       .resume         = pm_ptr(at91wdt_resume),
>         .driver         = {
>                 .name   = "atmel_st_watchdog",
>                 .of_match_table = at91_wdt_dt_ids,
> diff --git a/drivers/watchdog/db8500_wdt.c b/drivers/watchdog/db8500_wdt.c
> index 6ed8b63d310d..97148ac0aa54 100644
> --- a/drivers/watchdog/db8500_wdt.c
> +++ b/drivers/watchdog/db8500_wdt.c
> @@ -105,7 +105,6 @@ static int db8500_wdt_probe(struct platform_device *pdev)
>         return 0;
>  }
> 
> -#ifdef CONFIG_PM
>  static int db8500_wdt_suspend(struct platform_device *pdev,
>                              pm_message_t state)
>  {
> @@ -130,15 +129,11 @@ static int db8500_wdt_resume(struct platform_device *pdev)
>         }
>         return 0;
>  }
> -#else
> -#define db8500_wdt_suspend NULL
> -#define db8500_wdt_resume NULL
> -#endif
> 
>  static struct platform_driver db8500_wdt_driver = {
>         .probe          = db8500_wdt_probe,
> -       .suspend        = db8500_wdt_suspend,
> -       .resume         = db8500_wdt_resume,
> +       .suspend        = pm_ptr(db8500_wdt_suspend),
> +       .resume         = pm_ptr(db8500_wdt_resume),
>         .driver         = {
>                 .name   = "db8500_wdt",
>         },
> --
> 2.35.1
> 


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

end of thread, other threads:[~2022-10-21  7:21 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-20 18:50 [PATCH 0/4] watchdog: Remove #ifdef guards for PM functions Paul Cercueil
2022-10-20 18:50 ` [PATCH 1/4] watchdog: at91rm9200: Remove #ifdef guards for PM related functions Paul Cercueil
2022-10-20 21:59   ` Guenter Roeck
2022-10-21  7:21   ` Claudiu.Beznea
2022-10-20 18:50 ` [PATCH 2/4] watchdog: twl4030: " Paul Cercueil
2022-10-20 21:59   ` Guenter Roeck
2022-10-20 18:50 ` [PATCH 3/4] watchdog: omap: " Paul Cercueil
2022-10-20 19:22   ` Aaro Koskinen
2022-10-20 22:00   ` Guenter Roeck
2022-10-20 18:50 ` [PATCH 4/4] watchdog: kempld: " Paul Cercueil
2022-10-20 22:00   ` Guenter Roeck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).