public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH 1/4] watchdog: Set/unset GD_FLG_WDT_READY flag in wdt_start()/wdt_stop()
@ 2021-03-05 21:36 Pali Rohár
  2021-03-05 21:36 ` [PATCH 2/4] watchdog: Show error message when initr_watchdog() cannot start watchdog Pali Rohár
                   ` (4 more replies)
  0 siblings, 5 replies; 20+ messages in thread
From: Pali Rohár @ 2021-03-05 21:36 UTC (permalink / raw)
  To: u-boot

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>
---
 drivers/watchdog/wdt-uclass.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/drivers/watchdog/wdt-uclass.c b/drivers/watchdog/wdt-uclass.c
index 28f7918c4673..3f707f61f74f 100644
--- a/drivers/watchdog/wdt-uclass.c
+++ b/drivers/watchdog/wdt-uclass.c
@@ -51,7 +51,6 @@ int initr_watchdog(void)
 	}
 
 	wdt_start(gd->watchdog_dev, timeout * 1000, 0);
-	gd->flags |= GD_FLG_WDT_READY;
 	printf("WDT:   Started with%s servicing (%ds timeout)\n",
 	       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)
 {
 	const struct wdt_ops *ops = device_get_ops(dev);
+	int ret;
 
 	if (!ops->start)
 		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)
 {
 	const struct wdt_ops *ops = device_get_ops(dev);
+	int ret;
 
 	if (!ops->stop)
 		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)
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2021-04-06 10:28 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-03-05 21:36 [PATCH 1/4] watchdog: Set/unset GD_FLG_WDT_READY flag in wdt_start()/wdt_stop() Pali Rohár
2021-03-05 21:36 ` [PATCH 2/4] watchdog: Show error message when initr_watchdog() cannot start watchdog Pali Rohár
2021-03-09 11:27   ` Stefan Roese
2021-03-05 21:36 ` [PATCH 3/4] watchdog: Allow to use CONFIG_WDT without starting watchdog Pali Rohár
2021-03-09 11:33   ` Stefan Roese
2021-03-09 13:27     ` Pali Rohár
2021-03-09 16:12       ` Stefan Roese
2021-03-09 16:14         ` Pali Rohár
2021-03-05 21:36 ` [PATCH 4/4] arm: mvebu: Espressobin: Enable watchdog support but do not start it Pali Rohár
2021-03-09 11:34   ` Stefan Roese
2021-03-09 11:26 ` [PATCH 1/4] watchdog: Set/unset GD_FLG_WDT_READY flag in wdt_start()/wdt_stop() Stefan Roese
2021-03-09 13:26 ` [PATCH v2 " Pali Rohár
2021-03-09 13:26   ` [PATCH v2 2/4] watchdog: Show error message when initr_watchdog() cannot start watchdog Pali Rohár
2021-03-09 16:13     ` Stefan Roese
2021-03-09 13:26   ` [PATCH v2 3/4] watchdog: Allow to use CONFIG_WDT without starting watchdog Pali Rohár
2021-03-09 16:13     ` Stefan Roese
2021-03-09 13:26   ` [PATCH v2 4/4] arm: mvebu: Espressobin: Enable watchdog support but do not start it Pali Rohár
2021-03-09 16:13     ` Stefan Roese
2021-03-09 16:13   ` [PATCH v2 1/4] watchdog: Set/unset GD_FLG_WDT_READY flag in wdt_start()/wdt_stop() Stefan Roese
2021-04-06 10:28   ` Stefan Roese

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox