#include <linux/pci-epf.h>
#include <linux/pci-ep-cfs.h>
-static DEFINE_IDR(functions_idr);
-static DEFINE_MUTEX(functions_mutex);
+static DEFINE_IDA(function_ids);
static struct config_group *functions_group;
static struct config_group *controllers_group;
{
struct pci_epf_group *epf_group = to_pci_epf_group(item);
- mutex_lock(&functions_mutex);
- idr_remove(&functions_idr, epf_group->index);
- mutex_unlock(&functions_mutex);
+ ida_free(&function_ids, epf_group->index);
pci_epf_destroy(epf_group->epf);
kfree(epf_group);
}
if (!epf_group)
return ERR_PTR(-ENOMEM);
- mutex_lock(&functions_mutex);
- index = idr_alloc(&functions_idr, epf_group, 0, 0, GFP_KERNEL);
- mutex_unlock(&functions_mutex);
+ index = ida_alloc(&function_ids, GFP_KERNEL);
if (index < 0) {
err = index;
goto free_group;
kfree(epf_name);
remove_idr:
- mutex_lock(&functions_mutex);
- idr_remove(&functions_idr, epf_group->index);
- mutex_unlock(&functions_mutex);
+ ida_free(&function_ids, epf_group->index);
free_group:
kfree(epf_group);