Lines Matching +full:root +full:- +full:node

1 /* SPDX-License-Identifier: GPL-2.0 */
14 * Enumerate bits using enum autoincrement. Define the @name as the n-th bit.
50 return n != 0 && (n & (n - 1)) == 0; in is_power_of_two_u64()
69 static inline struct rb_node *rb_simple_search(const struct rb_root *root, u64 bytenr) in rb_simple_search() argument
71 struct rb_node *node = root->rb_node; in rb_simple_search() local
74 while (node) { in rb_simple_search()
75 entry = rb_entry(node, struct rb_simple_node, rb_node); in rb_simple_search()
77 if (bytenr < entry->bytenr) in rb_simple_search()
78 node = node->rb_left; in rb_simple_search()
79 else if (bytenr > entry->bytenr) in rb_simple_search()
80 node = node->rb_right; in rb_simple_search()
82 return node; in rb_simple_search()
88 * Search @root from an entry that starts or comes after @bytenr.
90 * @root: the root to search.
96 static inline struct rb_node *rb_simple_search_first(const struct rb_root *root, in rb_simple_search_first() argument
99 struct rb_node *node = root->rb_node, *ret = NULL; in rb_simple_search_first() local
102 while (node) { in rb_simple_search_first()
103 entry = rb_entry(node, struct rb_simple_node, rb_node); in rb_simple_search_first()
105 if (bytenr < entry->bytenr) { in rb_simple_search_first()
106 if (!ret || entry->bytenr < ret_entry->bytenr) { in rb_simple_search_first()
107 ret = node; in rb_simple_search_first()
111 node = node->rb_left; in rb_simple_search_first()
112 } else if (bytenr > entry->bytenr) { in rb_simple_search_first()
113 node = node->rb_right; in rb_simple_search_first()
115 return node; in rb_simple_search_first()
122 static inline struct rb_node *rb_simple_insert(struct rb_root *root, u64 bytenr, in rb_simple_insert() argument
123 struct rb_node *node) in rb_simple_insert() argument
125 struct rb_node **p = &root->rb_node; in rb_simple_insert()
133 if (bytenr < entry->bytenr) in rb_simple_insert()
134 p = &(*p)->rb_left; in rb_simple_insert()
135 else if (bytenr > entry->bytenr) in rb_simple_insert()
136 p = &(*p)->rb_right; in rb_simple_insert()
141 rb_link_node(node, parent, p); in rb_simple_insert()
142 rb_insert_color(node, root); in rb_simple_insert()