#include "dfl.h"
-static DEFINE_MUTEX(dfl_id_mutex);
-
/*
* when adding a new feature dev support in DFL framework, it's required to
* add a new item in enum dfl_id_type and provide related information in below
* dfl_dev_info - dfl feature device information.
* @name: name string of the feature platform device.
* @dfh_id: id value in Device Feature Header (DFH) register by DFL spec.
- * @id: idr id of the feature dev.
+ * @ids: id of the feature dev.
* @devt_type: index to dfl_chrdevs[].
*/
struct dfl_dev_info {
const char *name;
u32 dfh_id;
- struct idr id;
+ struct ida ids;
enum dfl_fpga_devt_type devt_type;
};
int i;
for (i = 0; i < ARRAY_SIZE(dfl_devs); i++)
- idr_init(&dfl_devs[i].id);
+ ida_init(&dfl_devs[i].ids);
}
static void dfl_ids_destroy(void)
int i;
for (i = 0; i < ARRAY_SIZE(dfl_devs); i++)
- idr_destroy(&dfl_devs[i].id);
+ ida_destroy(&dfl_devs[i].ids);
}
-static int dfl_id_alloc(enum dfl_id_type type, struct device *dev)
+static int dfl_id_alloc(enum dfl_id_type type)
{
- int id;
-
WARN_ON(type >= DFL_ID_MAX);
- mutex_lock(&dfl_id_mutex);
- id = idr_alloc(&dfl_devs[type].id, dev, 0, 0, GFP_KERNEL);
- mutex_unlock(&dfl_id_mutex);
-
- return id;
+ return ida_alloc(&dfl_devs[type].ids, GFP_KERNEL);
}
static void dfl_id_free(enum dfl_id_type type, int id)
{
WARN_ON(type >= DFL_ID_MAX);
- mutex_lock(&dfl_id_mutex);
- idr_remove(&dfl_devs[type].id, id);
- mutex_unlock(&dfl_id_mutex);
+ ida_free(&dfl_devs[type].ids, id);
}
static enum dfl_id_type feature_dev_id_type(struct platform_device *pdev)
binfo->ioaddr = ioaddr;
INIT_LIST_HEAD(&binfo->sub_features);
- fdev->id = dfl_id_alloc(type, &fdev->dev);
+ fdev->id = dfl_id_alloc(type);
if (fdev->id < 0)
return fdev->id;