- while (need_next) {
- need_next = false;
- if (!timers->level[level+1]) {
- found = find_first(&timers->far, found);
- } else {
- /* Current upper bucket has emptied into this
- * bucket; we want *next* one. */
- base >>= TIMER_LEVEL_BITS;
- base++;
- off = base % PER_LEVEL;
-
- if (off == 0) {
- need_next = true;
- } else {
- h = &timers->level[level+1]->list[off];
- found = find_first(h, found);
- }
+static const struct timer *get_first(struct timers *timers)
+{
+ /* We can have just far timers, for example. */
+ if (timers->level[0]) {
+ /* First search rest of lower buckets; we've already spilled
+ * so if we find one there we don't need to search further. */
+ unsigned int i, off = timers->base % PER_LEVEL;
+
+ for (i = off; i < PER_LEVEL; i++) {
+ struct list_head *h = &timers->level[0]->list[i];
+ if (!list_empty(h))
+ return find_first(h, 0, NULL);