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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> From: Nicolin Chen <nicolinc@xxxxxxxxxx>
> 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?

> +			vdev_id = (unsigned long)vdev->id;

break out of the loop if hit.

> +	}
> +	xa_unlock(&viommu->vdevs);
> +	return vdev_id;
> +}
> +EXPORT_SYMBOL_NS_GPL(iommufd_viommu_get_vdev_id, IOMMUFD);
> +
>  MODULE_DESCRIPTION("iommufd code shared with builtin modules");
>  MODULE_LICENSE("GPL");
> --
> 2.43.0






[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux