linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] watchdog: omap_wdt: Add 'early_disable' module parameter
@ 2014-09-09 13:07 Rostislav Lisovy
  2014-09-11 16:09 ` Guenter Roeck
  0 siblings, 1 reply; 2+ messages in thread
From: Rostislav Lisovy @ 2014-09-09 13:07 UTC (permalink / raw)
  To: Wim Van Sebroeck, linux-watchdog, linux-kernel
  Cc: sojkam1, michal.vokac, lisovy, Rostislav Lisovy

This parameter makes it possible to control if the watchdog
is being disabled during initialization or will stay enabled
in case it was previously initialized in the bootloader.

To maintain the existing behavior, the default value is 'true',
thus the watchdog is disabled during initialization.

This new feature is highly inspired by the w83627hf_wdt.c

Signed-off-by: Rostislav Lisovy <lisovy@merica.cz>
---
 drivers/watchdog/omap_wdt.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/drivers/watchdog/omap_wdt.c b/drivers/watchdog/omap_wdt.c
index 3691b15..8f4cabe 100644
--- a/drivers/watchdog/omap_wdt.c
+++ b/drivers/watchdog/omap_wdt.c
@@ -53,6 +53,10 @@ static unsigned timer_margin;
 module_param(timer_margin, uint, 0);
 MODULE_PARM_DESC(timer_margin, "initial watchdog timeout (in seconds)");
 
+static bool early_disable = true;
+module_param(early_disable, bool, 0);
+MODULE_PARM_DESC(early_disable, "Disable watchdog at boot time (default=1)");
+
 struct omap_wdt_dev {
 	void __iomem    *base;          /* physical */
 	struct device   *dev;
@@ -255,7 +259,15 @@ static int omap_wdt_probe(struct platform_device *pdev)
 	omap_wdt->bootstatus = (rs & (1 << OMAP_MPU_WD_RST_SRC_ID_SHIFT)) ?
 				WDIOF_CARDRESET : 0;
 
-	omap_wdt_disable(wdev);
+	if (early_disable) {
+		pr_warn("Stopping previously enabled watchdog until userland kicks in\n");
+		omap_wdt_disable(wdev);
+	} else {
+		pr_info("Watchdog already running. Resetting timeout to %d sec\n",
+			omap_wdt->timeout);
+		omap_wdt_set_timeout(omap_wdt, omap_wdt->timeout);
+		omap_wdt_ping(omap_wdt);
+	}
 
 	ret = watchdog_register_device(omap_wdt);
 	if (ret) {
@@ -267,7 +279,8 @@ static int omap_wdt_probe(struct platform_device *pdev)
 		readl_relaxed(wdev->base + OMAP_WATCHDOG_REV) & 0xFF,
 		omap_wdt->timeout);
 
-	pm_runtime_put_sync(wdev->dev);
+	if (early_disable)
+		pm_runtime_put_sync(wdev->dev);
 
 	return 0;
 }
-- 
1.9.1


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

* Re: [PATCH] watchdog: omap_wdt: Add 'early_disable' module parameter
  2014-09-09 13:07 [PATCH] watchdog: omap_wdt: Add 'early_disable' module parameter Rostislav Lisovy
@ 2014-09-11 16:09 ` Guenter Roeck
  0 siblings, 0 replies; 2+ messages in thread
From: Guenter Roeck @ 2014-09-11 16:09 UTC (permalink / raw)
  To: Rostislav Lisovy
  Cc: Wim Van Sebroeck, linux-watchdog, linux-kernel, sojkam1,
	michal.vokac, Rostislav Lisovy

On Tue, Sep 09, 2014 at 03:07:37PM +0200, Rostislav Lisovy wrote:
> This parameter makes it possible to control if the watchdog
> is being disabled during initialization or will stay enabled
> in case it was previously initialized in the bootloader.
> 
> To maintain the existing behavior, the default value is 'true',
> thus the watchdog is disabled during initialization.
> 
> This new feature is highly inspired by the w83627hf_wdt.c
> 
> Signed-off-by: Rostislav Lisovy <lisovy@merica.cz>
> ---
>  drivers/watchdog/omap_wdt.c | 17 +++++++++++++++--
>  1 file changed, 15 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/watchdog/omap_wdt.c b/drivers/watchdog/omap_wdt.c
> index 3691b15..8f4cabe 100644
> --- a/drivers/watchdog/omap_wdt.c
> +++ b/drivers/watchdog/omap_wdt.c
> @@ -53,6 +53,10 @@ static unsigned timer_margin;
>  module_param(timer_margin, uint, 0);
>  MODULE_PARM_DESC(timer_margin, "initial watchdog timeout (in seconds)");
>  
> +static bool early_disable = true;
> +module_param(early_disable, bool, 0);
> +MODULE_PARM_DESC(early_disable, "Disable watchdog at boot time (default=1)");
> +


>  struct omap_wdt_dev {
>  	void __iomem    *base;          /* physical */
>  	struct device   *dev;
> @@ -255,7 +259,15 @@ static int omap_wdt_probe(struct platform_device *pdev)
>  	omap_wdt->bootstatus = (rs & (1 << OMAP_MPU_WD_RST_SRC_ID_SHIFT)) ?
>  				WDIOF_CARDRESET : 0;
>  
> -	omap_wdt_disable(wdev);
> +	if (early_disable) {
> +		pr_warn("Stopping previously enabled watchdog until userland kicks in\n");

This is an unconditional message which will be displayed even if the watchdog
was not running at all. Since there was previously no message, why add a
confusing one now ?

> +		omap_wdt_disable(wdev);
> +	} else {
> +		pr_info("Watchdog already running. Resetting timeout to %d sec\n",
> +			omap_wdt->timeout);
> +		omap_wdt_set_timeout(omap_wdt, omap_wdt->timeout);
> +		omap_wdt_ping(omap_wdt);
> +	}
>  
>  	ret = watchdog_register_device(omap_wdt);
>  	if (ret) {
> @@ -267,7 +279,8 @@ static int omap_wdt_probe(struct platform_device *pdev)
>  		readl_relaxed(wdev->base + OMAP_WATCHDOG_REV) & 0xFF,
>  		omap_wdt->timeout);
>  
> -	pm_runtime_put_sync(wdev->dev);
> +	if (early_disable)
> +		pm_runtime_put_sync(wdev->dev);

Doesn't that mean that you are now leaking the device usage counter
if early_disable is 0 ?

Guenter
>  
>  	return 0;
>  }
> -- 
> 1.9.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

end of thread, other threads:[~2014-09-11 16:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-09 13:07 [PATCH] watchdog: omap_wdt: Add 'early_disable' module parameter Rostislav Lisovy
2014-09-11 16:09 ` 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).