From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jike Song Subject: [v3 2/5] vfio: export functions to get vfio_group from device and put it Date: Mon, 31 Oct 2016 14:35:03 +0800 Message-ID: <1477895706-22824-3-git-send-email-jike.song@intel.com> References: <1477895706-22824-1-git-send-email-jike.song@intel.com> Cc: kwankhede@nvidia.com, cjia@nvidia.com, kevin.tian@intel.com, jike.song@intel.com, kvm@vger.kernel.org To: pbonzini@redhat.com, alex.williamson@redhat.com, guangrong.xiao@linux.intel.com Return-path: Received: from mga09.intel.com ([134.134.136.24]:46459 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1761103AbcJaGk2 (ORCPT ); Mon, 31 Oct 2016 02:40:28 -0400 In-Reply-To: <1477895706-22824-1-git-send-email-jike.song@intel.com> Sender: kvm-owner@vger.kernel.org List-ID: External users might want to get the vfio_group from a given device, and put it after the usage. Signed-off-by: Jike Song --- drivers/vfio/vfio.c | 6 ++++-- include/linux/vfio.h | 3 +++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c index 23bc86c..e3e58e3 100644 --- a/drivers/vfio/vfio.c +++ b/drivers/vfio/vfio.c @@ -414,10 +414,11 @@ static void vfio_group_release(struct kref *kref) iommu_group_put(iommu_group); } -static void vfio_group_put(struct vfio_group *group) +void vfio_group_put(struct vfio_group *group) { kref_put_mutex(&group->kref, vfio_group_release, &vfio.group_lock); } +EXPORT_SYMBOL_GPL(vfio_group_put); /* Assume group_lock or group reference is held */ static void vfio_group_get(struct vfio_group *group) @@ -480,7 +481,7 @@ 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 vfio_group *vfio_group_get_from_dev(struct device *dev) { struct iommu_group *iommu_group; struct vfio_group *group; @@ -494,6 +495,7 @@ static struct vfio_group *vfio_group_get_from_dev(struct device *dev) return group; } +EXPORT_SYMBOL_GPL(vfio_group_get_from_dev); /** * Device objects - create, release, get, put, search diff --git a/include/linux/vfio.h b/include/linux/vfio.h index 0ecae0b..ad9b857 100644 --- a/include/linux/vfio.h +++ b/include/linux/vfio.h @@ -92,6 +92,9 @@ extern void vfio_unregister_iommu_driver( extern long vfio_external_check_extension(struct vfio_group *group, unsigned long arg); +extern struct vfio_group *vfio_group_get_from_dev(struct device *dev); +extern void vfio_group_put(struct vfio_group *group); + /* * Sub-module helpers */ -- 1.9.1