Commit b3b43590 authored by Jason Gunthorpe's avatar Jason Gunthorpe Committed by Alex Williamson
Browse files

vfio: Follow the naming pattern for vfio_group_ioctl_unset_container()



Make it clear that this is the body of the ioctl. Fold the locking into
the function so it is self contained like the other ioctls.

Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
Reviewed-by: default avatarKevin Tian <kevin.tian@intel.com>
Link: https://lore.kernel.org/r/7-v2-0f9e632d54fb+d6-vfio_ioctl_split_jgg@nvidia.com


Signed-off-by: default avatarAlex Williamson <alex.williamson@redhat.com>
parent 67671f15
Loading
Loading
Loading
Loading
+16 −11
Original line number Original line Diff line number Diff line
@@ -968,16 +968,24 @@ static void __vfio_group_unset_container(struct vfio_group *group)
 * the group, we know that still exists, therefore the only valid
 * the group, we know that still exists, therefore the only valid
 * transition here is 1->0.
 * transition here is 1->0.
 */
 */
static int vfio_group_unset_container(struct vfio_group *group)
static int vfio_group_ioctl_unset_container(struct vfio_group *group)
{
{
	lockdep_assert_held_write(&group->group_rwsem);
	int ret = 0;


	if (!group->container)
	down_write(&group->group_rwsem);
		return -EINVAL;
	if (!group->container) {
	if (group->container_users != 1)
		ret = -EINVAL;
		return -EBUSY;
		goto out_unlock;
	}
	if (group->container_users != 1) {
		ret = -EBUSY;
		goto out_unlock;
	}
	__vfio_group_unset_container(group);
	__vfio_group_unset_container(group);
	return 0;

out_unlock:
	up_write(&group->group_rwsem);
	return ret;
}
}


static int vfio_group_ioctl_set_container(struct vfio_group *group,
static int vfio_group_ioctl_set_container(struct vfio_group *group,
@@ -1270,10 +1278,7 @@ static long vfio_group_fops_unl_ioctl(struct file *filep,
	case VFIO_GROUP_SET_CONTAINER:
	case VFIO_GROUP_SET_CONTAINER:
		return vfio_group_ioctl_set_container(group, uarg);
		return vfio_group_ioctl_set_container(group, uarg);
	case VFIO_GROUP_UNSET_CONTAINER:
	case VFIO_GROUP_UNSET_CONTAINER:
		down_write(&group->group_rwsem);
		return vfio_group_ioctl_unset_container(group);
		ret = vfio_group_unset_container(group);
		up_write(&group->group_rwsem);
		break;
	}
	}


	return ret;
	return ret;