]> www.infradead.org Git - users/willy/xarray.git/commitdiff
pinctrl: Convert pin_function_tree to XArray
authorMatthew Wilcox <willy@infradead.org>
Thu, 25 Oct 2018 20:42:48 +0000 (16:42 -0400)
committerMatthew Wilcox (Oracle) <willy@infradead.org>
Fri, 9 Aug 2019 01:38:12 +0000 (21:38 -0400)
Straightforward conversion; no locking changes.

Signed-off-by: Matthew Wilcox <willy@infradead.org>
drivers/pinctrl/core.c
drivers/pinctrl/core.h
drivers/pinctrl/freescale/pinctrl-imx.c
drivers/pinctrl/pinmux.c
drivers/pinctrl/zte/pinctrl-zx.c

index 79a3e40b66f94feef463c47fc8743684776f8901..a110eaa699a4fc6dbcddb658a3828dd9724699af 100644 (file)
@@ -1925,7 +1925,7 @@ pinctrl_init_controller(struct pinctrl_desc *pctldesc, struct device *dev,
        xa_init(&pctldev->pin_group_xa);
 #endif
 #ifdef CONFIG_GENERIC_PINMUX_FUNCTIONS
-       INIT_RADIX_TREE(&pctldev->pin_function_tree, GFP_KERNEL);
+       xa_init(&pctldev->pin_function_xa);
 #endif
        INIT_LIST_HEAD(&pctldev->gpio_ranges);
        INIT_LIST_HEAD(&pctldev->node);
index 09cbfaa230e62548b65c4e7f3bf2d62ff2f7acc2..35b6f12fee7517a2d7efc054c8433cf5cf497de1 100644 (file)
@@ -25,7 +25,7 @@ struct pinctrl_gpio_range;
  *     this radix tree
  * @pin_group_xa: optionally each pin group can be stored in this array
  * @num_groups: optionally number of groups can be kept here
- * @pin_function_tree: optionally each function can be stored in this radix tree
+ * @pin_function_xa: optionally each function can be stored in this array
  * @num_functions: optionally number of functions can be kept here
  * @gpio_ranges: a list of GPIO ranges that is handled by this pin controller,
  *     ranges are added to this list at runtime
@@ -48,7 +48,7 @@ struct pinctrl_dev {
        unsigned int num_groups;
 #endif
 #ifdef CONFIG_GENERIC_PINMUX_FUNCTIONS
-       struct radix_tree_root pin_function_tree;
+       struct xarray pin_function_xa;
        unsigned int num_functions;
 #endif
        struct list_head gpio_ranges;
index 82bf6554177ec2bf7f6649d98e9698d148b12596..53d69695b96eadcc6815e1e6f988a2fb66dc4d19 100644 (file)
@@ -742,7 +742,7 @@ static int imx_pinctrl_probe_dt(struct platform_device *pdev,
                        return -ENOMEM;
 
                mutex_lock(&ipctl->mutex);
-               radix_tree_insert(&pctl->pin_function_tree, i, function);
+               xa_store(&pctl->pin_function_xa, i, function, GFP_KERNEL);
                mutex_unlock(&ipctl->mutex);
        }
        pctl->num_functions = nfuncs;
index 020e54f843f97d7aed70d6983eba2e229802f57e..2aad7df8a115dbaec9ef275b2eaa382f2bd8efd2 100644 (file)
@@ -680,8 +680,7 @@ pinmux_generic_get_function_name(struct pinctrl_dev *pctldev,
 {
        struct function_desc *function;
 
-       function = radix_tree_lookup(&pctldev->pin_function_tree,
-                                    selector);
+       function = xa_load(&pctldev->pin_function_xa, selector);
        if (!function)
                return NULL;
 
@@ -703,8 +702,7 @@ int pinmux_generic_get_function_groups(struct pinctrl_dev *pctldev,
 {
        struct function_desc *function;
 
-       function = radix_tree_lookup(&pctldev->pin_function_tree,
-                                    selector);
+       function = xa_load(&pctldev->pin_function_xa, selector);
        if (!function) {
                dev_err(pctldev->dev, "%s could not find function%i\n",
                        __func__, selector);
@@ -727,8 +725,7 @@ struct function_desc *pinmux_generic_get_function(struct pinctrl_dev *pctldev,
 {
        struct function_desc *function;
 
-       function = radix_tree_lookup(&pctldev->pin_function_tree,
-                                    selector);
+       function = xa_load(&pctldev->pin_function_xa, selector);
        if (!function)
                return NULL;
 
@@ -771,7 +768,7 @@ int pinmux_generic_add_function(struct pinctrl_dev *pctldev,
        function->num_group_names = num_groups;
        function->data = data;
 
-       radix_tree_insert(&pctldev->pin_function_tree, selector, function);
+       xa_store(&pctldev->pin_function_xa, selector, function, GFP_KERNEL);
 
        pctldev->num_functions++;
 
@@ -791,12 +788,10 @@ int pinmux_generic_remove_function(struct pinctrl_dev *pctldev,
 {
        struct function_desc *function;
 
-       function = radix_tree_lookup(&pctldev->pin_function_tree,
-                                    selector);
+       function = xa_erase(&pctldev->pin_function_xa, selector);
        if (!function)
                return -ENOENT;
 
-       radix_tree_delete(&pctldev->pin_function_tree, selector);
        devm_kfree(pctldev->dev, function);
 
        pctldev->num_functions--;
@@ -815,12 +810,7 @@ EXPORT_SYMBOL_GPL(pinmux_generic_remove_function);
  */
 void pinmux_generic_free_functions(struct pinctrl_dev *pctldev)
 {
-       struct radix_tree_iter iter;
-       void __rcu **slot;
-
-       radix_tree_for_each_slot(slot, &pctldev->pin_function_tree, &iter, 0)
-               radix_tree_delete(&pctldev->pin_function_tree, iter.index);
-
+       xa_destroy(&pctldev->pin_function_xa);
        pctldev->num_functions = 0;
 }
 
index 4baf2aae5a7cf6f555fa7b41ff9c50273e6bd54d..24868a2eac0b364311d0abd059738c96fffd73d8 100644 (file)
@@ -325,8 +325,8 @@ static int zx_pinctrl_build_state(struct platform_device *pdev)
                                /* New function */
                                func->name = mux->name;
                                func->num_group_names = 1;
-                               radix_tree_insert(&pctldev->pin_function_tree,
-                                                 nfunctions++, func);
+                               xa_store(&pctldev->pin_function_xa,
+                                               nfunctions++, func, GFP_KERNEL);
                        }
 
                        mux++;