On 28.10.22 13:50, Rasmus Villemoes wrote:
As a preparation for future patches, use a flag in gd->flags rather
than a separate member in (the singleton) struct cyclic_drv to keep
track of whether we're already inside cyclic_run().

Signed-off-by: Rasmus Villemoes <rasmus.villem...@prevas.dk>
---
  common/cyclic.c                   | 6 +++---
  include/asm-generic/global_data.h | 4 ++++
  include/cyclic.h                  | 2 --
  3 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/common/cyclic.c b/common/cyclic.c
index 7abb82c16a..ff75c8cadb 100644
--- a/common/cyclic.c
+++ b/common/cyclic.c
@@ -66,10 +66,10 @@ void cyclic_run(void)
        uint64_t now, cpu_time;
/* Prevent recursion */
-       if (gd->cyclic->cyclic_running)
+       if (gd->flags & GD_FLG_CYCLIC_RUNNING)
                return;
- gd->cyclic->cyclic_running = true;
+       gd->flags |= GD_FLG_CYCLIC_RUNNING;
        list_for_each_entry_safe(cyclic, tmp, &gd->cyclic->cyclic_list, list) {
                /*
                 * Check if this cyclic function needs to get called, e.g.
@@ -99,7 +99,7 @@ void cyclic_run(void)
                        }
                }
        }
-       gd->cyclic->cyclic_running = false;
+       gd->flags &= ~GD_FLG_CYCLIC_RUNNING;
  }
void schedule(void)
diff --git a/include/asm-generic/global_data.h 
b/include/asm-generic/global_data.h
index 2d55fe2ac0..ca36907b20 100644
--- a/include/asm-generic/global_data.h
+++ b/include/asm-generic/global_data.h
@@ -650,6 +650,10 @@ enum gd_flags {
         * @GD_FLG_FDT_CHANGED: Device tree change has been detected by tests
         */
        GD_FLG_FDT_CHANGED = 0x100000,
+       /**
+        * GD_FLG_CYCLIC_RUNNING: cyclic_run is in progress
+        */
+       GD_FLG_CYCLIC_RUNNING = 0x200000,
  };
#endif /* __ASSEMBLY__ */
diff --git a/include/cyclic.h b/include/cyclic.h
index 9c5c4fcc54..50427baa3f 100644
--- a/include/cyclic.h
+++ b/include/cyclic.h
@@ -19,12 +19,10 @@
   *
   * @cyclic_list: Cylic list node
   * @cyclic_ready: Flag if cyclic infrastructure is ready
- * @cyclic_running: Flag if cyclic infrastructure is running
   */
  struct cyclic_drv {
        struct list_head cyclic_list;
        bool cyclic_ready;
-       bool cyclic_running;
  };
/**

Reviewed-by: Stefan Roese <s...@denx.de>
Tested-by: Stefan Roese <s...@denx.de>

Thanks,
Stefan

Reply via email to