mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-24 06:24:17 +00:00
watchdog: Set/unset GD_FLG_WDT_READY flag in wdt_start()/wdt_stop()
Watchdog is ready after successful call of ops->start() callback in wdt_start() function. And is stopped after successful call of ops->stop() callback in wdt_stop function. So move setting of GD_FLG_WDT_READY flag from initr_watchdog() function to wdt_start() and ensure that GD_FLG_WDT_READY flag is unset in wdt_stop() function. This change ensures that GD_FLG_WDT_READY flag is set only when watchdog is running. And ensures that flag is also also when watchdog was started not only by initr_watchdog() call (e.g. by U-Boot 'wdt' command). Signed-off-by: Pali Rohár <pali@kernel.org> Reviewed-by: Stefan Roese <sr@denx.de>
This commit is contained in:
parent
90eba245a6
commit
9c44ff1c5f
1 changed files with 12 additions and 3 deletions
|
@ -51,7 +51,6 @@ int initr_watchdog(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
wdt_start(gd->watchdog_dev, timeout * 1000, 0);
|
wdt_start(gd->watchdog_dev, timeout * 1000, 0);
|
||||||
gd->flags |= GD_FLG_WDT_READY;
|
|
||||||
printf("WDT: Started with%s servicing (%ds timeout)\n",
|
printf("WDT: Started with%s servicing (%ds timeout)\n",
|
||||||
IS_ENABLED(CONFIG_WATCHDOG) ? "" : "out", timeout);
|
IS_ENABLED(CONFIG_WATCHDOG) ? "" : "out", timeout);
|
||||||
|
|
||||||
|
@ -61,21 +60,31 @@ int initr_watchdog(void)
|
||||||
int wdt_start(struct udevice *dev, u64 timeout_ms, ulong flags)
|
int wdt_start(struct udevice *dev, u64 timeout_ms, ulong flags)
|
||||||
{
|
{
|
||||||
const struct wdt_ops *ops = device_get_ops(dev);
|
const struct wdt_ops *ops = device_get_ops(dev);
|
||||||
|
int ret;
|
||||||
|
|
||||||
if (!ops->start)
|
if (!ops->start)
|
||||||
return -ENOSYS;
|
return -ENOSYS;
|
||||||
|
|
||||||
return ops->start(dev, timeout_ms, flags);
|
ret = ops->start(dev, timeout_ms, flags);
|
||||||
|
if (ret == 0)
|
||||||
|
gd->flags |= GD_FLG_WDT_READY;
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int wdt_stop(struct udevice *dev)
|
int wdt_stop(struct udevice *dev)
|
||||||
{
|
{
|
||||||
const struct wdt_ops *ops = device_get_ops(dev);
|
const struct wdt_ops *ops = device_get_ops(dev);
|
||||||
|
int ret;
|
||||||
|
|
||||||
if (!ops->stop)
|
if (!ops->stop)
|
||||||
return -ENOSYS;
|
return -ENOSYS;
|
||||||
|
|
||||||
return ops->stop(dev);
|
ret = ops->stop(dev);
|
||||||
|
if (ret == 0)
|
||||||
|
gd->flags &= ~GD_FLG_WDT_READY;
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int wdt_reset(struct udevice *dev)
|
int wdt_reset(struct udevice *dev)
|
||||||
|
|
Loading…
Add table
Reference in a new issue