diff options
author | Zhen Lei <thunder.leizhen@huawei.com> | 2015-03-16 21:08:56 +0100 |
---|---|---|
committer | Alex Williamson <alex.williamson@redhat.com> | 2015-03-16 21:08:56 +0100 |
commit | 2f51bf4be99386f49841b6365a85a5cabc148565 (patch) | |
tree | 2c3c9d7c36d2a3b14b577b4f0a09b0df34d11a6b /drivers/vfio/vfio.c | |
parent | vfio/platform: implement IRQ masking/unmasking via an eventfd (diff) | |
download | linux-2f51bf4be99386f49841b6365a85a5cabc148565.tar.xz linux-2f51bf4be99386f49841b6365a85a5cabc148565.zip |
vfio: put off the allocation of "minor" in vfio_create_group
The next code fragment "list_for_each_entry" is not depend on "minor". With this
patch, the free of "minor" in "list_for_each_entry" can be reduced, and there is
no functional change.
Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Diffstat (limited to '')
-rw-r--r-- | drivers/vfio/vfio.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c index 23ba12afe01f..86aac7e4a050 100644 --- a/drivers/vfio/vfio.c +++ b/drivers/vfio/vfio.c @@ -234,22 +234,21 @@ static struct vfio_group *vfio_create_group(struct iommu_group *iommu_group) mutex_lock(&vfio.group_lock); - minor = vfio_alloc_group_minor(group); - if (minor < 0) { - vfio_group_unlock_and_free(group); - return ERR_PTR(minor); - } - /* Did we race creating this group? */ list_for_each_entry(tmp, &vfio.group_list, vfio_next) { if (tmp->iommu_group == iommu_group) { vfio_group_get(tmp); - vfio_free_group_minor(minor); vfio_group_unlock_and_free(group); return tmp; } } + minor = vfio_alloc_group_minor(group); + if (minor < 0) { + vfio_group_unlock_and_free(group); + return ERR_PTR(minor); + } + dev = device_create(vfio.class, NULL, MKDEV(MAJOR(vfio.group_devt), minor), group, "%d", iommu_group_id(iommu_group)); |