}
/*
- * _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.
*
*
* 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;
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.
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
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;
}
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);
*/
void *mas_prev(struct ma_state *mas, unsigned long min)
{
+ void *entry;
+
if (!mas->index) {
/* Nothing comes before 0 */
mas->last = 0;
mas->node = MAS_START;
if (mas_is_start(mas)) {
- void *entry;
mas->last = --mas->index;
mas_start(mas);
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);
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);