diff options
author | Tom Rini <trini@konsulko.com> | 2025-05-26 16:07:19 -0600 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2025-05-26 16:07:19 -0600 |
commit | 39b815d02d7ce6af32bcf023d20243c404b75a84 (patch) | |
tree | 68cd13fa83e90f69bf8c989fbcde768b676eb6d7 /common/cyclic.c | |
parent | bab54f5942c428be698216224fd10b91d974d4da (diff) | |
parent | 2ca1398a5ece8d33d8feb6b410e6e38588b5d2bc (diff) |
Merge tag 'v2025.07-rc3' into next
Prepare v2025.07-rc3
Diffstat (limited to 'common/cyclic.c')
-rw-r--r-- | common/cyclic.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/common/cyclic.c b/common/cyclic.c index b695f092f52..ec952a01ee1 100644 --- a/common/cyclic.c +++ b/common/cyclic.c @@ -28,9 +28,23 @@ struct hlist_head *cyclic_get_list(void) return (struct hlist_head *)&gd->cyclic_list; } +static bool cyclic_is_registered(const struct cyclic_info *cyclic) +{ + const struct cyclic_info *c; + + hlist_for_each_entry(c, cyclic_get_list(), list) { + if (c == cyclic) + return true; + } + + return false; +} + void cyclic_register(struct cyclic_info *cyclic, cyclic_func_t func, uint64_t delay_us, const char *name) { + cyclic_unregister(cyclic); + memset(cyclic, 0, sizeof(*cyclic)); /* Store values in struct */ @@ -43,6 +57,9 @@ void cyclic_register(struct cyclic_info *cyclic, cyclic_func_t func, void cyclic_unregister(struct cyclic_info *cyclic) { + if (!cyclic_is_registered(cyclic)) + return; + hlist_del(&cyclic->list); } |