[PATCH v1 2/6] cyclic: Introduce schedule() function

Stefan Roese sr at denx.de
Fri Sep 2 14:10:45 CEST 2022


This patch introduces a schedule() function, which shall be used instead
of the old WATCHDOG_RESET. Follow-up patches will make sure, that this
new function is used.

Signed-off-by: Stefan Roese <sr at denx.de>
Reviewed-by: Simon Glass <sjg at chromium.org>
---
v1:
- Add Simon's SoB tag
- Add more comments in the header to fully document the prototypes

 common/cyclic.c  | 11 +++++++++++
 include/cyclic.h | 12 ++++++++++++
 2 files changed, 23 insertions(+)

diff --git a/common/cyclic.c b/common/cyclic.c
index f0bfd18c9242..0b07ede8d35e 100644
--- a/common/cyclic.c
+++ b/common/cyclic.c
@@ -18,6 +18,8 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
+void hw_watchdog_reset(void);
+
 struct list_head *cyclic_get_list()
 {
 	return &gd->cyclic->cyclic_list;
@@ -96,6 +98,15 @@ void cyclic_run(void)
 	gd->cyclic->cyclic_running = false;
 }
 
+void schedule(void)
+{
+	/* The HW watchdog is not integrated into the cyclic IF (yet) */
+	if (IS_ENABLED(CONFIG_HW_WATCHDOG))
+		hw_watchdog_reset();
+
+	cyclic_run();
+}
+
 int cyclic_uninit(void)
 {
 	struct cyclic_info *cyclic, *tmp;
diff --git a/include/cyclic.h b/include/cyclic.h
index 23902234cc87..760163643345 100644
--- a/include/cyclic.h
+++ b/include/cyclic.h
@@ -106,6 +106,14 @@ struct list_head *cyclic_get_list(void);
  * needs to be executed, then call into these registered functions.
  */
 void cyclic_run(void);
+
+/**
+ * schedule() - Schedule all potentially waiting tasks
+ *
+ * Basically a wrapper for cyclic_run(), pontentially enhanced by some
+ * other parts, that need to get handled periodically.
+ */
+void schedule(void);
 #else
 static inline struct cyclic_info *cyclic_register(cyclic_func_t func,
 						  uint64_t delay_us,
@@ -124,6 +132,10 @@ static inline void cyclic_run(void)
 {
 }
 
+static inline void schedule(void)
+{
+}
+
 static inline int cyclic_init(void)
 {
 	return 0;
-- 
2.37.3



More information about the U-Boot mailing list