Re: [RFC PATCH 02/10] vfio: Update vfio_add_group_dev() API
From: Jason Gunthorpe <jgg@nvidia.com>
Date: 2021-02-22 17:02:55
Also in:
lkml
On Mon, Feb 22, 2021 at 09:50:47AM -0700, Alex Williamson wrote:
quoted hunk ↗ jump to hunk
diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c index 464caef97aff..067cd843961c 100644 +++ b/drivers/vfio/vfio.c@@ -848,8 +848,9 @@ static int vfio_iommu_group_notifier(struct notifier_block *nb, /** * VFIO driver API */ -int vfio_add_group_dev(struct device *dev, - const struct vfio_device_ops *ops, void *device_data) +struct vfio_device *vfio_add_group_dev(struct device *dev, + const struct vfio_device_ops *ops, + void *device_data) { struct iommu_group *iommu_group; struct vfio_group *group;@@ -857,14 +858,14 @@ int vfio_add_group_dev(struct device *dev, iommu_group = iommu_group_get(dev); if (!iommu_group) - return -EINVAL; + return ERR_PTR(-EINVAL); group = vfio_group_get_from_iommu(iommu_group); if (!group) { group = vfio_create_group(iommu_group); if (IS_ERR(group)) { iommu_group_put(iommu_group); - return PTR_ERR(group); + return (struct vfio_device *)group;
Use ERR_CAST() here Also, I've wrote a small series last week that goes further than this, I made 'struct vfio_device *' the universal handle to refer to the device, instead of using 'void *' or 'struct device *' as a surrogate. It is interesting that you hit on the same issue as a blocker to this series. So for I've found quite a few other things that are out of sorts because of this. Cheers, Jason