]> www.infradead.org Git - users/willy/xarray.git/commitdiff
pwm: Convert to XArray
authorMatthew Wilcox <willy@infradead.org>
Thu, 25 Oct 2018 16:22:46 +0000 (12:22 -0400)
committerMatthew Wilcox (Oracle) <willy@infradead.org>
Fri, 9 Aug 2019 01:38:11 +0000 (21:38 -0400)
Straightforward conversion.

Signed-off-by: Matthew Wilcox <willy@infradead.org>
drivers/pwm/core.c

index c3ab07ab31a96df3072b94240fc241558a0da925..810a64a9053d25fc00a1a09b139e0f6244d8a18f 100644 (file)
@@ -9,7 +9,7 @@
 #include <linux/acpi.h>
 #include <linux/module.h>
 #include <linux/pwm.h>
-#include <linux/radix-tree.h>
+#include <linux/xarray.h>
 #include <linux/list.h>
 #include <linux/mutex.h>
 #include <linux/err.h>
@@ -27,11 +27,11 @@ static LIST_HEAD(pwm_lookup_list);
 static DEFINE_MUTEX(pwm_lock);
 static LIST_HEAD(pwm_chips);
 static DECLARE_BITMAP(allocated_pwms, MAX_PWMS);
-static RADIX_TREE(pwm_tree, GFP_KERNEL);
+static DEFINE_XARRAY(pwm_devs);
 
 static struct pwm_device *pwm_to_device(unsigned int pwm)
 {
-       return radix_tree_lookup(&pwm_tree, pwm);
+       return xa_load(&pwm_devs, pwm);
 }
 
 static int alloc_pwms(int pwm, unsigned int count)
@@ -64,7 +64,7 @@ static void free_pwms(struct pwm_chip *chip)
        for (i = 0; i < chip->npwm; i++) {
                struct pwm_device *pwm = &chip->pwms[i];
 
-               radix_tree_delete(&pwm_tree, pwm->pwm);
+               xa_erase(&pwm_devs, pwm->pwm);
        }
 
        bitmap_clear(allocated_pwms, chip->base, chip->npwm);
@@ -286,7 +286,7 @@ int pwmchip_add_with_polarity(struct pwm_chip *chip,
                if (chip->ops->get_state)
                        chip->ops->get_state(chip, pwm, &pwm->state);
 
-               radix_tree_insert(&pwm_tree, pwm->pwm, pwm);
+               xa_store(&pwm_devs, pwm->pwm, pwm, GFP_KERNEL);
        }
 
        bitmap_set(allocated_pwms, chip->base, chip->npwm);