Thread (32 messages) 32 messages, 2 authors, 2024-12-12

Re: [PATCH v2 06/13] iommufd/viommu: Add iommufd_viommu_get_vdev_id helper

From: Nicolin Chen <hidden>
Date: 2024-12-12 21:21:37
Also in: linux-doc, linux-iommu, linux-kselftest, lkml

On Wed, Dec 11, 2024 at 08:02:48AM +0000, Tian, Kevin wrote:
quoted
From: Nicolin Chen <redacted>
Sent: Wednesday, December 4, 2024 6:10 AM

+/* Return 0 if device is not associated to the vIOMMU */
+unsigned long iommufd_viommu_get_vdev_id(struct iommufd_viommu
*viommu,
+					 struct device *dev)
+{
+	struct iommufd_vdevice *vdev;
+	unsigned long vdev_id = 0;
+	unsigned long index;
+
+	xa_lock(&viommu->vdevs);
+	xa_for_each(&viommu->vdevs, index, vdev) {
+		if (vdev && vdev->dev == dev)
xa_for_each only find valid entries, so if (vdev) is redundant?
quoted
+			vdev_id = (unsigned long)vdev->id;
break out of the loop if hit.
Yea, missed that.

Thanks!
Nic
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help