]> git.baikalelectronics.ru Git - kernel.git/commit
vfio/mdev: Reorganize mdev_device_create()
authorJason Gunthorpe <jgg@nvidia.com>
Tue, 6 Apr 2021 19:40:31 +0000 (16:40 -0300)
committerAlex Williamson <alex.williamson@redhat.com>
Wed, 7 Apr 2021 21:39:18 +0000 (15:39 -0600)
commit1c5e5b5dd89644744f56efde866bbf746bbbbd50
tree37a1f34b243aca39f835e07edaa26c2cca1b26e9
parent4288e43b11954c93b7329e614c467aa5ced06702
vfio/mdev: Reorganize mdev_device_create()

Once the memory for the struct mdev_device is allocated it should
immediately be device_initialize()'d and filled in so that put_device()
can always be used to undo the allocation.

Place the mdev_get/put_parent() so that they are clearly protecting the
mdev->parent pointer. Move the final put to the release function so that
the lifetime rules are trivial to understand. Update the goto labels to
follow the normal convention.

Remove mdev_device_free() as the release function via device_put() is now
usable in all cases.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Message-Id: <8-v2-d36939638fc6+d54-vfio2_jgg@nvidia.com>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
drivers/vfio/mdev/mdev_core.c