]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
maple_tree: Rename functions and variables
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Fri, 4 Sep 2020 19:33:46 +0000 (15:33 -0400)
committerLiam R. Howlett <Liam.Howlett@Oracle.com>
Fri, 30 Oct 2020 19:11:08 +0000 (15:11 -0400)
Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
lib/maple_tree.c

index a010d1f8fc2998cba98c044d2842effb726c6109..b2e85da24db81a5c21ca0f5f5a86e573e6c49cb4 100644 (file)
@@ -472,32 +472,32 @@ static inline void mas_set_offset(struct ma_state *mas, int slot)
 }
 
 static inline unsigned long ma_get_pivot(const struct maple_node *mn,
-                                unsigned char slot, enum maple_type type)
+                                unsigned char piv, enum maple_type type)
 {
        switch (type) {
        case maple_arange_64:
-               return mn->ma64.pivot[slot];
+               return mn->ma64.pivot[piv];
        case maple_range_64:
        case maple_leaf_64:
-               return mn->mr64.pivot[slot];
+               return mn->mr64.pivot[piv];
        case maple_sparse_6:
                return mn->ms6.pivot;
        case maple_sparse_9:
-               return mn->ms9.pivot[slot];
+               return mn->ms9.pivot[piv];
        case maple_sparse_16:
-               return mn->ms16.pivot[slot];
+               return mn->ms16.pivot[piv];
        case maple_sparse_21:
-               return mn->ms21.pivot[slot];
+               return mn->ms21.pivot[piv];
        case maple_sparse_32:
-               return mn->ms32.pivot[slot];
+               return mn->ms32.pivot[piv];
        case maple_sparse_64:
-               return mn->ms64.pivot[slot];
+               return mn->ms64.pivot[piv];
        case maple_range_16:
        case maple_leaf_16:
-               return mn->mr16.pivot[slot];
+               return mn->mr16.pivot[piv];
        case maple_range_32:
        case maple_leaf_32:
-               return mn->mr32.pivot[slot];
+               return mn->mr32.pivot[piv];
        case maple_dense:
        default:
                return 0;
@@ -505,96 +505,98 @@ static inline unsigned long ma_get_pivot(const struct maple_node *mn,
 }
 
 static inline unsigned long _mte_get_pivot(const struct maple_enode *mn,
-                                unsigned char slot, enum maple_type type)
+                                unsigned char piv, enum maple_type type)
 {
-       return ma_get_pivot(mte_to_node(mn), slot, type);
+       return ma_get_pivot(mte_to_node(mn), piv, type);
 }
 
 static inline unsigned long mte_get_pivot(const struct maple_enode *mn,
-                                        unsigned char slot)
+                                        unsigned char piv)
 {
-       return _mte_get_pivot(mn, slot, mte_node_type(mn));
+       return _mte_get_pivot(mn, piv, mte_node_type(mn));
 }
 
-static inline unsigned long _mas_get_safe_pivot(const struct ma_state *mas,
-                               unsigned char slot, enum maple_type type)
+static inline unsigned long _mas_safe_pivot(const struct ma_state *mas,
+                               unsigned char piv, enum maple_type type)
 {
-       if (slot >= mt_pivots[type])
+       if (piv >= mt_pivots[type])
                return mas->max;
 
-       return _mte_get_pivot(mas->node, slot, type);
+       return _mte_get_pivot(mas->node, piv, type);
 }
 
 /*
- * mas_get_safe_pivot() - Return the pivot or the mas->max.
+ * mas_safe_pivot() - Return the pivot or the mas->max.
+ * @mas: The maple state.
+ * @piv:  the pivot location.
  *
- * Return: The pivot (including mas->max for the final slot)
+ * Return: The pivot (including mas->max for the final piv)
  */
-static inline unsigned long mas_get_safe_pivot(const struct ma_state *mas,
-                                        unsigned char slot)
+static inline unsigned long mas_safe_pivot(const struct ma_state *mas,
+                                        unsigned char piv)
 {
        enum maple_type type = mte_node_type(mas->node);
 
-       return _mas_get_safe_pivot(mas, slot, type);
+       return _mas_safe_pivot(mas, piv, type);
 }
 
-static inline unsigned long mas_get_safe_lower_bound(struct ma_state *mas,
-                                                    unsigned char slot)
+static inline unsigned long mas_safe_min(struct ma_state *mas,
+                                        unsigned char piv)
 {
-       if (!slot)
+       if (!piv)
                return mas->min;
 
-       return mas_get_safe_pivot(mas, slot - 1) + 1;
+       return mas_safe_pivot(mas, piv - 1) + 1;
 }
 
