From patchwork Fri Oct 21 06:27:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Huang, Shaoqin" X-Patchwork-Id: 6525 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp521665wrr; Thu, 20 Oct 2022 23:33:38 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6oHU/3krQ5MFEqyxA8pJA4TWMx8spMb5EPqjy6ZB5WARjabk32GaAy873NYCMP4LvGyQg9 X-Received: by 2002:a17:907:3d8f:b0:78d:b46e:eadd with SMTP id he15-20020a1709073d8f00b0078db46eeaddmr14434173ejc.277.1666334018227; Thu, 20 Oct 2022 23:33:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666334018; cv=none; d=google.com; s=arc-20160816; b=EBe9/da3NLq4u2aoTnnsDBhEYYCm3E6r9+cRzQQyLI1WWQNRYbP0o9A7hNJFa2UaeU sIJZdLoL5tXudQogByBMccuSDDystM09JZtn0sVcuiusdv4t7jqWBsbWBrkBZ/7UN1yO qpX9bg53ZWzPfIglmluCser2ls31h8bvN0NijeJZS1NoupzOY0R+3jBHfag/UF7eis6g Dxj1rboTSib11UrSAAOS3szFn27N6SPpeKk4kR6EHoEvx/XgHO7AIhdbLcQ251ez4rZh aEMdu3/Bvl5p89cy5dj/0iB9mf9FHdh/La3rN1mFxLtDNdlbsN7+FfqoWlwZPPj0DJ+/ 7gbA== 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=WwDxwuFKFn7IDXJ4g8zfhNzZAfmgre6BEKXClu1O9e4=; b=C52HpsgUhLwiSm082+cb2uf464SFmL2Mvk55dkT8NZqdK6Oap3/WG6pvUgc679hrqi msB5JCl5/arqdWBaYV0FG13777j/YyFeyeqaDARzMrzLwC6wqCHkGwjc84KHVK+XGpnp MjyO1dXZovQxVYS6zlQ0XXpnL7rwk1yXfHwXGf7/cqhI3yecsUa+Kk6FWy8OgxNod5ZW lWQrHf4z+3l35OQxCepIiB2jay5F/w7KAgG1aPwGDDUJrwNOD4KdZxftTn6L8GNTLgPJ e+J2QSoxiH/N/EqN/1BdTc6UVpr7DwJZEoP1tmV57jrD5XhNDQJ/m+egMXTVrUy1YMEu rdug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=O2h8Ti+y; 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 nd27-20020a170907629b00b0078331a3b123si21384127ejc.572.2022.10.20.23.33.13; Thu, 20 Oct 2022 23:33:38 -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=O2h8Ti+y; 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 S229958AbiJUG1r (ORCPT + 99 others); Fri, 21 Oct 2022 02:27:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229690AbiJUG1k (ORCPT ); Fri, 21 Oct 2022 02:27:40 -0400 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C8A51239233 for ; Thu, 20 Oct 2022 23:27:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1666333659; x=1697869659; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=NnQlu/b7OKYqJy4jWUYIP9NkO/n7jpwIEwYD7R17ODQ=; b=O2h8Ti+yg7CKhiRR23xmdrxk8/bVvUMaWKVow+tagvKINjw742Jw9GQQ 2X2Vlqb3af3qbamNtFSgw6LOej93w2BeNy0Bk5X8QR5TQhmZJ+UrkEGlw XKeC+2Bf9csL14kIYeEb0wndose20xK5qkQgwgXU1hcarU6Xhv6m3yQ2Y AU65duowtVHwjNhr8/HzPtvvhg/u9kterGFVzyffzYpupJdA3PH315FxN ZwWRFdRoVfeo2bwPhs2l4CoUa8P//AC1RUY53T8cOGGKY14Ti8hHNaq1p rwotS02j27MzNV2oNTAxtx8xD22g/Jg+Au/IYvRRFqVJb919DkAjHbBwb Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10506"; a="286642400" X-IronPort-AV: E=Sophos;i="5.95,200,1661842800"; d="scan'208";a="286642400" 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="735358030" X-IronPort-AV: E=Sophos;i="5.95,200,1661842800"; d="scan'208";a="735358030" 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 1/2] virtio_pci: use helper function is_power_of_2() Date: Thu, 20 Oct 2022 23:27:33 -0700 Message-Id: <20221021062734.228881-2-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?1747277859496108836?= X-GMAIL-MSGID: =?utf-8?q?1747277859496108836?= 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: Philippe Mathieu-Daudé Reviewed-by: Xuan Zhuo --- drivers/virtio/virtio_pci_modern.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/virtio/virtio_pci_modern.c b/drivers/virtio/virtio_pci_modern.c index c3b9f2761849..207294bd7b9d 100644 --- a/drivers/virtio/virtio_pci_modern.c +++ b/drivers/virtio/virtio_pci_modern.c @@ -310,7 +310,7 @@ static struct virtqueue *setup_vq(struct virtio_pci_device *vp_dev, if (!num || vp_modern_get_queue_enable(mdev, index)) return ERR_PTR(-ENOENT); - if (num & (num - 1)) { + if (!is_power_of_2(num)) { dev_warn(&vp_dev->pci_dev->dev, "bad queue size %u", num); return ERR_PTR(-EINVAL); }