public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Gerd Hoffmann" <kraxel@redhat.com>
To: devel@edk2.groups.io
Cc: "Michael D Kinney" <michael.d.kinney@intel.com>,
	"Erdem Aktas" <erdemaktas@google.com>,
	"James Bottomley" <jejb@linux.ibm.com>,
	"Liming Gao" <gaoliming@byosoft.com.cn>,
	"Marvin Häuser" <mhaeuser@posteo.de>,
	"Pawel Polawski" <ppolawsk@redhat.com>,
	"Michael Roth" <michael.roth@amd.com>,
	"Tom Lendacky" <thomas.lendacky@amd.com>,
	"Gerd Hoffmann" <kraxel@redhat.com>,
	"Jiewen Yao" <jiewen.yao@intel.com>,
	"Jian J Wang" <jian.j.wang@intel.com>,
	"Ard Biesheuvel" <ardb+tianocore@kernel.org>,
	"Jordan Justen" <jordan.l.justen@intel.com>,
	"Hao A Wu" <hao.a.wu@intel.com>,
	"Zhiguang Liu" <zhiguang.liu@intel.com>,
	"Ray Ni" <ray.ni@intel.com>, "Min Xu" <min.m.xu@intel.com>,
	"Oliver Steffen" <osteffen@redhat.com>
Subject: [PATCH v2 6/6] UefiCpuPkg/MtrrLib: use new IS_POW2() macro.
Date: Wed, 22 Mar 2023 08:02:43 +0100	[thread overview]
Message-ID: <20230322070243.410903-7-kraxel@redhat.com> (raw)
In-Reply-To: <20230322070243.410903-1-kraxel@redhat.com>

Drop MtrrLibIsPowerOfTwo function, use the new IS_POW2() macro instead.

The ASSERT() removed (inside MtrrLibIsPowerOfTwo) is superfluous,
another ASSERT() a few lines up in MtrrLibCalculateMtrrs() already
guarantees that Length can not be zero at this point.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 UefiCpuPkg/Library/MtrrLib/MtrrLib.c | 17 +----------------
 1 file changed, 1 insertion(+), 16 deletions(-)

diff --git a/UefiCpuPkg/Library/MtrrLib/MtrrLib.c b/UefiCpuPkg/Library/MtrrLib/MtrrLib.c
index e5c862c83d61..dd0b668d7782 100644
--- a/UefiCpuPkg/Library/MtrrLib/MtrrLib.c
+++ b/UefiCpuPkg/Library/MtrrLib/MtrrLib.c
@@ -1253,21 +1253,6 @@ MtrrLibLowestType (
   return (MTRR_MEMORY_CACHE_TYPE)Type;
 }
 
-/**
-  Return TRUE when the Operand is exactly power of 2.
-
-  @retval TRUE  Operand is exactly power of 2.
-  @retval FALSE Operand is not power of 2.
-**/
-BOOLEAN
-MtrrLibIsPowerOfTwo (
-  IN     UINT64  Operand
-  )
-{
-  ASSERT (Operand != 0);
-  return (BOOLEAN)((Operand & (Operand - 1)) == 0);
-}
-
 /**
   Calculate the subtractive path from vertex Start to Stop.
 
@@ -1638,7 +1623,7 @@ MtrrLibCalculateMtrrs (
           break;
         }
 
-        if ((Weight[M (Start, Stop)] == MAX_WEIGHT) && MtrrLibIsPowerOfTwo (Length)) {
+        if ((Weight[M (Start, Stop)] == MAX_WEIGHT) && IS_POW2 (Length)) {
           if (MtrrLibGetNumberOfTypes (
                 Ranges,
                 RangeCount,
-- 
2.39.2


  parent reply	other threads:[~2023-03-22  7:03 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-22  7:02 [PATCH v2 0/6] MdePkg/Base.h: Introduce various alignment-related macros Gerd Hoffmann
2023-03-22  7:02 ` [PATCH v2 1/6] MdeModulePkg: Rename IS_ALIGNED macros to avoid name collisions Gerd Hoffmann
2023-03-22  7:02 ` [PATCH v2 2/6] OvmfPkg: " Gerd Hoffmann
2023-03-22  7:02 ` [PATCH v2 3/6] MdePkg/Base.h: Introduce various alignment-related macros Gerd Hoffmann
2023-03-22 22:17   ` Michael D Kinney
2023-03-22  7:02 ` [PATCH v2 4/6] MdeModulePkg: Consume new " Gerd Hoffmann
2023-03-22  7:02 ` [PATCH v2 5/6] OvmfPkg: " Gerd Hoffmann
2023-03-22  7:02 ` Gerd Hoffmann [this message]
2023-03-22  9:03   ` [PATCH v2 6/6] UefiCpuPkg/MtrrLib: use new IS_POW2() macro Ni, Ray
2023-03-22 22:15   ` [edk2-devel] " Michael D Kinney
2023-03-30  7:33 ` [PATCH v2 0/6] MdePkg/Base.h: Introduce various alignment-related macros Gerd Hoffmann
2023-04-01 23:38   ` [edk2-devel] " Michael D Kinney

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230322070243.410903-7-kraxel@redhat.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox