public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Ni, Ray" <ray.ni@intel.com>
To: Gerd Hoffmann <kraxel@redhat.com>,
	"devel@edk2.groups.io" <devel@edk2.groups.io>
Cc: "Kinney, Michael D" <michael.d.kinney@intel.com>,
	"Aktas, Erdem" <erdemaktas@google.com>,
	"James Bottomley" <jejb@linux.ibm.com>,
	"Gao, Liming" <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>,
	"Yao, Jiewen" <jiewen.yao@intel.com>,
	"Wang, Jian J" <jian.j.wang@intel.com>,
	"Ard Biesheuvel" <ardb+tianocore@kernel.org>,
	"Justen, Jordan L" <jordan.l.justen@intel.com>,
	"Wu, Hao A" <hao.a.wu@intel.com>,
	"Liu, Zhiguang" <zhiguang.liu@intel.com>,
	"Xu, Min M" <min.m.xu@intel.com>,
	"Oliver Steffen" <osteffen@redhat.com>
Subject: Re: [PATCH v2 6/6] UefiCpuPkg/MtrrLib: use new IS_POW2() macro.
Date: Wed, 22 Mar 2023 09:03:44 +0000	[thread overview]
Message-ID: <MN6PR11MB824456ED78EBA888324BE3018C869@MN6PR11MB8244.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20230322070243.410903-7-kraxel@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 2482 bytes --]

Reviewed-by: Ray Ni <ray.ni@intel.com>

thanks,
ray
________________________________
From: Gerd Hoffmann <kraxel@redhat.com>
Sent: Wednesday, March 22, 2023 3:02:43 PM
To: devel@edk2.groups.io <devel@edk2.groups.io>
Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Aktas, Erdem <erdemaktas@google.com>; James Bottomley <jejb@linux.ibm.com>; Gao, Liming <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>; Yao, Jiewen <jiewen.yao@intel.com>; Wang, Jian J <jian.j.wang@intel.com>; Ard Biesheuvel <ardb+tianocore@kernel.org>; Justen, Jordan L <jordan.l.justen@intel.com>; Wu, Hao A <hao.a.wu@intel.com>; Liu, Zhiguang <zhiguang.liu@intel.com>; Ni, Ray <ray.ni@intel.com>; Xu, Min M <min.m.xu@intel.com>; Oliver Steffen <osteffen@redhat.com>
Subject: [PATCH v2 6/6] UefiCpuPkg/MtrrLib: use new IS_POW2() macro.

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


[-- Attachment #2: Type: text/html, Size: 3979 bytes --]

  reply	other threads:[~2023-03-22  9: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 ` [PATCH v2 6/6] UefiCpuPkg/MtrrLib: use new IS_POW2() macro Gerd Hoffmann
2023-03-22  9:03   ` Ni, Ray [this message]
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=MN6PR11MB824456ED78EBA888324BE3018C869@MN6PR11MB8244.namprd11.prod.outlook.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