From: Matthew Wilcox Date: Sat, 16 Feb 2019 02:28:08 +0000 (-0500) Subject: fpga: Convert dfl idrs to IDA X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=933838c6259f6820bba9683283761fe4c5bbdd96;p=users%2Fwilly%2Fxarray.git fpga: Convert dfl idrs to IDA Signed-off-by: Matthew Wilcox --- diff --git a/drivers/fpga/dfl.c b/drivers/fpga/dfl.c index 4b66aaa32b5a..010f21756330 100644 --- a/drivers/fpga/dfl.c +++ b/drivers/fpga/dfl.c @@ -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;