Commit 69b4d367 authored by Jonathan Cavitt's avatar Jonathan Cavitt Committed by Andi Shyti
Browse files

drm/i915/gvt: Simplify case switch in intel_vgpu_ioctl



We do not need a case switch to check cap_type_id in intel_vgpu_ioctl
for various reasons (it's impossible to hit the default case in the
current code, there's only one valid case to check, the error handling
code overlaps in both cases, etc.).  Simplify the case switch into a
single if statement.  This has the additional effect of simplifying the
error handling code.

Note that it is still currently impossible for
'if (cap_type_id == VFIO_REGION_INFO_CAP_SPARSE_MMAP)'
to fail, but we should still guard against the possibility of this
changing in the future.

Signed-off-by: default avatarJonathan Cavitt <jonathan.cavitt@intel.com>
Cc: Andi Shyti <andi.shyti@linux.intel.com>
Reviewed-by: default avatarZhenyu Wang <zhenyuw.linux@gmail.com>
Reviewed-by: default avatarAndi Shyti <andi.shyti@linux.intel.com>
Signed-off-by: default avatarAndi Shyti <andi.shyti@linux.intel.com>
Link: https://lore.kernel.org/r/20250918214515.66926-2-jonathan.cavitt@intel.com
parent fe3c0353
Loading
Loading
Loading
Loading
+4 −9
Original line number Diff line number Diff line
@@ -1279,8 +1279,8 @@ static long intel_vgpu_ioctl(struct vfio_device *vfio_dev, unsigned int cmd,
		}

		if ((info.flags & VFIO_REGION_INFO_FLAG_CAPS) && sparse) {
			switch (cap_type_id) {
			case VFIO_REGION_INFO_CAP_SPARSE_MMAP:
			ret = -EINVAL;
			if (cap_type_id == VFIO_REGION_INFO_CAP_SPARSE_MMAP)
				ret = vfio_info_add_capability(&caps,
					&sparse->header,
					struct_size(sparse, areas,
@@ -1289,11 +1289,6 @@ static long intel_vgpu_ioctl(struct vfio_device *vfio_dev, unsigned int cmd,
				kfree(sparse);
				return ret;
			}
				break;
			default:
				kfree(sparse);
				return -EINVAL;
			}
		}

		if (caps.size) {