Messages in this thread | | | Date | Thu, 23 Jun 2022 22:52:47 -0300 | From | Jason Gunthorpe <> | Subject | Re: [PATCH v2 1/2] vfio/type1: Simplify bus_type determination |
| |
On Wed, Jun 22, 2022 at 01:04:11PM +0100, Robin Murphy wrote:
> +struct vfio_device *vfio_device_get_from_iommu(struct iommu_group *iommu_group) > +{ > + struct vfio_group *group = vfio_group_get_from_iommu(iommu_group); > + struct vfio_device *device; > + > + mutex_lock(&group->device_lock); > + list_for_each_entry(device, &group->device_list, group_next) { > + if (vfio_device_try_get(device)) { > + mutex_unlock(&group->device_lock); > + return device; > + } > + } > + mutex_unlock(&group->device_lock); > + return NULL; > +}
FWIW, I have no objection to this general approach, and I don't think we should make any broader API just for this.
Though I might call it something like 'vfio_get_group_representor_device()' which more strongly suggests what it is only used for.
Thanks, Jason
| |