All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCHv2] watchdog: cadence_wdt: Fix the suspend resume
@ 2016-08-23  9:49 Shubhrajyoti Datta
  2016-08-23 12:45 ` Guenter Roeck
  0 siblings, 1 reply; 3+ messages in thread
From: Shubhrajyoti Datta @ 2016-08-23  9:49 UTC (permalink / raw)
  To: linux-watchdog; +Cc: linux, shubhrajyoti.datta, Shubhrajyoti Datta

Currently even if no users are there the suspend tries to
stop the watchdog and resume starts it.

so after resume the watchdog starts and resets the board.
Fix the same by adding a check for users.

Signed-off-by: Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com>
---
v2: use watchdog_active

 drivers/watchdog/cadence_wdt.c |   18 +++++++++++-------
 1 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/drivers/watchdog/cadence_wdt.c b/drivers/watchdog/cadence_wdt.c
index 4dda902..0fd267e 100644
--- a/drivers/watchdog/cadence_wdt.c
+++ b/drivers/watchdog/cadence_wdt.c
@@ -424,8 +424,10 @@ static int __maybe_unused cdns_wdt_suspend(struct device *dev)
 	struct platform_device *pdev = to_platform_device(dev);
 	struct cdns_wdt *wdt = platform_get_drvdata(pdev);
 
-	cdns_wdt_stop(&wdt->cdns_wdt_device);
-	clk_disable_unprepare(wdt->clk);
+	if (watchdog_active(&wdt->cdns_wdt_device)) {
+		cdns_wdt_stop(&wdt->cdns_wdt_device);
+		clk_disable_unprepare(wdt->clk);
+	}
 
 	return 0;
 }
@@ -442,12 +444,14 @@ static int __maybe_unused cdns_wdt_resume(struct device *dev)
 	struct platform_device *pdev = to_platform_device(dev);
 	struct cdns_wdt *wdt = platform_get_drvdata(pdev);
 
-	ret = clk_prepare_enable(wdt->clk);
-	if (ret) {
-		dev_err(dev, "unable to enable clock\n");
-		return ret;
+	if (watchdog_active(&wdt->cdns_wdt_device)) {
+		ret = clk_prepare_enable(wdt->clk);
+		if (ret) {
+			dev_err(dev, "unable to enable clock\n");
+			return ret;
+		}
+		cdns_wdt_start(&wdt->cdns_wdt_device);
 	}
-	cdns_wdt_start(&wdt->cdns_wdt_device);
 
 	return 0;
 }
-- 
1.7.1


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

* Re: [PATCHv2] watchdog: cadence_wdt: Fix the suspend resume
  2016-08-23  9:49 [PATCHv2] watchdog: cadence_wdt: Fix the suspend resume Shubhrajyoti Datta
@ 2016-08-23 12:45 ` Guenter Roeck
  2016-09-07  5:57   ` Shubhrajyoti Datta
  0 siblings, 1 reply; 3+ messages in thread
From: Guenter Roeck @ 2016-08-23 12:45 UTC (permalink / raw)
  To: Shubhrajyoti Datta, linux-watchdog; +Cc: shubhrajyoti.datta

On 08/23/2016 02:49 AM, Shubhrajyoti Datta wrote:
> Currently even if no users are there the suspend tries to
> stop the watchdog and resume starts it.
>
> so after resume the watchdog starts and resets the board.
> Fix the same by adding a check for users.
>
> Signed-off-by: Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com>

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

> ---
> v2: use watchdog_active
>
>  drivers/watchdog/cadence_wdt.c |   18 +++++++++++-------
>  1 files changed, 11 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/watchdog/cadence_wdt.c b/drivers/watchdog/cadence_wdt.c
> index 4dda902..0fd267e 100644
> --- a/drivers/watchdog/cadence_wdt.c
> +++ b/drivers/watchdog/cadence_wdt.c
> @@ -424,8 +424,10 @@ static int __maybe_unused cdns_wdt_suspend(struct device *dev)
>  	struct platform_device *pdev = to_platform_device(dev);
>  	struct cdns_wdt *wdt = platform_get_drvdata(pdev);
>
> -	cdns_wdt_stop(&wdt->cdns_wdt_device);
> -	clk_disable_unprepare(wdt->clk);
> +	if (watchdog_active(&wdt->cdns_wdt_device)) {
> +		cdns_wdt_stop(&wdt->cdns_wdt_device);
> +		clk_disable_unprepare(wdt->clk);
> +	}
>
>  	return 0;
>  }
> @@ -442,12 +444,14 @@ static int __maybe_unused cdns_wdt_resume(struct device *dev)
>  	struct platform_device *pdev = to_platform_device(dev);
>  	struct cdns_wdt *wdt = platform_get_drvdata(pdev);
>
> -	ret = clk_prepare_enable(wdt->clk);
> -	if (ret) {
> -		dev_err(dev, "unable to enable clock\n");
> -		return ret;
> +	if (watchdog_active(&wdt->cdns_wdt_device)) {
> +		ret = clk_prepare_enable(wdt->clk);
> +		if (ret) {
> +			dev_err(dev, "unable to enable clock\n");
> +			return ret;
> +		}
> +		cdns_wdt_start(&wdt->cdns_wdt_device);
>  	}
> -	cdns_wdt_start(&wdt->cdns_wdt_device);
>
>  	return 0;
>  }
>


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

* Re: [PATCHv2] watchdog: cadence_wdt: Fix the suspend resume
  2016-08-23 12:45 ` Guenter Roeck
@ 2016-09-07  5:57   ` Shubhrajyoti Datta
  0 siblings, 0 replies; 3+ messages in thread
From: Shubhrajyoti Datta @ 2016-09-07  5:57 UTC (permalink / raw)
  To: Guenter Roeck; +Cc: Shubhrajyoti Datta, linux-watchdog

On Tue, Aug 23, 2016 at 6:15 PM, Guenter Roeck <linux@roeck-us.net> wrote:
> On 08/23/2016 02:49 AM, Shubhrajyoti Datta wrote:
>>
>> Currently even if no users are there the suspend tries to
>> stop the watchdog and resume starts it.
>>
>> so after resume the watchdog starts and resets the board.
>> Fix the same by adding a check for users.
>>
>> Signed-off-by: Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com>
>
>
> Reviewed-by: Guenter Roeck <linux@roeck-us.net>
If there are no further comments then can this be merged

>
>
>> ---

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

end of thread, other threads:[~2016-09-07  5:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-23  9:49 [PATCHv2] watchdog: cadence_wdt: Fix the suspend resume Shubhrajyoti Datta
2016-08-23 12:45 ` Guenter Roeck
2016-09-07  5:57   ` Shubhrajyoti Datta

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.