Skip to content

Commit

Permalink
vfio: Rearrange functions to get vfio_group from dev
Browse files Browse the repository at this point in the history
This patch rearranges functions to get vfio_group from device

Signed-off-by: Kirti Wankhede <kwankhede@nvidia.com>
Signed-off-by: Neo Jia <cjia@nvidia.com>
Reviewed-by: Jike Song <jike.song@intel.com>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
  • Loading branch information
Kirti Wankhede authored and Alex Williamson committed Nov 17, 2016
1 parent fa3da00 commit 7ed3ea8
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions drivers/vfio/vfio.c
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,21 @@ static struct vfio_group *vfio_group_get_from_minor(int minor)
return group;
}

static struct vfio_group *vfio_group_get_from_dev(struct device *dev)
{
struct iommu_group *iommu_group;
struct vfio_group *group;

iommu_group = iommu_group_get(dev);
if (!iommu_group)
return NULL;

group = vfio_group_get_from_iommu(iommu_group);
iommu_group_put(iommu_group);

return group;
}

/**
* Device objects - create, release, get, put, search
*/
Expand Down Expand Up @@ -811,16 +826,10 @@ EXPORT_SYMBOL_GPL(vfio_add_group_dev);
*/
struct vfio_device *vfio_device_get_from_dev(struct device *dev)
{
struct iommu_group *iommu_group;
struct vfio_group *group;
struct vfio_device *device;

iommu_group = iommu_group_get(dev);
if (!iommu_group)
return NULL;

group = vfio_group_get_from_iommu(iommu_group);
iommu_group_put(iommu_group);
group = vfio_group_get_from_dev(dev);
if (!group)
return NULL;

Expand Down

0 comments on commit 7ed3ea8

Please sign in to comment.