aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRasmus Villemoes <rasmus.villemoes@prevas.dk>2021-08-19 11:56:59 +0200
committerStefan Roese <sr@denx.de>2021-08-31 12:04:03 +0200
commitf1b112afbb6d7a1d88fd2ad3b4a285b95612757c (patch)
treea1f880bc533650c57d0e4311875ed10b941922a3
parent3eaf6e2e42c5855036a11dd7c00831226c27f152 (diff)
downloadu-boot-f1b112afbb6d7a1d88fd2ad3b4a285b95612757c.zip
u-boot-f1b112afbb6d7a1d88fd2ad3b4a285b95612757c.tar.gz
u-boot-f1b112afbb6d7a1d88fd2ad3b4a285b95612757c.tar.bz2
watchdog: wdt-uclass.c: keep track of each device's running state
As a step towards handling all DM watchdogs in watchdog_reset(), use a per-device flag to keep track of whether the device has been started instead of a bit in gd->flags. We will still need that bit to know whether we are past initr_watchdog() and hence have populated gd->watchdog_dev - incidentally, that is how it was used prior to commit 9c44ff1c5f3c. Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Stefan Roese <sr@denx.de> Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
-rw-r--r--drivers/watchdog/wdt-uclass.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/drivers/watchdog/wdt-uclass.c b/drivers/watchdog/wdt-uclass.c
index 0a1f437..358fc68 100644
--- a/drivers/watchdog/wdt-uclass.c
+++ b/drivers/watchdog/wdt-uclass.c
@@ -33,6 +33,8 @@ struct wdt_priv {
* ->reset().
*/
ulong next_reset;
+ /* Whether watchdog_start() has been called on the device. */
+ bool running;
};
static void init_watchdog_dev(struct udevice *dev)
@@ -74,6 +76,7 @@ int initr_watchdog(void)
}
init_watchdog_dev(gd->watchdog_dev);
+ gd->flags |= GD_FLG_WDT_READY;
return 0;
}
@@ -86,8 +89,11 @@ int wdt_start(struct udevice *dev, u64 timeout_ms, ulong flags)
return -ENOSYS;
ret = ops->start(dev, timeout_ms, flags);
- if (ret == 0)
- gd->flags |= GD_FLG_WDT_READY;
+ if (ret == 0) {
+ struct wdt_priv *priv = dev_get_uclass_priv(dev);
+
+ priv->running = true;
+ }
return ret;
}
@@ -101,8 +107,11 @@ int wdt_stop(struct udevice *dev)
return -ENOSYS;
ret = ops->stop(dev);
- if (ret == 0)
- gd->flags &= ~GD_FLG_WDT_READY;
+ if (ret == 0) {
+ struct wdt_priv *priv = dev_get_uclass_priv(dev);
+
+ priv->running = false;
+ }
return ret;
}
@@ -156,6 +165,9 @@ void watchdog_reset(void)
dev = gd->watchdog_dev;
priv = dev_get_uclass_priv(dev);
+ if (!priv->running)
+ return;
+
/* Do not reset the watchdog too often */
now = get_timer(0);
if (time_after_eq(now, priv->next_reset)) {