lkml.org 
[lkml]   [2021]   [Feb]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC PATCH 02/10] vfio: Update vfio_add_group_dev() API
On Mon, Feb 22, 2021 at 09:50:47AM -0700, Alex Williamson wrote:
> 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

\
 
 \ /
  Last update: 2021-02-22 18:03    [W:0.086 / U:6.112 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site