| 246 | } |
| 247 | |
| 248 | static const struct timer *get_first(struct timers *timers) |
| 249 | { |
| 250 | /* We can have just far timers, for example. */ |
| 251 | if (timers->level[0]) { |
| 252 | /* First search rest of lower buckets; we've already spilled |
| 253 | * so if we find one there we don't need to search further. */ |
| 254 | unsigned int i, off = timers->base % PER_LEVEL; |
| 255 | |
| 256 | for (i = off; i < PER_LEVEL; i++) { |
| 257 | struct list_head *h = &timers->level[0]->list[i]; |
| 258 | if (!list_empty(h)) |
| 259 | return find_first(h, 0, NULL); |
| 260 | } |
| 261 | } |
| 262 | |
| 263 | /* From here on, we're searching non-normalized parts of the |
| 264 | * data structure, which is much subtler. |
| 265 | * |
| 266 | * So we brute force. */ |
| 267 | return brute_force_first(timers); |
| 268 | } |
| 269 | |
| 270 | static bool update_first(struct timers *timers) |
| 271 | { |