]> www.infradead.org Git - users/willy/xarray.git/commitdiff
pinctrl: Convert pin_desc_tree to XArray
authorMatthew Wilcox <willy@infradead.org>
Thu, 25 Oct 2018 20:50:34 +0000 (16:50 -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

index a110eaa699a4fc6dbcddb658a3828dd9724699af..3f0cd4520a03e1e533cb5edb5b5243d15cc9ecfa 100644 (file)
@@ -187,14 +187,9 @@ static void pinctrl_free_pindescs(struct pinctrl_dev *pctldev,
        for (i = 0; i < num_pins; i++) {
                struct pin_desc *pindesc;
 
-               pindesc = radix_tree_lookup(&pctldev->pin_desc_tree,
-                                           pins[i].number);
-               if (pindesc) {
-                       radix_tree_delete(&pctldev->pin_desc_tree,
-                                         pins[i].number);
-                       if (pindesc->dynamic_name)
-                               kfree(pindesc->name);
-               }
+               pindesc = xa_erase(&pctldev->pin_desc_xa, pins[i].number);
+               if (pindesc && pindesc->dynamic_name)
+                       kfree(pindesc->name);
                kfree(pindesc);
        }
 }
@@ -232,7 +227,7 @@ static int pinctrl_register_one_pin(struct pinctrl_dev *pctldev,
 
        pindesc->drv_data = pin->drv_data;
 
-       radix_tree_insert(&pctldev->pin_desc_tree, pin->number, pindesc);
+       xa_store(&pctldev->pin_desc_xa, pin->number, pindesc, GFP_KERNEL);
        pr_debug("registered pin %d (%s) on %s\n",
                 pin->number, pindesc->name, pctldev->desc->name);
        return 0;
@@ -1920,7 +1915,7 @@ pinctrl_init_controller(struct pinctrl_desc *pctldesc, struct device *dev,
        pctldev->owner = pctldesc->owner;
        pctldev->desc = pctldesc;
        pctldev->driver_data = driver_data;
-       INIT_RADIX_TREE(&pctldev->pin_desc_tree, GFP_KERNEL);
+       xa_init(&pctldev->pin_desc_xa);
 #ifdef CONFIG_GENERIC_PINCTRL_GROUPS
        xa_init(&pctldev->pin_group_xa);
 #endif
index 35b6f12fee7517a2d7efc054c8433cf5cf497de1..019c21aea1faefd624f7c9391d0366e1746309df 100644 (file)
@@ -21,8 +21,8 @@ struct pinctrl_gpio_range;
  * @node: node to include this pin controller in the global pin controller list
  * @desc: the pin controller descriptor supplied when initializing this pin
  *     controller
- * @pin_desc_tree: each pin descriptor for this pin controller is stored in
- *     this radix tree
+ * @pin_desc_xa: each pin descriptor for this pin controller is stored in
+ *     this array
  * @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_xa: optionally each function can be stored in this array
@@ -42,7 +42,7 @@ struct pinctrl_gpio_range;
 struct pinctrl_dev {
        struct list_head node;
        struct pinctrl_desc *desc;
-       struct radix_tree_root pin_desc_tree;
+       struct xarray pin_desc_xa;
 #ifdef CONFIG_GENERIC_PINCTRL_GROUPS
        struct xarray pin_group_xa;
        unsigned int num_groups;
@@ -229,7 +229,7 @@ int pinctrl_get_group_selector(struct pinctrl_dev *pctldev,
 static inline struct pin_desc *pin_desc_get(struct pinctrl_dev *pctldev,
                                            unsigned int pin)
 {
-       return radix_tree_lookup(&pctldev->pin_desc_tree, pin);
+       return xa_load(&pctldev->pin_desc_xa, pin);
 }
 
 extern struct pinctrl_gpio_range *