vfio/platform: Convert to get_region_info_caps

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>
This commit is contained in:
Jason Gunthorpe 2025-11-07 13:41:36 -04:00 committed by Alex Williamson
parent 1b0ecb5baf
commit 182c62861b
4 changed files with 11 additions and 20 deletions

View File

@ -115,7 +115,7 @@ static const struct vfio_device_ops vfio_amba_ops = {
.open_device = vfio_platform_open_device, .open_device = vfio_platform_open_device,
.close_device = vfio_platform_close_device, .close_device = vfio_platform_close_device,
.ioctl = vfio_platform_ioctl, .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, .read = vfio_platform_read,
.write = vfio_platform_write, .write = vfio_platform_write,
.mmap = vfio_platform_mmap, .mmap = vfio_platform_mmap,

View File

@ -101,7 +101,7 @@ static const struct vfio_device_ops vfio_platform_ops = {
.open_device = vfio_platform_open_device, .open_device = vfio_platform_open_device,
.close_device = vfio_platform_close_device, .close_device = vfio_platform_close_device,
.ioctl = vfio_platform_ioctl, .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, .read = vfio_platform_read,
.write = vfio_platform_write, .write = vfio_platform_write,
.mmap = vfio_platform_mmap, .mmap = vfio_platform_mmap,

View File

@ -273,30 +273,20 @@ int vfio_platform_open_device(struct vfio_device *core_vdev)
EXPORT_SYMBOL_GPL(vfio_platform_open_device); EXPORT_SYMBOL_GPL(vfio_platform_open_device);
int vfio_platform_ioctl_get_region_info(struct vfio_device *core_vdev, 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 = struct vfio_platform_device *vdev =
container_of(core_vdev, 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 (info->index >= vdev->num_regions)
if (copy_from_user(&info, arg, minsz))
return -EFAULT;
if (info.argsz < minsz)
return -EINVAL;
if (info.index >= vdev->num_regions)
return -EINVAL; return -EINVAL;
/* map offset to the physical address */ /* map offset to the physical address */
info.offset = VFIO_PLATFORM_INDEX_TO_OFFSET(info.index); info->offset = VFIO_PLATFORM_INDEX_TO_OFFSET(info->index);
info.size = vdev->regions[info.index].size; info->size = vdev->regions[info->index].size;
info.flags = vdev->regions[info.index].flags; info->flags = vdev->regions[info->index].flags;
return 0;
return copy_to_user(arg, &info, minsz) ? -EFAULT : 0;
} }
EXPORT_SYMBOL_GPL(vfio_platform_ioctl_get_region_info); EXPORT_SYMBOL_GPL(vfio_platform_ioctl_get_region_info);

View File

@ -86,7 +86,8 @@ void vfio_platform_close_device(struct vfio_device *core_vdev);
long vfio_platform_ioctl(struct vfio_device *core_vdev, long vfio_platform_ioctl(struct vfio_device *core_vdev,
unsigned int cmd, unsigned long arg); unsigned int cmd, unsigned long arg);
int vfio_platform_ioctl_get_region_info(struct vfio_device *core_vdev, 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, ssize_t vfio_platform_read(struct vfio_device *core_vdev,
char __user *buf, size_t count, char __user *buf, size_t count,
loff_t *ppos); loff_t *ppos);