Source
26
26
#include <linux/timerqueue.h>
27
27
#include <linux/rbtree.h>
28
28
#include <linux/export.h>
29
29
30
30
/**
31
31
* timerqueue_add - Adds timer to timerqueue.
32
32
*
33
33
* @head: head of timerqueue
34
34
* @node: timer node to be added
35
35
*
36
-
* Adds the timer node to the timerqueue, sorted by the
37
-
* node's expires value.
36
+
* Adds the timer node to the timerqueue, sorted by the node's expires
37
+
* value. Returns true if the newly added timer is the first expiring timer in
38
+
* the queue.
38
39
*/
39
40
bool timerqueue_add(struct timerqueue_head *head, struct timerqueue_node *node)
40
41
{
41
42
struct rb_node **p = &head->head.rb_node;
42
43
struct rb_node *parent = NULL;
43
44
struct timerqueue_node *ptr;
44
45
45
46
/* Make sure we don't add nodes that are already added */
46
47
WARN_ON_ONCE(!RB_EMPTY_NODE(&node->node));
47
48
63
64
return false;
64
65
}
65
66
EXPORT_SYMBOL_GPL(timerqueue_add);
66
67
67
68
/**
68
69
* timerqueue_del - Removes a timer from the timerqueue.
69
70
*
70
71
* @head: head of timerqueue
71
72
* @node: timer node to be removed
72
73
*
73
-
* Removes the timer node from the timerqueue.
74
+
* Removes the timer node from the timerqueue. Returns true if the queue is
75
+
* not empty after the remove.
74
76
*/
75
77
bool timerqueue_del(struct timerqueue_head *head, struct timerqueue_node *node)
76
78
{
77
79
WARN_ON_ONCE(RB_EMPTY_NODE(&node->node));
78
80
79
81
/* update next pointer */
80
82
if (head->next == node) {
81
83
struct rb_node *rbn = rb_next(&node->node);
82
84
83
85
head->next = rb_entry_safe(rbn, struct timerqueue_node, node);