-static inline void ma_set_pivot(struct maple_node *mn, unsigned char slot,
+static inline void ma_set_pivot(struct maple_node *mn, unsigned char piv,
                enum maple_type type, unsigned long val)
 {
-       BUG_ON(slot >= mt_pivots[type]);
+       BUG_ON(piv >= mt_pivots[type]);
 
        switch (type) {
        default:
        case maple_range_64:
        case maple_leaf_64:
-               (&mn->mr64)->pivot[slot] = val;
+               (&mn->mr64)->pivot[piv] = val;
                break;
        case maple_arange_64:
-               (&mn->ma64)->pivot[slot] = val;
+               (&mn->ma64)->pivot[piv] = val;
        case maple_dense:
                break;
        case maple_sparse_6:
                (&mn->ms6)->pivot = val;
                break;
        case maple_sparse_9:
-               (&mn->ms9)->pivot[slot] = val;
+               (&mn->ms9)->pivot[piv] = val;
                break;
        case maple_sparse_16:
-               (&mn->ms16)->pivot[slot] = val;
+               (&mn->ms16)->pivot[piv] = val;
                break;
        case maple_sparse_21:
-               (&mn->ms21)->pivot[slot] = val;
+               (&mn->ms21)->pivot[piv] = val;
                break;
        case maple_sparse_32:
-               (&mn->ms32)->pivot[slot] = val;
+               (&mn->ms32)->pivot[piv] = val;
                break;
        case maple_sparse_64:
-               (&mn->ms64)->pivot[slot] = val;
+               (&mn->ms64)->pivot[piv] = val;
                break;
        case maple_range_16:
        case maple_leaf_16:
-               (&mn->mr16)->pivot[slot] = val;
+               (&mn->mr16)->pivot[piv] = val;
                break;
        case maple_range_32:
        case maple_leaf_32:
-               (&mn->mr32)->pivot[slot] = val;
+               (&mn->mr32)->pivot[piv] = val;
                break;
        }
 }
 
-static inline void mte_set_pivot(struct maple_enode *mn, unsigned char slot,
+static inline void mte_set_pivot(struct maple_enode *mn, unsigned char piv,
                                unsigned long val)
 {
-       return ma_set_pivot(mte_to_node(mn), slot, mte_node_type(mn), val);
+       return ma_set_pivot(mte_to_node(mn), piv, mte_node_type(mn), val);
 }
 
 static inline void __rcu **ma_get_slots(struct maple_node *mn,
@@ -828,8 +830,8 @@ static inline void mas_descend(struct ma_state *mas)
        unsigned char slot = mas_offset(mas);
 
        if (slot)
-               mas->min = mas_get_safe_pivot(mas, slot - 1) + 1;
-       mas->max = mas_get_safe_pivot(mas, slot);
+               mas->min = mas_safe_pivot(mas, slot - 1) + 1;
+       mas->max = mas_safe_pivot(mas, slot);
        mas->node = mas_get_rcu_slot(mas, mas_offset(mas));
 }
 
@@ -1132,7 +1134,7 @@ static inline unsigned char mas_data_end(const struct ma_state *mas)
        unsigned long piv = mas->min;
 
        while (slot < mt_slots[type]) {
-               piv = _mas_get_safe_pivot(mas, slot, type);
+               piv = _mas_safe_pivot(mas, slot, type);
                if (piv >= mas->max)
                        break;
                slot++;
@@ -1173,7 +1175,7 @@ static inline unsigned long mas_leaf_max_gap(struct ma_state *mas)
 
        pstart = mas->min;
        for (i = 0; i < mt_slots[mt]; i++) {
-               pend = mas_get_safe_pivot(mas, i);
+               pend = mas_safe_pivot(mas, i);
                if (!pend && i)
                        pend = mas->max;
 
@@ -1298,7 +1300,7 @@ static inline unsigned long mas_first_node(struct ma_state *mas,
        while (++slot < count) {
                struct maple_enode *mn;
 
-               pivot = mas_get_safe_pivot(mas, slot);
+               pivot = mas_safe_pivot(mas, slot);
                if (pivot > limit)
                        goto no_entry;
 
@@ -1346,7 +1348,7 @@ static inline unsigned long mas_first_entry(struct ma_state *mas,
                        mas_first_node(mas, limit);
                        if (mas_is_none(mas))
                                return limit;
-                       return mas_get_safe_pivot(mas,
+                       return mas_safe_pivot(mas,
                                        mas_offset(mas));
                }
 
@@ -1576,7 +1578,7 @@ static inline void mas_mab_cp(struct ma_state *mas, unsigned char mas_start,
                        b_node->gap[j] = mte_get_gap(mas->node, i);
 
                if (i < mt_pivot_count(mas->node))
-                       b_node->pivot[j] = mas_get_safe_pivot(mas, i);
+                       b_node->pivot[j] = mas_safe_pivot(mas, i);
                else
                        b_node->pivot[j] = mas->max;
 
@@ -1704,7 +1706,7 @@ static inline unsigned char mas_store_b_node(struct ma_state *mas,
        b_node->pivot[b_end] = mas->last;
 
        // Handle range overlap end.
-       piv = mas_get_safe_pivot(mas, slot);
+       piv = mas_safe_pivot(mas, slot);
        if (piv > mas->last) {
                b_node->slot[++b_end] = contents;
                if (!contents)
@@ -1719,7 +1721,7 @@ static inline unsigned char mas_store_b_node(struct ma_state *mas,
 
        // Handle range overwrites
        do {
-               piv = mas_get_safe_pivot(mas, ++slot);
+               piv = mas_safe_pivot(mas, ++slot);
        } while ((piv <= mas->last) && (slot <= end));
 
        // Copy end data to the end of the node.
@@ -2856,7 +2858,7 @@ static inline bool mas_node_walk(struct ma_state *mas, enum maple_type type,
        switch (type) {
        default:
                for (i = mas_offset(mas); i < mt_slots[type]; i++) {
-                       pivot = _mas_get_safe_pivot(mas, i, type);
+                       pivot = _mas_safe_pivot(mas, i, type);
 
                        if (!pivot && i) {
                                if (mas->max < mas->index) {
@@ -2966,11 +2968,11 @@ static inline unsigned char mas_extend_null(struct ma_state *l_mas,
        unsigned char r_slot = mas_offset(r_mas);
        unsigned char cp_r_slot = r_slot;
        void *content = mas_get_rcu_slot(l_mas, l_slot);
-       unsigned long range_max = mas_get_safe_pivot(r_mas, r_slot);
+       unsigned long range_max = mas_safe_pivot(r_mas, r_slot);
        unsigned long range_min = l_mas->min;
 
        if (l_slot)
-               range_min = mas_get_safe_pivot(l_mas, l_slot - 1) + 1;
+               range_min = mas_safe_pivot(l_mas, l_slot - 1) + 1;
 
        if (!content)
                l_mas->index = range_min;
@@ -2978,7 +2980,7 @@ static inline unsigned char mas_extend_null(struct ma_state *l_mas,
        if ((l_mas->index == range_min) &&
            l_slot && !mas_get_rcu_slot(l_mas, l_slot - 1)) {
                if (l_slot > 1)
-                       l_mas->index = mas_get_safe_pivot(l_mas, l_slot - 2) + 1;
+                       l_mas->index = mas_safe_pivot(l_mas, l_slot - 2) + 1;
                else
                        l_mas->index = l_mas->min;
                mas_set_offset(l_mas, l_slot - 1);
@@ -2992,7 +2994,7 @@ static inline unsigned char mas_extend_null(struct ma_state *l_mas,
 
        if (r_mas->last == range_max &&
            r_mas->last < r_mas->max && !mas_get_rcu_slot(r_mas, r_slot + 1)) {
-               r_mas->last = mas_get_safe_pivot(r_mas, r_slot + 1);
+               r_mas->last = mas_safe_pivot(r_mas, r_slot + 1);
                cp_r_slot++;
        }
 
@@ -3250,7 +3252,7 @@ static inline void mas_prev_node(struct ma_state *mas, unsigned long limit)
        struct maple_enode *mn;
        int level;
 
-       start_piv = mas_get_safe_pivot(mas, slot);
+       start_piv = mas_safe_pivot(mas, slot);
 restart_prev_node:
        level = 0;
        if (mte_is_root(mas->node) || mas->node == MAS_NONE)
@@ -3270,9 +3272,9 @@ restart_prev_node:
 
                slot--;
                do {
-                       pivot = mas_get_safe_pivot(mas, slot);
+                       pivot = mas_safe_pivot(mas, slot);
 
-                       min = mas_get_safe_lower_bound(mas, slot);
+                       min = mas_safe_min(mas, slot);
                        if (pivot < limit)
                                goto no_entry;
 
@@ -3335,7 +3337,7 @@ restart_next_node:
 
                mn = mas->node;
                slot = mas_offset(mas);
-               start_piv = mas_get_safe_pivot(mas, slot);
+               start_piv = mas_safe_pivot(mas, slot);
                level++;
                mas_ascend(mas);
 
@@ -3343,9 +3345,9 @@ restart_next_node:
                        goto restart_next_node;
 
                count = mt_slot_count(mas->node);
-               prev_piv = mas_get_safe_pivot(mas, slot);
+               prev_piv = mas_safe_pivot(mas, slot);
                while (++slot < count) {
-                       unsigned long pivot = mas_get_safe_pivot(mas, slot);
+                       unsigned long pivot = mas_safe_pivot(mas, slot);
 
                        if (prev_piv > max)
                                goto no_entry;
@@ -3403,7 +3405,7 @@ static inline bool mas_prev_nentry(struct ma_state *mas, unsigned long limit,
 
        slot--;
        do {
-               pivot = mas_get_safe_pivot(mas, slot);
+               pivot = mas_safe_pivot(mas, slot);
                if (pivot < limit)
                        return false;
 
@@ -3433,10 +3435,10 @@ static inline bool mas_next_nentry(struct ma_state *mas, unsigned long max,
        unsigned char count = mt_slot_count(mas->node);
        void *entry;
 
-       r_start = mas_get_safe_lower_bound(mas, slot);
+       r_start = mas_safe_min(mas, slot);
 
        while (slot < count) {
-               pivot = mas_get_safe_pivot(mas, slot);
+               pivot = mas_safe_pivot(mas, slot);
 
                if (pivot > mas->max) // possibly a retry.
                        goto no_entry;
@@ -3603,7 +3605,7 @@ static inline void *_mas_prev(struct ma_state *mas, unsigned long limit)
 
        mas->last = max;
        slot = mas_offset(mas);
-       mas->index = mas_get_safe_lower_bound(mas, slot);
+       mas->index = mas_safe_min(mas, slot);
        return mas_get_rcu_slot(mas, mas_offset(mas));
 }
 
@@ -3648,12 +3650,12 @@ static inline bool _mas_rev_awalk(struct ma_state *mas, unsigned long size)
        unsigned long gap = 0;
        bool found = false;
 
-       max = _mas_get_safe_pivot(mas, slot, type);
+       max = _mas_safe_pivot(mas, slot, type);
        switch (type) {
        case maple_leaf_64:
        default:
                do {
-                       min = mas_get_safe_lower_bound(mas, slot);
+                       min = mas_safe_min(mas, slot);
                        /* last is below this range */
                        if (mas->last < min)
                                goto next_slot;
@@ -3711,7 +3713,7 @@ next_slot:
 
                mas->node = next;
                slot = mas_data_end(mas);
-               max = mas_get_safe_pivot(mas, slot);
+               max = mas_safe_pivot(mas, slot);
        }
 
        mas_set_offset(mas, slot);
@@ -3736,9 +3738,9 @@ static inline bool _mas_awalk(struct ma_state *mas, unsigned long size)
                slot = mas_offset(mas);
                fallthrough;
        case maple_leaf_64:
-               min = mas_get_safe_lower_bound(mas, slot);
+               min = mas_safe_min(mas, slot);
                for (; slot <= pivot_cnt; slot++) {
-                       pivot = _mas_get_safe_pivot(mas, slot, type);
+                       pivot = _mas_safe_pivot(mas, slot, type);
                        if (slot && !pivot)
                                break;
 
@@ -3994,8 +3996,8 @@ static int mas_fill_gap(struct ma_state *mas, void *entry, unsigned char slot,
         * calculation, so fix the ma_state here
         */
        mas_ascend(mas);
-       mas->max = mas_get_safe_pivot(mas, pslot);
-       mas->min = mas_get_safe_lower_bound(mas, pslot);
+       mas->max = mas_safe_pivot(mas, pslot);
+       mas->min = mas_safe_min(mas, pslot);
        mas->node = mn;
        mas_set_offset(mas, slot);
        _mas_store(mas, entry, false);
@@ -4012,7 +4014,7 @@ void mas_set_fwd_index(struct ma_state *mas, unsigned long size)
                min = mte_get_pivot(mas->node, slot - 1) + 1;
 
        mas->min = min;
-       mas->max = mas_get_safe_pivot(mas, slot);
+       mas->max = mas_safe_pivot(mas, slot);
 
        if (mas->index < min)
                mas->index = min;
@@ -5070,7 +5072,7 @@ void mas_validate_gaps(struct ma_state *mas)
        }
 
        for (i = 0; i < mt_slot_count(mte); i++) {
-               p_end = mas_get_safe_pivot(mas, i);
+               p_end = mas_safe_pivot(mas, i);
                if (!p_end && i)
                        p_end = mas->max;
 
@@ -5206,7 +5208,7 @@ void mas_validate_limits(struct ma_state *mas)
                return; // all limits are fine here.
 
        for (i = 0; i < mt_slot_count(mas->node); i++) {
-               unsigned long piv = mas_get_safe_pivot(mas, i);
+               unsigned long piv = mas_safe_pivot(mas, i);
 
                if (!piv)
                        break;