On 2022/12/21 12:10, Tian, Kevin wrote:
From: Liu, Yi L <yi.l.liu@xxxxxxxxx>
Sent: Monday, December 19, 2022 4:47 PM
This avoids passing struct kvm * and struct iommufd_ctx * in multiple
functions. vfio_device_open() becomes to be a locked helper, while
vfio_device_open() still holds device->dev_set->lock itself.
Not sure what the words after 'while' intend to explain.
yeah, may remove it.
-int vfio_device_open(struct vfio_device *device,
- struct iommufd_ctx *iommufd, struct kvm *kvm)
+int vfio_device_open(struct vfio_device_file *df)
{
- int ret = 0;
+ struct vfio_device *device = df->device;
+
+ lockdep_assert_held(&device->dev_set->lock);
- mutex_lock(&device->dev_set->lock);
device->open_count++;
if (device->open_count == 1) {
- ret = vfio_device_first_open(device, iommufd, kvm);
- if (ret)
+ int ret;
+
+ ret = vfio_device_first_open(df);
+ if (ret) {
device->open_count--;
+ return ret;
+ }
}
- mutex_unlock(&device->dev_set->lock);
- return ret;
+ return 0;
}
I don't see the point of moving 'ret' into the inner block.
just want to make the function success oriented. :-)
--
Regards,
Yi Liu