diff options
author | Alex Williamson <alex.williamson@redhat.com> | 2021-02-22 10:14:24 -0700 |
---|---|---|
committer | Alex Williamson <alex.williamson@redhat.com> | 2021-02-22 10:14:24 -0700 |
commit | 72d6e4871f0457dc9e498f8437ea344ee6b78075 (patch) | |
tree | 44a6975d7f0818086e34b8e84e3164527fac36f4 /lib/timerqueue.c | |
parent | b9abef43a08ef7faa33477cccb0c08c64eb2b8bf (diff) | |
parent | 3e10585335b7967326ca7b4118cada0d2d00a2ab (diff) |
Merge commit '3e10585335b7967326ca7b4118cada0d2d00a2ab' into v5.12/vfio/next
Update to new follow_pte() definition
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 c527109645930..cdb9c7658478f 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); |