#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>
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)
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);
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);