diff options
author | Petr Mladek <pmladek@suse.com> | 2021-11-02 10:39:27 +0100 |
---|---|---|
committer | Petr Mladek <pmladek@suse.com> | 2021-11-02 10:39:27 +0100 |
commit | 40e64a88dadcfa168914065baf7f035de957bbe0 (patch) | |
tree | 06c8c4a9e6c1b478aa6851794c6a33bec1ce6ec4 /drivers/vfio/mdev/vfio_mdev.c | |
parent | lib/vsprintf.c: Amend static asserts for format specifier flags (diff) | |
parent | vsprintf: Update %pGp documentation about that it prints hex value (diff) | |
download | linux-40e64a88dadcfa168914065baf7f035de957bbe0.tar.xz linux-40e64a88dadcfa168914065baf7f035de957bbe0.zip |
Merge branch 'for-5.16-vsprintf-pgp' into for-linus
Diffstat (limited to 'drivers/vfio/mdev/vfio_mdev.c')
-rw-r--r-- | drivers/vfio/mdev/vfio_mdev.c | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/drivers/vfio/mdev/vfio_mdev.c b/drivers/vfio/mdev/vfio_mdev.c index 39ef7489fe47..7a9883048216 100644 --- a/drivers/vfio/mdev/vfio_mdev.c +++ b/drivers/vfio/mdev/vfio_mdev.c @@ -17,24 +17,24 @@ #include "mdev_private.h" -static int vfio_mdev_open(struct vfio_device *core_vdev) +static int vfio_mdev_open_device(struct vfio_device *core_vdev) { struct mdev_device *mdev = to_mdev_device(core_vdev->dev); struct mdev_parent *parent = mdev->type->parent; - if (unlikely(!parent->ops->open)) - return -EINVAL; + if (unlikely(!parent->ops->open_device)) + return 0; - return parent->ops->open(mdev); + return parent->ops->open_device(mdev); } -static void vfio_mdev_release(struct vfio_device *core_vdev) +static void vfio_mdev_close_device(struct vfio_device *core_vdev) { struct mdev_device *mdev = to_mdev_device(core_vdev->dev); struct mdev_parent *parent = mdev->type->parent; - if (likely(parent->ops->release)) - parent->ops->release(mdev); + if (likely(parent->ops->close_device)) + parent->ops->close_device(mdev); } static long vfio_mdev_unlocked_ioctl(struct vfio_device *core_vdev, @@ -44,7 +44,7 @@ static long vfio_mdev_unlocked_ioctl(struct vfio_device *core_vdev, struct mdev_parent *parent = mdev->type->parent; if (unlikely(!parent->ops->ioctl)) - return -EINVAL; + return 0; return parent->ops->ioctl(mdev, cmd, arg); } @@ -100,8 +100,8 @@ static void vfio_mdev_request(struct vfio_device *core_vdev, unsigned int count) static const struct vfio_device_ops vfio_mdev_dev_ops = { .name = "vfio-mdev", - .open = vfio_mdev_open, - .release = vfio_mdev_release, + .open_device = vfio_mdev_open_device, + .close_device = vfio_mdev_close_device, .ioctl = vfio_mdev_unlocked_ioctl, .read = vfio_mdev_read, .write = vfio_mdev_write, @@ -120,12 +120,16 @@ static int vfio_mdev_probe(struct mdev_device *mdev) vfio_init_group_dev(vdev, &mdev->dev, &vfio_mdev_dev_ops); ret = vfio_register_group_dev(vdev); - if (ret) { - kfree(vdev); - return ret; - } + if (ret) + goto out_uninit; + dev_set_drvdata(&mdev->dev, vdev); return 0; + +out_uninit: + vfio_uninit_group_dev(vdev); + kfree(vdev); + return ret; } static void vfio_mdev_remove(struct mdev_device *mdev) @@ -133,6 +137,7 @@ static void vfio_mdev_remove(struct mdev_device *mdev) struct vfio_device *vdev = dev_get_drvdata(&mdev->dev); vfio_unregister_group_dev(vdev); + vfio_uninit_group_dev(vdev); kfree(vdev); } |