mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] wdog: imx-wd: watchdog cannot be disabled again
@ 2015-11-12 12:18 Stefan Christ
  2015-11-13  7:54 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Stefan Christ @ 2015-11-12 12:18 UTC (permalink / raw)
  To: barebox

The i.MX21/i.MX6 watchdog cannot be disabled after it was activated.
Bit 2 (WDE) cannot be set to 0 again. Notify the user about that by
returning -ENOSYS.

Signed-off-by: Stefan Christ <s.christ@phytec.de>
---
 drivers/watchdog/imxwd.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/watchdog/imxwd.c b/drivers/watchdog/imxwd.c
index dd11a62..bb0d2db 100644
--- a/drivers/watchdog/imxwd.c
+++ b/drivers/watchdog/imxwd.c
@@ -97,14 +97,14 @@ static int imx21_watchdog_set_timeout(struct imx_wd *priv, int timeout)
 
 	dev_dbg(priv->dev, "%s: %d\n", __func__, timeout);
 
-	if (!timeout || timeout > 128)
+	if (timeout < 0 || timeout > 128)
 		return -EINVAL;
 
-	if (timeout > 0)
-		val = ((timeout * 2 - 1) << 8) | IMX21_WDOG_WCR_SRS |
-			IMX21_WDOG_WCR_WDA;
-	else
-		val = 0;
+	if (timeout == 0) /* bit 2 (WDE) cannot be set to 0 again */
+		return -ENOSYS;
+
+	val = ((timeout * 2 - 1) << 8) | IMX21_WDOG_WCR_SRS |
+		IMX21_WDOG_WCR_WDA;
 
 	writew(val, priv->base + IMX21_WDOG_WCR);
 	writew(IMX21_WDOG_WCR_WDE | val, priv->base + IMX21_WDOG_WCR);
-- 
1.9.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH] wdog: imx-wd: watchdog cannot be disabled again
  2015-11-12 12:18 [PATCH] wdog: imx-wd: watchdog cannot be disabled again Stefan Christ
@ 2015-11-13  7:54 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2015-11-13  7:54 UTC (permalink / raw)
  To: Stefan Christ; +Cc: barebox

On Thu, Nov 12, 2015 at 01:18:55PM +0100, Stefan Christ wrote:
> The i.MX21/i.MX6 watchdog cannot be disabled after it was activated.
> Bit 2 (WDE) cannot be set to 0 again. Notify the user about that by
> returning -ENOSYS.
> 
> Signed-off-by: Stefan Christ <s.christ@phytec.de>
> ---
>  drivers/watchdog/imxwd.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)

Applied, thanks

Sascha

> 
> diff --git a/drivers/watchdog/imxwd.c b/drivers/watchdog/imxwd.c
> index dd11a62..bb0d2db 100644
> --- a/drivers/watchdog/imxwd.c
> +++ b/drivers/watchdog/imxwd.c
> @@ -97,14 +97,14 @@ static int imx21_watchdog_set_timeout(struct imx_wd *priv, int timeout)
>  
>  	dev_dbg(priv->dev, "%s: %d\n", __func__, timeout);
>  
> -	if (!timeout || timeout > 128)
> +	if (timeout < 0 || timeout > 128)
>  		return -EINVAL;
>  
> -	if (timeout > 0)
> -		val = ((timeout * 2 - 1) << 8) | IMX21_WDOG_WCR_SRS |
> -			IMX21_WDOG_WCR_WDA;
> -	else
> -		val = 0;
> +	if (timeout == 0) /* bit 2 (WDE) cannot be set to 0 again */
> +		return -ENOSYS;
> +
> +	val = ((timeout * 2 - 1) << 8) | IMX21_WDOG_WCR_SRS |
> +		IMX21_WDOG_WCR_WDA;
>  
>  	writew(val, priv->base + IMX21_WDOG_WCR);
>  	writew(IMX21_WDOG_WCR_WDE | val, priv->base + IMX21_WDOG_WCR);
> -- 
> 1.9.1
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2015-11-13  7:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-12 12:18 [PATCH] wdog: imx-wd: watchdog cannot be disabled again Stefan Christ
2015-11-13  7:54 ` Sascha Hauer

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