cyclic: get rid of cyclic_get_list() helper

As the comment indicates, this was used to silence a warning without
having to add casts everywhere gd->cyclic_list was referenced. But
nowadays gd is not volatile qualified, so this helper is not needed
and only obfuscates the code somewhat, because the head of the list
being operated on with the hlist_ or list_ macros is usually not
obtained via a function call.

Remove the helper and refer to the list head using the idiomatic
&gd->cyclic_list.

Signed-off-by: Rasmus Villemoes <rv@rasmusvillemoes.dk>
Reviewed-by: Stefan Roese <stefan.roese@mailbox.org>
This commit is contained in:
Rasmus Villemoes
2026-08-03 14:46:51 +02:00
committed by Stefan Roese
parent baa64b2f89
commit dcadbeed2a
3 changed files with 8 additions and 20 deletions
+4 -10
View File
@@ -22,17 +22,11 @@ DECLARE_GLOBAL_DATA_PTR;
void hw_watchdog_reset(void);
struct hlist_head *cyclic_get_list(void)
{
/* Silence "discards 'volatile' qualifier" warning. */
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) {
hlist_for_each_entry(c, &gd->cyclic_list, list) {
if (c == cyclic)
return true;
}
@@ -52,7 +46,7 @@ void cyclic_register(struct cyclic_info *cyclic, cyclic_func_t func,
cyclic->name = name;
cyclic->delay_us = delay_us;
cyclic->start_time_us = get_timer_us(0);
hlist_add_head(&cyclic->list, cyclic_get_list());
hlist_add_head(&cyclic->list, &gd->cyclic_list);
}
void cyclic_unregister(struct cyclic_info *cyclic)
@@ -75,7 +69,7 @@ static void cyclic_run(void)
gd->flags |= GD_FLG_CYCLIC_RUNNING;
now = get_timer_us(0);
hlist_for_each_entry_safe(cyclic, tmp, cyclic_get_list(), list) {
hlist_for_each_entry_safe(cyclic, tmp, &gd->cyclic_list, list) {
/*
* Check if this cyclic function needs to get called, e.g.
* do not call the cyclic func too often
@@ -129,7 +123,7 @@ int cyclic_unregister_all(void)
struct cyclic_info *cyclic;
struct hlist_node *tmp;
hlist_for_each_entry_safe(cyclic, tmp, cyclic_get_list(), list)
hlist_for_each_entry_safe(cyclic, tmp, &gd->cyclic_list, list)
cyclic_unregister(cyclic);
return 0;