]> www.infradead.org Git - users/willy/xarray.git/commitdiff
fpga: Convert dfl idrs to IDA
authorMatthew Wilcox <willy@infradead.org>
Sat, 16 Feb 2019 02:28:08 +0000 (21:28 -0500)
committerMatthew Wilcox (Oracle) <willy@infradead.org>
Fri, 9 Aug 2019 01:38:17 +0000 (21:38 -0400)
Signed-off-by: Matthew Wilcox <willy@infradead.org>
drivers/fpga/dfl.c

index 4b66aaa32b5ab2f1f91d94caf93cd335e2725906..010f217563304b1d69f4355a8bdc2fed6283e89c 100644 (file)
@@ -14,8 +14,6 @@
 
 #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
@@ -51,13 +49,13 @@ static const char *dfl_pdata_key_strings[DFL_ID_MAX] = {
  * 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;
 };
 
@@ -90,7 +88,7 @@ static void dfl_ids_init(void)
        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)
@@ -98,27 +96,19 @@ 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)
@@ -558,7 +548,7 @@ build_info_create_dev(struct build_feature_devs_info *binfo,
        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;