From: Liam R. Howlett Date: Tue, 9 Nov 2021 18:27:16 +0000 (-0500) Subject: maple_tree: Remove _mas_find() and _mas_prev(), rename _mas_next() to mas_next_entry() X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=20cae1318dd1e0383a454ae1615ee8a6fee4e370;p=users%2Fjedix%2Flinux-maple.git maple_tree: Remove _mas_find() and _mas_prev(), rename _mas_next() to mas_next_entry() Signed-off-by: Liam R. Howlett --- diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 5ca5f319e3b8..46b86756914d 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -4831,7 +4831,7 @@ none: } /* - * _mas_next() - Internal function to get the next entry. + * mas_next_entry() - Internal function to get the next entry. * @mas: The maple state * @limit: The maximum range start. * @@ -4842,7 +4842,7 @@ none: * * Return: the next entry or %NULL. */ -static inline void *_mas_next(struct ma_state *mas, unsigned long limit) +static inline void *mas_next_entry(struct ma_state *mas, unsigned long limit) { void *entry = NULL; struct maple_enode *prev_node; @@ -4948,37 +4948,6 @@ retry: return entry; } -/* - * _mas_prev() - Internal function. Return the previous entry - * @mas: The maple state. - * @limit: The lower limit to check. - * - * Return: the previous entry or %NULL. - */ -static inline void *_mas_prev(struct ma_state *mas, unsigned long limit) -{ - void *entry; - unsigned long index = mas->index; - -retry: - while (likely(!mas_is_none(mas))) { - entry = mas_prev_nentry(mas, limit, index); - if (likely(entry)) - return entry; - - if (unlikely(mas_prev_node(mas, limit))) { - mas_rewalk(mas, index); - goto retry; - } - - if (!mas_is_none(mas)) - mas->offset = mas_data_end(mas) + 1; - } - - mas->index = mas->last = limit; - return NULL; -} - /* * _mas_rev_awalk() - Internal function. Reverse allocation walk. Find the * highest gap address of a given size in a given node and descend. @@ -5535,35 +5504,6 @@ no_gap: return -EBUSY; } -/* - * _mas_find() - Finds the entry at @mas->index on MAS_START or the next entry - * and sets @mas->index and @mas->last to the range. - * @mas: The maple state - * @limit: The maximum value to check. - * - * Return: Point to the next entry or %NULL - */ -static inline void *_mas_find(struct ma_state *mas, unsigned long limit) -{ - if (unlikely(mas_is_start(mas))) { - /* First run or continue */ - void *entry; - - if (mas->index > limit) - return NULL; - - entry = mas_walk(mas); - if (entry) - return entry; - } - - if (unlikely(!mas_searchable(mas))) - return NULL; - - /* Retries on dead nodes handled by _mas_next */ - return _mas_next(mas, limit); -} - /* * _mt_find() - Search from start up until an entry is found. * @mt: The maple tree @@ -5604,7 +5544,7 @@ void *_mt_find(struct maple_tree *mt, unsigned long *index, unsigned long max, mas.index = range_start; while (mas_searchable(&mas) && (mas.index < max)) { - entry = _mas_next(&mas, max); + entry = mas_next_entry(&mas, max); if (likely(entry && !xa_is_zero(entry))) break; } @@ -6015,8 +5955,8 @@ void *mas_next(struct ma_state *mas, unsigned long max) return entry; } - /* Retries on dead nodes handled by _mas_next */ - return _mas_next(mas, max); + /* Retries on dead nodes handled by mas_next_entry */ + return mas_next_entry(mas, max); } EXPORT_SYMBOL_GPL(mas_next); @@ -6053,6 +5993,8 @@ EXPORT_SYMBOL_GPL(mt_next); */ void *mas_prev(struct ma_state *mas, unsigned long min) { + void *entry; + if (!mas->index) { /* Nothing comes before 0 */ mas->last = 0; @@ -6066,7 +6008,6 @@ void *mas_prev(struct ma_state *mas, unsigned long min) mas->node = MAS_START; if (mas_is_start(mas)) { - void *entry; mas->last = --mas->index; mas_start(mas); @@ -6075,7 +6016,23 @@ void *mas_prev(struct ma_state *mas, unsigned long min) return entry; } - return _mas_prev(mas, min); +retry: + while (likely(!mas_is_none(mas))) { + entry = mas_prev_nentry(mas, min, mas->index); + if (likely(entry)) + return entry; + + if (unlikely(mas_prev_node(mas, min))) { + mas_rewalk(mas, mas->index); + goto retry; + } + + if (!mas_is_none(mas)) + mas->offset = mas_data_end(mas) + 1; + } + + mas->index = mas->last = min; + return NULL; } EXPORT_SYMBOL_GPL(mas_prev); @@ -6141,7 +6098,23 @@ void *mas_find(struct ma_state *mas, unsigned long max) mas->index = ++mas->last; } - return _mas_find(mas, max); + if (unlikely(mas_is_start(mas))) { + /* First run or continue */ + void *entry; + + if (mas->index > max) + return NULL; + + entry = mas_walk(mas); + if (entry) + return entry; + } + + if (unlikely(!mas_searchable(mas))) + return NULL; + + /* Retries on dead nodes handled by mas_next_entry */ + return mas_next_entry(mas, max); } EXPORT_SYMBOL_GPL(mas_find);