summaryrefslogtreecommitdiff
path: root/drivers/vfio/mdev/mdev_private.h
diff options
context:
space:
mode:
authorJason Gunthorpe <jgg@nvidia.com>2021-04-06 16:40:29 -0300
committerAlex Williamson <alex.williamson@redhat.com>2021-04-07 15:39:17 -0600
commita9f8111d0b5f445d853345e6917c1781573e4ba9 (patch)
treebe45a0d1ab2ba79c501eb3fe2d8cff05a12d09e2 /drivers/vfio/mdev/mdev_private.h
parent417fd5bf242d7691c15fe0bd705ab76c69276572 (diff)
downloadlinux-a9f8111d0b5f445d853345e6917c1781573e4ba9.tar.gz
linux-a9f8111d0b5f445d853345e6917c1781573e4ba9.tar.bz2
linux-a9f8111d0b5f445d853345e6917c1781573e4ba9.zip
vfio/mdev: Expose mdev_get/put_parent to mdev_private.h
The next patch will use these in mdev_sysfs.c While here remove the now dead code checks for NULL, a mdev_type can never have a NULL parent. 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: <6-v2-d36939638fc6+d54-vfio2_jgg@nvidia.com> Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Diffstat (limited to 'drivers/vfio/mdev/mdev_private.h')
-rw-r--r--drivers/vfio/mdev/mdev_private.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/drivers/vfio/mdev/mdev_private.h b/drivers/vfio/mdev/mdev_private.h
index f12e34e16ab9..fddab240ccc3 100644
--- a/drivers/vfio/mdev/mdev_private.h
+++ b/drivers/vfio/mdev/mdev_private.h
@@ -46,4 +46,16 @@ void mdev_remove_sysfs_files(struct mdev_device *mdev);
int mdev_device_create(struct mdev_type *kobj, const guid_t *uuid);
int mdev_device_remove(struct mdev_device *dev);
+void mdev_release_parent(struct kref *kref);
+
+static inline void mdev_get_parent(struct mdev_parent *parent)
+{
+ kref_get(&parent->ref);
+}
+
+static inline void mdev_put_parent(struct mdev_parent *parent)
+{
+ kref_put(&parent->ref, mdev_release_parent);
+}
+
#endif /* MDEV_PRIVATE_H */