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/ccw: Convert to get_region_info_caps

Remove the duplicate code and flatten the call chain.

Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Reviewed-by: Eric Farman <farman@linux.ibm.com>
Link: https://lore.kernel.org/r/18-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
973af0c4 93165757

+7 -48
+7 -48
drivers/s390/cio/vfio_ccw_ops.c
··· 313 313 return 0; 314 314 } 315 315 316 - static int vfio_ccw_mdev_get_region_info(struct vfio_ccw_private *private, 317 - struct vfio_region_info *info, 318 - unsigned long arg) 316 + static int vfio_ccw_mdev_ioctl_get_region_info(struct vfio_device *vdev, 317 + struct vfio_region_info *info, 318 + struct vfio_info_cap *caps) 319 319 { 320 + struct vfio_ccw_private *private = 321 + container_of(vdev, struct vfio_ccw_private, vdev); 320 322 int i; 321 323 322 324 switch (info->index) { ··· 330 328 return 0; 331 329 default: /* all other regions are handled via capability chain */ 332 330 { 333 - struct vfio_info_cap caps = { .buf = NULL, .size = 0 }; 334 331 struct vfio_region_info_cap_type cap_type = { 335 332 .header.id = VFIO_REGION_INFO_CAP_TYPE, 336 333 .header.version = 1 }; ··· 352 351 cap_type.type = private->region[i].type; 353 352 cap_type.subtype = private->region[i].subtype; 354 353 355 - ret = vfio_info_add_capability(&caps, &cap_type.header, 354 + ret = vfio_info_add_capability(caps, &cap_type.header, 356 355 sizeof(cap_type)); 357 356 if (ret) 358 357 return ret; 359 - 360 - info->flags |= VFIO_REGION_INFO_FLAG_CAPS; 361 - if (info->argsz < sizeof(*info) + caps.size) { 362 - info->argsz = sizeof(*info) + caps.size; 363 - info->cap_offset = 0; 364 - } else { 365 - vfio_info_cap_shift(&caps, sizeof(*info)); 366 - if (copy_to_user((void __user *)arg + sizeof(*info), 367 - caps.buf, caps.size)) { 368 - kfree(caps.buf); 369 - return -EFAULT; 370 - } 371 - info->cap_offset = sizeof(*info); 372 - } 373 - 374 - kfree(caps.buf); 375 - 376 358 } 377 359 } 378 360 return 0; ··· 488 504 private->region = NULL; 489 505 } 490 506 491 - static int 492 - vfio_ccw_mdev_ioctl_get_region_info(struct vfio_device *vdev, 493 - struct vfio_region_info __user *arg) 494 - { 495 - struct vfio_ccw_private *private = 496 - container_of(vdev, struct vfio_ccw_private, vdev); 497 - struct vfio_region_info info; 498 - unsigned long minsz; 499 - int ret; 500 - 501 - minsz = offsetofend(struct vfio_region_info, offset); 502 - 503 - if (copy_from_user(&info, arg, minsz)) 504 - return -EFAULT; 505 - 506 - if (info.argsz < minsz) 507 - return -EINVAL; 508 - 509 - ret = vfio_ccw_mdev_get_region_info(private, &info, arg); 510 - if (ret) 511 - return ret; 512 - 513 - return copy_to_user(arg, &info, minsz) ? -EFAULT : 0; 514 - } 515 - 516 507 static ssize_t vfio_ccw_mdev_ioctl(struct vfio_device *vdev, 517 508 unsigned int cmd, 518 509 unsigned long arg) ··· 593 634 .read = vfio_ccw_mdev_read, 594 635 .write = vfio_ccw_mdev_write, 595 636 .ioctl = vfio_ccw_mdev_ioctl, 596 - .get_region_info = vfio_ccw_mdev_ioctl_get_region_info, 637 + .get_region_info_caps = vfio_ccw_mdev_ioctl_get_region_info, 597 638 .request = vfio_ccw_mdev_request, 598 639 .dma_unmap = vfio_ccw_dma_unmap, 599 640 .bind_iommufd = vfio_iommufd_emulated_bind,