diff options
author | Max Gurtovoy <mgurtovoy@nvidia.com> | 2021-05-18 21:21:32 +0200 |
---|---|---|
committer | Alex Williamson <alex.williamson@redhat.com> | 2021-06-15 22:12:15 +0200 |
commit | 9dcf01d95721261844d8c07c142efc143f7d38e3 (patch) | |
tree | 779e6b75b40ed6b96acf52fff59111ee09c37119 /drivers/vfio/mdev | |
parent | Linux 5.13-rc6 (diff) | |
download | linux-9dcf01d95721261844d8c07c142efc143f7d38e3.tar.xz linux-9dcf01d95721261844d8c07c142efc143f7d38e3.zip |
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')
-rw-r--r-- | drivers/vfio/mdev/vfio_mdev.c | 13 |
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, |