]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPkg/ArmDmaLib: consistently use 'gCacheAlignment - 1' as alignment mask
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Tue, 19 Apr 2016 14:16:37 +0000 (16:16 +0200)
committerArd Biesheuvel <ard.biesheuvel@linaro.org>
Tue, 10 May 2016 12:44:27 +0000 (14:44 +0200)
We manage to use both an AND operation with 'gCacheAlignment - 1' and a
modulo operation with 'gCacheAlignment' in the same compound if statement.
Since gCacheAlignment is a global of which the compiler cannot guarantee
that it is a power of two, simply use the AND version in both cases.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
ArmPkg/Library/ArmDmaLib/ArmDmaLib.c

index 1e6b288b10b91ab9a1d35fe1b2271996365e1ab9..66f3469eb1b5805e6211233bff48b02341111f4e 100644 (file)
@@ -93,7 +93,7 @@ DmaMap (
   *Mapping = Map;\r
 \r
   if ((((UINTN)HostAddress & (gCacheAlignment - 1)) != 0) ||\r
-      ((*NumberOfBytes % gCacheAlignment) != 0)) {\r
+      ((*NumberOfBytes & (gCacheAlignment - 1)) != 0)) {\r
 \r
     // Get the cacheability of the region\r
     Status = gDS->GetMemorySpaceDescriptor (*DeviceAddress, &GcdDescriptor);\r