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