Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

vfio/fsl: Provide a get_region_info op

Move it out of vfio_fsl_mc_ioctl() and re-indent it.

Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Acked-by: Pranjal Shrivastava <praan@google.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Link: https://lore.kernel.org/r/10-v2-2a9e24d62f1b+e10a-vfio_get_region_info_op_jgg@nvidia.com
Signed-off-by: Alex Williamson <alex@shazbot.org>

authored by

Jason Gunthorpe and committed by
Alex Williamson
6cdae5d0 d4635df2

+32 -24
+32 -24
drivers/vfio/fsl-mc/vfio_fsl_mc.c
··· 117 117 fsl_mc_cleanup_irq_pool(mc_cont); 118 118 } 119 119 120 + static int 121 + vfio_fsl_mc_ioctl_get_region_info(struct vfio_device *core_vdev, 122 + struct vfio_region_info __user *arg) 123 + { 124 + struct vfio_fsl_mc_device *vdev = 125 + container_of(core_vdev, struct vfio_fsl_mc_device, vdev); 126 + struct fsl_mc_device *mc_dev = vdev->mc_dev; 127 + struct vfio_region_info info; 128 + unsigned long minsz; 129 + 130 + minsz = offsetofend(struct vfio_region_info, offset); 131 + 132 + if (copy_from_user(&info, arg, minsz)) 133 + return -EFAULT; 134 + 135 + if (info.argsz < minsz) 136 + return -EINVAL; 137 + 138 + if (info.index >= mc_dev->obj_desc.region_count) 139 + return -EINVAL; 140 + 141 + /* map offset to the physical address */ 142 + info.offset = VFIO_FSL_MC_INDEX_TO_OFFSET(info.index); 143 + info.size = vdev->regions[info.index].size; 144 + info.flags = vdev->regions[info.index].flags; 145 + 146 + if (copy_to_user(arg, &info, minsz)) 147 + return -EFAULT; 148 + return 0; 149 + } 150 + 120 151 static long vfio_fsl_mc_ioctl(struct vfio_device *core_vdev, 121 152 unsigned int cmd, unsigned long arg) 122 153 { ··· 179 148 180 149 return copy_to_user((void __user *)arg, &info, minsz) ? 181 150 -EFAULT : 0; 182 - } 183 - case VFIO_DEVICE_GET_REGION_INFO: 184 - { 185 - struct vfio_region_info info; 186 - 187 - minsz = offsetofend(struct vfio_region_info, offset); 188 - 189 - if (copy_from_user(&info, (void __user *)arg, minsz)) 190 - return -EFAULT; 191 - 192 - if (info.argsz < minsz) 193 - return -EINVAL; 194 - 195 - if (info.index >= mc_dev->obj_desc.region_count) 196 - return -EINVAL; 197 - 198 - /* map offset to the physical address */ 199 - info.offset = VFIO_FSL_MC_INDEX_TO_OFFSET(info.index); 200 - info.size = vdev->regions[info.index].size; 201 - info.flags = vdev->regions[info.index].flags; 202 - 203 - if (copy_to_user((void __user *)arg, &info, minsz)) 204 - return -EFAULT; 205 - return 0; 206 151 } 207 152 case VFIO_DEVICE_GET_IRQ_INFO: 208 153 { ··· 596 589 .open_device = vfio_fsl_mc_open_device, 597 590 .close_device = vfio_fsl_mc_close_device, 598 591 .ioctl = vfio_fsl_mc_ioctl, 592 + .get_region_info = vfio_fsl_mc_ioctl_get_region_info, 599 593 .read = vfio_fsl_mc_read, 600 594 .write = vfio_fsl_mc_write, 601 595 .mmap = vfio_fsl_mc_mmap,