All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/i915/gvt: Simplify case switch in intel_vgpu_ioctl
@ 2025-09-18 21:45 Jonathan Cavitt
  2025-09-19  0:43 ` ✓ i915.CI.BAT: success for " Patchwork
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Jonathan Cavitt @ 2025-09-18 21:45 UTC (permalink / raw)
  To: intel-gfx; +Cc: saurabhg.gupta, alex.zuo, jonathan.cavitt, andi.shyti

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: Jonathan Cavitt <jonathan.cavitt@intel.com>
Cc: Andi Shyti <andi.shyti@linux.intel.com>
---
 drivers/gpu/drm/i915/gvt/kvmgt.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/i915/gvt/kvmgt.c b/drivers/gpu/drm/i915/gvt/kvmgt.c
index 69830a5c49d3..70af86d46fe8 100644
--- a/drivers/gpu/drm/i915/gvt/kvmgt.c
+++ b/drivers/gpu/drm/i915/gvt/kvmgt.c
@@ -1279,20 +1279,15 @@ 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,
 						    sparse->nr_areas));
-				if (ret) {
-					kfree(sparse);
-					return ret;
-				}
-				break;
-			default:
+			if (ret) {
 				kfree(sparse);
-				return -EINVAL;
+				return ret;
 			}
 		}
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2025-09-25 22:24 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-18 21:45 [PATCH] drm/i915/gvt: Simplify case switch in intel_vgpu_ioctl Jonathan Cavitt
2025-09-19  0:43 ` ✓ i915.CI.BAT: success for " Patchwork
2025-09-19 10:22 ` [PATCH] " Andi Shyti
2025-09-19 22:10 ` ✗ i915.CI.Full: failure for " Patchwork
2025-09-22  2:50 ` [PATCH] " Zhenyu Wang
2025-09-23 23:44 ` ✓ i915.CI.BAT: success for drm/i915/gvt: Simplify case switch in intel_vgpu_ioctl (rev2) Patchwork
2025-09-24 14:36 ` ✗ i915.CI.Full: failure " Patchwork
2025-09-25 22:24 ` [PATCH] drm/i915/gvt: Simplify case switch in intel_vgpu_ioctl Andi Shyti

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.