diff options
author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2021-05-04 21:46:00 +0300 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2021-05-04 21:46:00 +0300 |
commit | d0034a7a4ac7fae708146ac0059b9c47a1543f0d (patch) | |
tree | ac3ac88066f0f80632aa754e3ae008994f2426a2 /lib/timerqueue.c | |
parent | 56cfe6f820a6315291eb5a1b82bb49633b993d3b (diff) | |
parent | d12b64b9764ea17554fb230784ebf91287ed807e (diff) | |
download | linux-d0034a7a4ac7fae708146ac0059b9c47a1543f0d.tar.xz |
Merge branch 'next' into for-linus
Prepare input updates for 5.13 merge window.
Diffstat (limited to 'lib/timerqueue.c')
-rw-r--r-- | lib/timerqueue.c | 28 |
1 files changed, 9 insertions, 19 deletions
diff --git a/lib/timerqueue.c b/lib/timerqueue.c index c52710964593..cdb9c7658478 100644 --- a/lib/timerqueue.c +++ b/lib/timerqueue.c @@ -14,6 +14,14 @@ #include <linux/rbtree.h> #include <linux/export.h> +#define __node_2_tq(_n) \ + rb_entry((_n), struct timerqueue_node, node) + +static inline bool __timerqueue_less(struct rb_node *a, const struct rb_node *b) +{ + return __node_2_tq(a)->expires < __node_2_tq(b)->expires; +} + /** * timerqueue_add - Adds timer to timerqueue. * @@ -26,28 +34,10 @@ */ bool timerqueue_add(struct timerqueue_head *head, struct timerqueue_node *node) { - struct rb_node **p = &head->rb_root.rb_root.rb_node; - struct rb_node *parent = NULL; - struct timerqueue_node *ptr; - bool leftmost = true; - /* Make sure we don't add nodes that are already added */ WARN_ON_ONCE(!RB_EMPTY_NODE(&node->node)); - while (*p) { - parent = *p; - ptr = rb_entry(parent, struct timerqueue_node, node); - if (node->expires < ptr->expires) { - p = &(*p)->rb_left; - } else { - p = &(*p)->rb_right; - leftmost = false; - } - } - rb_link_node(&node->node, parent, p); - rb_insert_color_cached(&node->node, &head->rb_root, leftmost); - - return leftmost; + return rb_add_cached(&node->node, &head->rb_root, __timerqueue_less); } EXPORT_SYMBOL_GPL(timerqueue_add); |