mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Stefan Christ <s.christ@phytec.de>
To: barebox@lists.infradead.org
Subject: [PATCH] wdog: imx-wd: watchdog cannot be disabled again
Date: Thu, 12 Nov 2015 13:18:55 +0100	[thread overview]
Message-ID: <1447330735-7568-1-git-send-email-s.christ@phytec.de> (raw)

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

             reply	other threads:[~2015-11-12 12:19 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-12 12:18 Stefan Christ [this message]
2015-11-13  7:54 ` Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1447330735-7568-1-git-send-email-s.christ@phytec.de \
    --to=s.christ@phytec.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox