]> xenbits.xensource.com Git - ovmf.git/commitdiff
UefiCpuPkg/MtrrLib: use new IS_POW2() macro.
authorGerd Hoffmann <kraxel@redhat.com>
Wed, 22 Mar 2023 07:02:43 +0000 (00:02 -0700)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Sat, 1 Apr 2023 23:11:44 +0000 (23:11 +0000)
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>
Reviewed-by: Ray Ni <ray.ni@intel.com>
UefiCpuPkg/Library/MtrrLib/MtrrLib.c

index a66357e30580618042a8ae60f7f1ff5a7539ef7b..22ec8d2a48413106b2092ce9bbec99843857dc1f 100644 (file)
@@ -1273,21 +1273,6 @@ MtrrLibLowestType (
   return (MTRR_MEMORY_CACHE_TYPE)Type;\r
 }\r
 \r
-/**\r
-  Return TRUE when the Operand is exactly power of 2.\r
-\r
-  @retval TRUE  Operand is exactly power of 2.\r
-  @retval FALSE Operand is not power of 2.\r
-**/\r
-BOOLEAN\r
-MtrrLibIsPowerOfTwo (\r
-  IN     UINT64  Operand\r
-  )\r
-{\r
-  ASSERT (Operand != 0);\r
-  return (BOOLEAN)((Operand & (Operand - 1)) == 0);\r
-}\r
-\r
 /**\r
   Calculate the subtractive path from vertex Start to Stop.\r
 \r
@@ -1658,7 +1643,7 @@ MtrrLibCalculateMtrrs (
           break;\r
         }\r
 \r
-        if ((Weight[M (Start, Stop)] == MAX_WEIGHT) && MtrrLibIsPowerOfTwo (Length)) {\r
+        if ((Weight[M (Start, Stop)] == MAX_WEIGHT) && IS_POW2 (Length)) {\r
           if (MtrrLibGetNumberOfTypes (\r
                 Ranges,\r
                 RangeCount,\r