From: Al Viro Date: Sat, 18 Aug 2012 01:27:32 +0000 (-0400) Subject: vfio: get rid of open-coding kref_put_mutex X-Git-Tag: upstream/snapshot3+hdmi~6789^2~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6d2cd3ce815b302e885b44ca1bdbe3c7db321c7a;p=platform%2Fadaptation%2Frenesas_rcar%2Frenesas_kernel.git vfio: get rid of open-coding kref_put_mutex Acked-by: Alex Williamson Signed-off-by: Al Viro --- diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c index 0b025d5..92b8567 100644 --- a/drivers/vfio/vfio.c +++ b/drivers/vfio/vfio.c @@ -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 */