diff options
author | John Stultz <john.stultz@linaro.org> | 2010-09-20 17:42:46 -0700 |
---|---|---|
committer | John Stultz <john.stultz@linaro.org> | 2010-12-02 16:41:39 -0800 |
commit | 87de5ac782761a3ebf806e434e8c9cc205a87274 (patch) | |
tree | 8186969d00da5d0daea37fcb92538bbc72c8f086 /include | |
parent | 5e4f083f78d03e9f8d2e327daccde16976f9bb00 (diff) | |
download | linux-87de5ac782761a3ebf806e434e8c9cc205a87274.tar.gz linux-87de5ac782761a3ebf806e434e8c9cc205a87274.tar.bz2 linux-87de5ac782761a3ebf806e434e8c9cc205a87274.zip |
timers: Introduce timerlist infrastructure.
The timerlist infrastructure is a thin layer over the rbtree
code that implements a simple list of timers sorted by an
expires value, and a getnext function that provides a pointer
to the earliest timer.
This infrastructure allows drivers and other kernel infrastructure
to easily implement timers without duplicating code.
Signed-off-by: John Stultz <john.stultz@linaro.org>
LKML Reference: <1290136329-18291-2-git-send-email-john.stultz@linaro.org>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
CC: Alessandro Zummo <a.zummo@towertech.it>
CC: Thomas Gleixner <tglx@linutronix.de>
CC: Richard Cochran <richardcochran@gmail.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/timerlist.h | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/include/linux/timerlist.h b/include/linux/timerlist.h new file mode 100644 index 000000000000..c46b28ae6e4d --- /dev/null +++ b/include/linux/timerlist.h @@ -0,0 +1,37 @@ +#ifndef _LINUX_TIMERLIST_H +#define _LINUX_TIMERLIST_H + +#include <linux/rbtree.h> +#include <linux/ktime.h> + + +struct timerlist_node { + struct rb_node node; + ktime_t expires; +}; + +struct timerlist_head { + struct rb_root head; + struct timerlist_node *next; +}; + + +extern void timerlist_add(struct timerlist_head *head, + struct timerlist_node *node); +extern void timerlist_del(struct timerlist_head *head, + struct timerlist_node *node); +extern struct timerlist_node *timerlist_getnext(struct timerlist_head *head); +extern struct timerlist_node *timerlist_iterate_next( + struct timerlist_node *node); + +static inline void timerlist_init(struct timerlist_node *node) +{ + RB_CLEAR_NODE(&node->node); +} + +static inline void timerlist_init_head(struct timerlist_head *head) +{ + head->head = RB_ROOT; + head->next = NULL; +} +#endif /* _LINUX_TIMERLIST_H */ |