Commit b0bd82bf authored by Jason Wang's avatar Jason Wang Committed by Michael S. Tsirkin

vhost-vdpa: refine ioctl pre-processing

Switch to use 'switch' to make the codes more easier to be extended.
Signed-off-by: default avatarJason Wang <jasowang@redhat.com>
Link: https://lore.kernel.org/r/20200804162048.22587-2-eli@mellanox.comSigned-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
parent 0a9d74d1
...@@ -360,15 +360,16 @@ static long vhost_vdpa_vring_ioctl(struct vhost_vdpa *v, unsigned int cmd, ...@@ -360,15 +360,16 @@ static long vhost_vdpa_vring_ioctl(struct vhost_vdpa *v, unsigned int cmd,
idx = array_index_nospec(idx, v->nvqs); idx = array_index_nospec(idx, v->nvqs);
vq = &v->vqs[idx]; 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))) if (copy_from_user(&s, argp, sizeof(s)))
return -EFAULT; return -EFAULT;
ops->set_vq_ready(vdpa, idx, s.num); ops->set_vq_ready(vdpa, idx, s.num);
return 0; return 0;
} case VHOST_GET_VRING_BASE:
if (cmd == VHOST_GET_VRING_BASE)
vq->last_avail_idx = ops->get_vq_state(v->vdpa, idx); vq->last_avail_idx = ops->get_vq_state(v->vdpa, idx);
break;
}
r = vhost_vring_ioctl(&v->vdev, cmd, argp); r = vhost_vring_ioctl(&v->vdev, cmd, argp);
if (r) if (r)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment