[PATCH] wdog: imx-wd: watchdog cannot be disabled again
Stefan Christ
s.christ at phytec.de
Thu Nov 12 04:18:55 PST 2015
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 at 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
More information about the barebox
mailing list