]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
vfio/platform: Convert to get_region_info_caps
authorJason Gunthorpe <jgg@nvidia.com>
Fri, 7 Nov 2025 17:41:36 +0000 (13:41 -0400)
committerAlex Williamson <alex@shazbot.org>
Wed, 12 Nov 2025 22:06:41 +0000 (15:06 -0700)
Remove the duplicate code and change info to a pointer. caps are not used.

Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Reviewed-by: Mostafa Saleh <smostafa@google.com>
Reviewed-by: Pranjal Shrivastava <praan@google.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Link: https://lore.kernel.org/r/20-v2-2a9e24d62f1b+e10a-vfio_get_region_info_op_jgg@nvidia.com
Signed-off-by: Alex Williamson <alex@shazbot.org>
drivers/vfio/platform/vfio_amba.c
drivers/vfio/platform/vfio_platform.c
drivers/vfio/platform/vfio_platform_common.c
drivers/vfio/platform/vfio_platform_private.h

index d600deaf23b6d71bc4327a1a3e871aea833e911d..fa754f203b2dfcdc67b528fc68d47d3c2e70b5a2 100644 (file)
@@ -115,7 +115,7 @@ static const struct vfio_device_ops vfio_amba_ops = {
        .open_device    = vfio_platform_open_device,
        .close_device   = vfio_platform_close_device,
        .ioctl          = vfio_platform_ioctl,
-       .get_region_info = vfio_platform_ioctl_get_region_info,
+       .get_region_info_caps = vfio_platform_ioctl_get_region_info,
        .read           = vfio_platform_read,
        .write          = vfio_platform_write,
        .mmap           = vfio_platform_mmap,
index 0e85c914b6510514de6e93c7e653ce701e1a0359..a4d3ace3e02dda8b9e05ccc78d859c67a30912fa 100644 (file)
@@ -101,7 +101,7 @@ static const struct vfio_device_ops vfio_platform_ops = {
        .open_device    = vfio_platform_open_device,
        .close_device   = vfio_platform_close_device,
        .ioctl          = vfio_platform_ioctl,
-       .get_region_info = vfio_platform_ioctl_get_region_info,
+       .get_region_info_caps = vfio_platform_ioctl_get_region_info,
        .read           = vfio_platform_read,
        .write          = vfio_platform_write,
        .mmap           = vfio_platform_mmap,
index 3ebd50fb78fbb77e0d6b45510c4b4023129bf709..c2990b7e900fa541b7dd916335daec05d6c99b6c 100644 (file)
@@ -273,30 +273,20 @@ err_irq:
 EXPORT_SYMBOL_GPL(vfio_platform_open_device);
 
 int vfio_platform_ioctl_get_region_info(struct vfio_device *core_vdev,
-                                       struct vfio_region_info __user *arg)
+                                       struct vfio_region_info *info,
+                                       struct vfio_info_cap *caps)
 {
        struct vfio_platform_device *vdev =
                container_of(core_vdev, struct vfio_platform_device, vdev);
-       struct vfio_region_info info;
-       unsigned long minsz;
-
-       minsz = offsetofend(struct vfio_region_info, offset);
 
-       if (copy_from_user(&info, arg, minsz))
-               return -EFAULT;
-
-       if (info.argsz < minsz)
-               return -EINVAL;
-
-       if (info.index >= vdev->num_regions)
+       if (info->index >= vdev->num_regions)
                return -EINVAL;
 
        /* map offset to the physical address  */
-       info.offset = VFIO_PLATFORM_INDEX_TO_OFFSET(info.index);
-       info.size = vdev->regions[info.index].size;
-       info.flags = vdev->regions[info.index].flags;
-
-       return copy_to_user(arg, &info, minsz) ? -EFAULT : 0;
+       info->offset = VFIO_PLATFORM_INDEX_TO_OFFSET(info->index);
+       info->size = vdev->regions[info->index].size;
+       info->flags = vdev->regions[info->index].flags;
+       return 0;
 }
 EXPORT_SYMBOL_GPL(vfio_platform_ioctl_get_region_info);
 
index a6008320e77baeee093265ff9ecf5539f12f9c55..05084212a76eb6969b14c99b46b7bdf509a8af93 100644 (file)
@@ -86,7 +86,8 @@ void vfio_platform_close_device(struct vfio_device *core_vdev);
 long vfio_platform_ioctl(struct vfio_device *core_vdev,
                         unsigned int cmd, unsigned long arg);
 int vfio_platform_ioctl_get_region_info(struct vfio_device *core_vdev,
-                                       struct vfio_region_info __user *arg);
+                                       struct vfio_region_info *info,
+                                       struct vfio_info_cap *caps);
 ssize_t vfio_platform_read(struct vfio_device *core_vdev,
                           char __user *buf, size_t count,
                           loff_t *ppos);