xref: /openbmc/linux/include/linux/interval_tree.h (revision 0c94efab)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _LINUX_INTERVAL_TREE_H
3 #define _LINUX_INTERVAL_TREE_H
4 
5 #include <linux/rbtree.h>
6 
7 struct interval_tree_node {
8 	struct rb_node rb;
9 	unsigned long start;	/* Start of interval */
10 	unsigned long last;	/* Last location _in_ interval */
11 	unsigned long __subtree_last;
12 };
13 
14 extern void
15 interval_tree_insert(struct interval_tree_node *node,
16 		     struct rb_root_cached *root);
17 
18 extern void
19 interval_tree_remove(struct interval_tree_node *node,
20 		     struct rb_root_cached *root);
21 
22 extern struct interval_tree_node *
23 interval_tree_iter_first(struct rb_root_cached *root,
24 			 unsigned long start, unsigned long last);
25 
26 extern struct interval_tree_node *
27 interval_tree_iter_next(struct interval_tree_node *node,
28 			unsigned long start, unsigned long last);
29 
30 #endif	/* _LINUX_INTERVAL_TREE_H */
31