Re: [PATCH 1/2] cyclic: get rid of cyclic_get_list() helper
Stefan Roese via U-Boot <[email protected]> Mon, 3 Aug 2026 14:27:23 +0200
| Newsgroups | gmane.comp.boot-loaders.u-boot |
|---|---|
| Message-ID | <[email protected]> |
On 7/30/26 12:55, Rasmus Villemoes wrote: > 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 <[email protected]> Reviewed-by: Stefan Roese <[email protected]> Thanks, Stefan > --- > cmd/cyclic.c | 5 ++++- > common/cyclic.c | 14 ++++---------- > include/cyclic.h | 9 --------- > 3 files changed, 8 insertions(+), 20 deletions(-) > > diff --git a/cmd/cyclic.c b/cmd/cyclic.c > index 339dd4a7bce..880cd648aae 100644 > --- a/cmd/cyclic.c > +++ b/cmd/cyclic.c > @@ -16,6 +16,9 @@ > #include <vsprintf.h> > #include <linux/delay.h> > #include <linux/kernel.h> > +#include <asm/global_data.h> > + > +DECLARE_GLOBAL_DATA_PTR; > > struct cyclic_demo_info { > struct cyclic_info cyclic; > @@ -64,7 +67,7 @@ static int do_cyclic_list(struct cmd_tbl *cmdtp, int flag, int argc, > struct hlist_node *tmp; > u64 cnt, freq; > > - hlist_for_each_entry_safe(cyclic, tmp, cyclic_get_list(), list) { > + hlist_for_each_entry_safe(cyclic, tmp, &gd->cyclic_list, list) { > cnt = cyclic->run_cnt * 1000000ULL * 100ULL; > freq = lldiv(cnt, timer_get_us() - cyclic->start_time_us); > printf("function: %s, cpu-time: %lld us, frequency: %lld.%02d times/s\n", > diff --git a/common/cyclic.c b/common/cyclic.c > index 573e715587d..2bc3c773f27 100644 > --- a/common/cyclic.c > +++ b/common/cyclic.c > @@ -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; > diff --git a/include/cyclic.h b/include/cyclic.h > index df8b725e3d0..ec2c53b6ecf 100644 > --- a/include/cyclic.h > +++ b/include/cyclic.h > @@ -78,15 +78,6 @@ void cyclic_unregister(struct cyclic_info *cyclic); > */ > int cyclic_unregister_all(void); > > -/** > - * cyclic_get_list() - Get cyclic list pointer > - * > - * Return the cyclic list pointer > - * > - * @return: pointer to cyclic_list > - */ > -struct hlist_head *cyclic_get_list(void); > - > #else > > static inline void cyclic_register(struct cyclic_info *cyclic, cyclic_func_t func,