On Wed, Mar 10, 2021 at 03:59:41PM -0400, Jason Gunthorpe wrote: > > > diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c > > > index af5696a96a76e0..4b0d60f7602e40 100644 > > > +++ b/drivers/vfio/pci/vfio_pci.c > > > @@ -534,7 +534,7 @@ static struct vfio_pci_device *get_pf_vdev(struct vfio_pci_device *vdev, > > > return NULL; > > > } > > > > > > - return vfio_device_data(*pf_dev); > > > + return container_of(*pf_dev, struct vfio_pci_device, vdev); > > > > I think it would be useful to just return the vfio_device and let > > the caller do the container_of() here, maybe as a followup. > > The callers seem to need the vfio_pci_device *? Yes. But the container_of is trivial arithmetics, no need to waste an indirect argument for that. > In a later series this function gets transformed into this: > > device_lock(&physfn->dev); > vdev = vfio_pci_get_drvdata(physfn); > if (!vdev) { > device_unlock(&physfn->dev); > return NULL; > } > vfio_device_get(&vdev->vdev); > device_unlock(&physfn->dev); > > There is no container_of here because the drvdata now points at the > struct vfio_pci_device Ok, so discard my comment then.