Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp456033pxa; Tue, 4 Aug 2020 09:26:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw30xAJujJK8qJ66Re/gUTHHBPBjiDvpgmk15XA4/4SeUNJdxqwj5y9EG+VK1oedObzDht6 X-Received: by 2002:a17:906:c7d3:: with SMTP id dc19mr22539665ejb.495.1596558395251; Tue, 04 Aug 2020 09:26:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596558395; cv=none; d=google.com; s=arc-20160816; b=D/+L02D5t2R0ANloQ4RQAcMo39dBm9ra+uooROKKWkFkXUcFtel3SVjTqlCSF1gRdI op1QPAip8QWPR9Jcg063EdxXNegbh4YrcUcDkfstOjML09QIPcM0rDNxTm8LtM/AIn0l dHrLnkiWMQLQrQWqotSqz43s3QCHWLb261ri0y+jvg4xfOSVKSzKarho+pzQmkaNdxG+ zMi8bitc1lTO2QHmB/x/+v987xWrnvtp7fAJHart10JHdPwTvP3m9Q37k3ayMFDxPmM7 f1UA1J1A6kj5fPWQZcgJJPhWL2FZDzIQJEedetoBh3Zti5VWyGDHylm/8Jn7hDp3n1XM 6Ovg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=+fsdSEL9+csz4qeZEg83pq6TlsQ97KDe++ISOBTdknc=; b=zv0KB0CHjmhi6wmWpMuwWWew/+fjCQDwnLJ6chEMCdAfZ42UgnTearAGzPaTwc/R0h bYLeDLgG4YlozVVeCzQmsW0xrLUNWtCtxdVl2S7YmIp7/zS1kTL8FOEaIkT3rj4n5sNU HqMJr8MI3KY+ti4LXuLPi38dTr8nhL4Bcy0ABs+ImMB+z4ciaHNJzu5tdRqp91C74d5h x9ORk6yx7HWXEs2yQrMZtNWDRBURu7jH70/b1qncc2m98Ox5CGXdz9TBW/GSDup1wZLB 31ciPqNscCf+awrRjh16FFWPHVUS/gn7ZxF0TwV2RAMfTbtTAtu2X9lHwdjPGjpE+kDM ZDPg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mellanox.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id za3si2579875ejb.312.2020.08.04.09.26.02; Tue, 04 Aug 2020 09:26:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mellanox.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729908AbgHDQZK (ORCPT + 99 others); Tue, 4 Aug 2020 12:25:10 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:43866 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729563AbgHDQU6 (ORCPT ); Tue, 4 Aug 2020 12:20:58 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from eli@mellanox.com) with SMTP; 4 Aug 2020 19:20:51 +0300 Received: from nps-server-21.mtl.labs.mlnx (nps-server-21.mtl.labs.mlnx [10.237.240.120]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 074GKpLO023990; Tue, 4 Aug 2020 19:20:51 +0300 Received: from nps-server-21.mtl.labs.mlnx (localhost [127.0.0.1]) by nps-server-21.mtl.labs.mlnx (8.14.7/8.14.7) with ESMTP id 074GKpIx022634; Tue, 4 Aug 2020 19:20:51 +0300 Received: (from eli@localhost) by nps-server-21.mtl.labs.mlnx (8.14.7/8.14.7/Submit) id 074GKpvj022633; Tue, 4 Aug 2020 19:20:51 +0300 From: Eli Cohen To: mst@redhat.com, jasowang@redhat.com, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org Cc: shahafs@mellanox.com, saeedm@mellanox.com, parav@mellanox.com Subject: [PATCH V4 linux-next 01/12] vhost-vdpa: refine ioctl pre-processing Date: Tue, 4 Aug 2020 19:20:37 +0300 Message-Id: <20200804162048.22587-2-eli@mellanox.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200804162048.22587-1-eli@mellanox.com> References: <20200804162048.22587-1-eli@mellanox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jason Wang Switch to use 'switch' to make the codes more easier to be extended. Signed-off-by: Jason Wang --- drivers/vhost/vdpa.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c index 16e0ffb115be..563ae6204052 100644 --- a/drivers/vhost/vdpa.c +++ b/drivers/vhost/vdpa.c @@ -377,15 +377,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) -- 2.26.0