diff options
| author | Zhen Lei <thunder.leizhen@huawei.com> | 2015-03-16 16:08:56 -0400 |
|---|---|---|
| committer | Alex Williamson <alex.williamson@redhat.com> | 2015-03-16 16:08:56 -0400 |
| commit | 2f51bf4be99386f49841b6365a85a5cabc148565 (patch) | |
| tree | 2c3c9d7c36d2a3b14b577b4f0a09b0df34d11a6b /drivers/vfio | |
| parent | a7fa7c77cf15fb22d0f33fcc88770de0246c5588 (diff) | |
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 'drivers/vfio')
| -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) | |||
| 234 | 234 | ||
| 235 | mutex_lock(&vfio.group_lock); | 235 | mutex_lock(&vfio.group_lock); |
| 236 | 236 | ||
| 237 | minor = vfio_alloc_group_minor(group); | ||
| 238 | if (minor < 0) { | ||
| 239 | vfio_group_unlock_and_free(group); | ||
| 240 | return ERR_PTR(minor); | ||
| 241 | } | ||
| 242 | |||
| 243 | /* Did we race creating this group? */ | 237 | /* Did we race creating this group? */ |
| 244 | list_for_each_entry(tmp, &vfio.group_list, vfio_next) { | 238 | list_for_each_entry(tmp, &vfio.group_list, vfio_next) { |
| 245 | if (tmp->iommu_group == iommu_group) { | 239 | if (tmp->iommu_group == iommu_group) { |
| 246 | vfio_group_get(tmp); | 240 | vfio_group_get(tmp); |
| 247 | vfio_free_group_minor(minor); | ||
| 248 | vfio_group_unlock_and_free(group); | 241 | vfio_group_unlock_and_free(group); |
| 249 | return tmp; | 242 | return tmp; |
| 250 | } | 243 | } |
| 251 | } | 244 | } |
| 252 | 245 | ||
| 246 | minor = vfio_alloc_group_minor(group); | ||
| 247 | if (minor < 0) { | ||
| 248 | vfio_group_unlock_and_free(group); | ||
| 249 | return ERR_PTR(minor); | ||
| 250 | } | ||
| 251 | |||
| 253 | dev = device_create(vfio.class, NULL, | 252 | dev = device_create(vfio.class, NULL, |
| 254 | MKDEV(MAJOR(vfio.group_devt), minor), | 253 | MKDEV(MAJOR(vfio.group_devt), minor), |
| 255 | group, "%d", iommu_group_id(iommu_group)); | 254 | group, "%d", iommu_group_id(iommu_group)); |
