vfio: get rid of open-coding kref_put_mutex
authorAl Viro <viro@zeniv.linux.org.uk>
Sat, 18 Aug 2012 01:27:32 +0000 (21:27 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Wed, 22 Aug 2012 14:25:19 +0000 (10:25 -0400)
Acked-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
drivers/vfio/vfio.c

index 0b025d58de813ebe94c74a6518b66f045fb415e8..92b85676e6bed3ca908866c74b62fab197876757 100644 (file)
@@ -264,6 +264,7 @@ static struct vfio_group *vfio_create_group(struct iommu_group *iommu_group)
        return group;
 }
 
+/* called with vfio.group_lock held */
 static void vfio_group_release(struct kref *kref)
 {
        struct vfio_group *group = container_of(kref, struct vfio_group, kref);
@@ -287,13 +288,7 @@ static void vfio_group_release(struct kref *kref)
 
 static void vfio_group_put(struct vfio_group *group)
 {
-       mutex_lock(&vfio.group_lock);
-       /*
-        * Release needs to unlock to unregister the notifier, so only
-        * unlock if not released.
-        */
-       if (!kref_put(&group->kref, vfio_group_release))
-               mutex_unlock(&vfio.group_lock);
+       kref_put_mutex(&group->kref, vfio_group_release, &vfio.group_lock);
 }
 
 /* Assume group_lock or group reference is held */