vfio: Rearrange functions to get vfio_group from dev
authorKirti Wankhede <kwankhede@nvidia.com>
Wed, 16 Nov 2016 20:46:15 +0000 (02:16 +0530)
committerAlex Williamson <alex.williamson@redhat.com>
Thu, 17 Nov 2016 15:24:52 +0000 (08:24 -0700)
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>
drivers/vfio/vfio.c

index d1d70e0b011bf41a8d49255a2a4359be342041c7..23bc86c1d05dda3185ee78b80213ad5eb418110b 100644 (file)
@@ -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
  */
@@ -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;