Skip to content

Commit b0bd82b

Browse files
jasowangmstsirkin
authored andcommitted
vhost-vdpa: refine ioctl pre-processing
Switch to use 'switch' to make the codes more easier to be extended. Signed-off-by: Jason Wang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Michael S. Tsirkin <[email protected]>
1 parent 0a9d74d commit b0bd82b

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

drivers/vhost/vdpa.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -360,15 +360,16 @@ static long vhost_vdpa_vring_ioctl(struct vhost_vdpa *v, unsigned int cmd,
360360
idx = array_index_nospec(idx, v->nvqs);
361361
vq = &v->vqs[idx];
362362

363-
if (cmd == VHOST_VDPA_SET_VRING_ENABLE) {
363+
switch (cmd) {
364+
case VHOST_VDPA_SET_VRING_ENABLE:
364365
if (copy_from_user(&s, argp, sizeof(s)))
365366
return -EFAULT;
366367
ops->set_vq_ready(vdpa, idx, s.num);
367368
return 0;
368-
}
369-
370-
if (cmd == VHOST_GET_VRING_BASE)
369+
case VHOST_GET_VRING_BASE:
371370
vq->last_avail_idx = ops->get_vq_state(v->vdpa, idx);
371+
break;
372+
}
372373

373374
r = vhost_vring_ioctl(&v->vdev, cmd, argp);
374375
if (r)

0 commit comments

Comments
 (0)