diff options
| -rw-r--r-- | common/cyclic.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/common/cyclic.c b/common/cyclic.c index ec952a01ee1..573e715587d 100644 --- a/common/cyclic.c +++ b/common/cyclic.c @@ -41,7 +41,7 @@ static bool cyclic_is_registered(const struct cyclic_info *cyclic) } void cyclic_register(struct cyclic_info *cyclic, cyclic_func_t func, - uint64_t delay_us, const char *name) + u64 delay_us, const char *name) { cyclic_unregister(cyclic); @@ -67,26 +67,28 @@ static void cyclic_run(void) { struct cyclic_info *cyclic; struct hlist_node *tmp; - uint64_t now, cpu_time; + u64 now, after, cpu_time; /* Prevent recursion */ if (gd->flags & GD_FLG_CYCLIC_RUNNING) return; gd->flags |= GD_FLG_CYCLIC_RUNNING; + now = get_timer_us(0); hlist_for_each_entry_safe(cyclic, tmp, cyclic_get_list(), list) { /* * Check if this cyclic function needs to get called, e.g. * do not call the cyclic func too often */ - now = get_timer_us(0); if (time_after_eq64(now, cyclic->next_call)) { /* Call cyclic function and account it's cpu-time */ cyclic->next_call = now + cyclic->delay_us; cyclic->func(cyclic); + after = get_timer_us(0); cyclic->run_cnt++; - cpu_time = get_timer_us(0) - now; + cpu_time = after - now; cyclic->cpu_time_us += cpu_time; + now = after; /* Check if cpu-time exceeds max allowed time */ if ((cpu_time > CONFIG_CYCLIC_MAX_CPU_TIME_US) && |
