mirror of
git://git.yoctoproject.org/linux-yocto.git
synced 2025-10-22 23:13:01 +02:00
iommufd/viommu: Add iommufd_viommu_find_dev helper
This avoids a bigger trouble of exposing struct iommufd_device and struct iommufd_vdevice in the public header. Link: https://patch.msgid.link/r/84fa7c624db4d4508067ccfdf42059533950180a.1730836308.git.nicolinc@nvidia.com Reviewed-by: Kevin Tian <kevin.tian@intel.com> Reviewed-by: Jason Gunthorpe <jgg@nvidia.com> Signed-off-by: Nicolin Chen <nicolinc@nvidia.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
This commit is contained in:
parent
4f2e59ccb6
commit
c747e67978
|
@ -36,5 +36,18 @@ out_free:
|
|||
}
|
||||
EXPORT_SYMBOL_NS_GPL(_iommufd_object_alloc, IOMMUFD);
|
||||
|
||||
/* Caller should xa_lock(&viommu->vdevs) to protect the return value */
|
||||
struct device *iommufd_viommu_find_dev(struct iommufd_viommu *viommu,
|
||||
unsigned long vdev_id)
|
||||
{
|
||||
struct iommufd_vdevice *vdev;
|
||||
|
||||
lockdep_assert_held(&viommu->vdevs.xa_lock);
|
||||
|
||||
vdev = xa_load(&viommu->vdevs, vdev_id);
|
||||
return vdev ? vdev->dev : NULL;
|
||||
}
|
||||
EXPORT_SYMBOL_NS_GPL(iommufd_viommu_find_dev, IOMMUFD);
|
||||
|
||||
MODULE_DESCRIPTION("iommufd code shared with builtin modules");
|
||||
MODULE_LICENSE("GPL");
|
||||
|
|
|
@ -185,6 +185,8 @@ static inline int iommufd_vfio_compat_set_no_iommu(struct iommufd_ctx *ictx)
|
|||
struct iommufd_object *_iommufd_object_alloc(struct iommufd_ctx *ictx,
|
||||
size_t size,
|
||||
enum iommufd_object_type type);
|
||||
struct device *iommufd_viommu_find_dev(struct iommufd_viommu *viommu,
|
||||
unsigned long vdev_id);
|
||||
#else /* !CONFIG_IOMMUFD_DRIVER_CORE */
|
||||
static inline struct iommufd_object *
|
||||
_iommufd_object_alloc(struct iommufd_ctx *ictx, size_t size,
|
||||
|
@ -192,6 +194,12 @@ _iommufd_object_alloc(struct iommufd_ctx *ictx, size_t size,
|
|||
{
|
||||
return ERR_PTR(-EOPNOTSUPP);
|
||||
}
|
||||
|
||||
static inline struct device *
|
||||
iommufd_viommu_find_dev(struct iommufd_viommu *viommu, unsigned long vdev_id)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
#endif /* CONFIG_IOMMUFD_DRIVER_CORE */
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in New Issue
Block a user