]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
cyclic: drop redundant cyclic_ready flag
authorRasmus Villemoes <rasmus.villemoes@prevas.dk>
Fri, 28 Oct 2022 11:50:51 +0000 (13:50 +0200)
committerStefan Roese <sr@denx.de>
Wed, 2 Nov 2022 07:41:42 +0000 (08:41 +0100)
We're already relying on gd->cyclic being NULL before cyclic_init() is
called - i.e., we're relying on all of gd being zeroed before entering
any C code. And when we do populate gd->cyclic, its ->cyclic_ready
member is automatically set to true. So we can actually just rely on
testing gd->cyclic itself.

The only wrinkle is that cyclic_uninit() actually did set
->cyclic_ready to false. However, since it doesn't free gd->cyclic,
the cyclic infrastructure is actually still ready (i.e., the list_head
is properly initialized as an empty list).

Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
Reviewed-by: Stefan Roese <sr@denx.de>
Tested-by: Stefan Roese <sr@denx.de>
Tested-by: Tim Harvey <tharvey@gateworks.com> # imx8mm-venice-*
common/cyclic.c
include/cyclic.h

index ff75c8cadb9125819e126e10237395f3f7e6fb41..d6f11b002ed5010783b106d11f2a2b83ec099187 100644 (file)
@@ -30,7 +30,7 @@ struct cyclic_info *cyclic_register(cyclic_func_t func, uint64_t delay_us,
 {
        struct cyclic_info *cyclic;
 
-       if (!gd->cyclic->cyclic_ready) {
+       if (!gd->cyclic) {
                pr_debug("Cyclic IF not ready yet\n");
                return NULL;
        }
@@ -112,7 +112,7 @@ void schedule(void)
         * schedule() might get called very early before the cyclic IF is
         * ready. Make sure to only call cyclic_run() when it's initalized.
         */
-       if (gd && gd->cyclic && gd->cyclic->cyclic_ready)
+       if (gd && gd->cyclic)
                cyclic_run();
 }
 
@@ -122,7 +122,6 @@ int cyclic_uninit(void)
 
        list_for_each_entry_safe(cyclic, tmp, &gd->cyclic->cyclic_list, list)
                cyclic_unregister(cyclic);
-       gd->cyclic->cyclic_ready = false;
 
        return 0;
 }
@@ -137,7 +136,6 @@ int cyclic_init(void)
 
        memset(gd->cyclic, '\0', size);
        INIT_LIST_HEAD(&gd->cyclic->cyclic_list);
-       gd->cyclic->cyclic_ready = true;
 
        return 0;
 }
index 50427baa3f49d65044fadce2738ac3c0c664a523..263b74d89b8aa34f321d349cfb9d5ab0d047eed5 100644 (file)
  * struct cyclic_drv - Cyclic driver internal data
  *
  * @cyclic_list: Cylic list node
- * @cyclic_ready: Flag if cyclic infrastructure is ready
  */
 struct cyclic_drv {
        struct list_head cyclic_list;
-       bool cyclic_ready;
 };
 
 /**