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>
* ->reset().
*/
ulong next_reset;
+ /* Whether watchdog_start() has been called on the device. */
+ bool running;
};
static void init_watchdog_dev(struct udevice *dev)
}
init_watchdog_dev(gd->watchdog_dev);
+ gd->flags |= GD_FLG_WDT_READY;
return 0;
}
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;
}
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;
}
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)) {