summaryrefslogtreecommitdiffstats
path: root/drivers/vfio/mdev/vfio_mdev.c
diff options
context:
space:
mode:
authorMax Gurtovoy <mgurtovoy@nvidia.com>2021-05-18 22:21:32 +0300
committerAlex Williamson <alex.williamson@redhat.com>2021-06-15 14:12:15 -0600
commit9dcf01d95721261844d8c07c142efc143f7d38e3 (patch)
tree779e6b75b40ed6b96acf52fff59111ee09c37119 /drivers/vfio/mdev/vfio_mdev.c
parent009c9aa5be652675a06d5211e1640e02bbb1c33d (diff)
downloadlinux-9dcf01d95721261844d8c07c142efc143f7d38e3.tar.bz2
vfio: centralize module refcount in subsystem layer
Remove code duplication and move module refcounting to the subsystem module. Signed-off-by: Max Gurtovoy <mgurtovoy@nvidia.com> Reviewed-by: Eric Auger <eric.auger@redhat.com> Link: https://lore.kernel.org/r/20210518192133.59195-2-mgurtovoy@nvidia.com Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Diffstat (limited to 'drivers/vfio/mdev/vfio_mdev.c')
-rw-r--r--drivers/vfio/mdev/vfio_mdev.c13
1 files changed, 1 insertions, 12 deletions
diff --git a/drivers/vfio/mdev/vfio_mdev.c b/drivers/vfio/mdev/vfio_mdev.c
index 922729071c5a..5ef4815609ed 100644
--- a/drivers/vfio/mdev/vfio_mdev.c
+++ b/drivers/vfio/mdev/vfio_mdev.c
@@ -26,19 +26,10 @@ static int vfio_mdev_open(struct vfio_device *core_vdev)
struct mdev_device *mdev = to_mdev_device(core_vdev->dev);
struct mdev_parent *parent = mdev->type->parent;
- int ret;
-
if (unlikely(!parent->ops->open))
return -EINVAL;
- if (!try_module_get(THIS_MODULE))
- return -ENODEV;
-
- ret = parent->ops->open(mdev);
- if (ret)
- module_put(THIS_MODULE);
-
- return ret;
+ return parent->ops->open(mdev);
}
static void vfio_mdev_release(struct vfio_device *core_vdev)
@@ -48,8 +39,6 @@ static void vfio_mdev_release(struct vfio_device *core_vdev)
if (likely(parent->ops->release))
parent->ops->release(mdev);
-
- module_put(THIS_MODULE);
}
static long vfio_mdev_unlocked_ioctl(struct vfio_device *core_vdev,