From patchwork Fri Oct 21 06:27:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Huang, Shaoqin" X-Patchwork-Id: 6527 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp521855wrr; Thu, 20 Oct 2022 23:34:07 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7xWk5NyQeenqKZ0Zk/Ljajihvx5m7yIMmmA/iQDGBph3/hKuTeYjt9a7E1BVtI80c0oX/g X-Received: by 2002:a17:907:3e02:b0:782:1267:f2c8 with SMTP id hp2-20020a1709073e0200b007821267f2c8mr14015356ejc.585.1666334047672; Thu, 20 Oct 2022 23:34:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666334047; cv=none; d=google.com; s=arc-20160816; b=eE7AE1dCVMpZCro3KIWLtg+CZE/BtB41/okzz4jLXR6V9V2FiwH5+AYgp0sL7pEteF 9rKt/+f89m6iJQgH8P1gNV++GD5pSgEH78rf3tki+W5X3R6dIQiMtGY+ppx+Y+qemNT7 rJUBigScSNKcwOBR1IBj7rYbddkQO4uQ/EHPFVFz9YV+gbJAYvIQvaZ3S0eUrCFVJFcR p7Y5MYCkkDdJ9N+2GM4kSVP+GcL1uqWb9Mb7wmaL2CHmQ3Zy4/PctVVH56/hEvttIxTZ XCt/6N1+kfaS8uRNmzj+YEUhMwqdS/PDeYsVWH/sCfS6311hRkkdVgPFZd7FxojnQ8bg 41YQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=sefUPNg3H6tiTNdmeyjfz6HuTjDZzBFjuAiZ1DC29bk=; b=biFRZN8FMmbxV6crIxTVvp3MSMoqdE8tvRfo6Px8OWq0eHwnXPyKovi4LHpV880O79 Z7Noskb7HgaTXIuWQid1QtLMJ8iZtFwEJHwmzvJqGX3gxp1eLkEPXauOLG2GvmwDFtbE n/T5UzFFRbQi1IPAJFu95zIrouCmccnBYFKOy6uWPqwfiZ9D0JHraIQMedJrBDBqkAs2 6k2vVcOByJ0cncGqTVYCnBNJLlYkYwK8prZA5lhy7JRUpoNQVH5W8T3ussGX5u9WmA2p wx9omQbDz/0u4Gw5FewicAxGQ7nviiYkrwqmfbwyjEyTMFBdzjXl6Puy5q3PAsBY3vYR RI5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=mgkf8E9B; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i26-20020a50fd1a000000b0045cc4d4d64fsi16832648eds.256.2022.10.20.23.33.22; Thu, 20 Oct 2022 23:34:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=mgkf8E9B; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229776AbiJUG1u (ORCPT + 99 others); Fri, 21 Oct 2022 02:27:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229937AbiJUG1l (ORCPT ); Fri, 21 Oct 2022 02:27:41 -0400 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 49CE4239235 for ; Thu, 20 Oct 2022 23:27:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1666333660; x=1697869660; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=YzNlDHPI/XFafd7wgVRkw0spwtN78uwxU/YxTQTL/b4=; b=mgkf8E9BGeAe+cNX/V+Z3WPyaUUTEilLFru3qB+OGralYqcHIdSKVIj5 T6fswYsZjd0RAn9RGcKxfuTuFMAb9Yl3xOAXRPeejd7f1WUExDiFRnN1Z StTJUEL57lTu3gId6USviViabmlFvJqDdJlyOjzMgclADaUPCQUMzENuU 6pxZZKCN+5HC0sEfFMu1z7MvTyPAEXHzA4jt2hCMISnYxYKXk5f6X01hw M0wf5MeydGMVfEVfwrzjB0JW94DFY0C+KqgpvPN6yX4IVC7Sp4iZY/fym ROu/ikLWsLiKzjnbJWl0RskokqsApb42RlCxFOOY1kN4OYmFK7NaMyX17 Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10506"; a="286642406" X-IronPort-AV: E=Sophos;i="5.95,200,1661842800"; d="scan'208";a="286642406" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Oct 2022 23:27:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10506"; a="735358035" X-IronPort-AV: E=Sophos;i="5.95,200,1661842800"; d="scan'208";a="735358035" Received: from d8bbc18b98c6.jf.intel.com ([10.54.241.152]) by fmsmga002.fm.intel.com with ESMTP; 20 Oct 2022 23:27:39 -0700 From: shaoqin.huang@intel.com To: mst@redhat.com, jasowang@redhat.com Cc: Shaoqin Huang , virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] virtio_ring: use helper function is_power_of_2() Date: Thu, 20 Oct 2022 23:27:34 -0700 Message-Id: <20221021062734.228881-3-shaoqin.huang@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221021062734.228881-1-shaoqin.huang@intel.com> References: <20221021062734.228881-1-shaoqin.huang@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747277890292836231?= X-GMAIL-MSGID: =?utf-8?q?1747277890292836231?= From: Shaoqin Huang Use helper function is_power_of_2() to check if num is power of two. Minor readability improvement. Signed-off-by: Shaoqin Huang Reviewed-by: Xuan Zhuo --- drivers/virtio/virtio_ring.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c index 2e7689bb933b..723c4e29e1d3 100644 --- a/drivers/virtio/virtio_ring.c +++ b/drivers/virtio/virtio_ring.c @@ -1052,7 +1052,7 @@ static int vring_alloc_queue_split(struct vring_virtqueue_split *vring_split, dma_addr_t dma_addr; /* We assume num is a power of 2. */ - if (num & (num - 1)) { + if (!is_power_of_2(num)) { dev_warn(&vdev->dev, "Bad virtqueue length %u\n", num); return -EINVAL; }