Skip to content

Commit

Permalink
vhost-vdpa: refine ioctl pre-processing
Browse files Browse the repository at this point in the history
Switch to use 'switch' to make the codes more easier to be extended.

Signed-off-by: Jason Wang <jasowang@redhat.com>
Link: https://lore.kernel.org/r/20200804162048.22587-2-eli@mellanox.com
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
  • Loading branch information
Jason Wang authored and Michael S. Tsirkin committed Aug 5, 2020
1 parent 0a9d74d commit b0bd82b
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions drivers/vhost/vdpa.c
Original file line number Diff line number Diff line change
Expand Up @@ -360,15 +360,16 @@ static long vhost_vdpa_vring_ioctl(struct vhost_vdpa *v, unsigned int cmd,
idx = array_index_nospec(idx, v->nvqs);
vq = &v->vqs[idx];

if (cmd == VHOST_VDPA_SET_VRING_ENABLE) {
switch (cmd) {
case VHOST_VDPA_SET_VRING_ENABLE:
if (copy_from_user(&s, argp, sizeof(s)))
return -EFAULT;
ops->set_vq_ready(vdpa, idx, s.num);
return 0;
}

if (cmd == VHOST_GET_VRING_BASE)
case VHOST_GET_VRING_BASE:
vq->last_avail_idx = ops->get_vq_state(v->vdpa, idx);
break;
}

r = vhost_vring_ioctl(&v->vdev, cmd, argp);
if (r)
Expand Down

0 comments on commit b0bd82b

Please sign in to comment.