lkml.org 
[lkml]   [2018]   [Sep]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 2/3] dma-mapping: simplify dma_direct get_required_mask
Date
If we use fls64 we don't need to divide the max address into lower
and upper halves.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
drivers/base/platform.c | 18 +++---------------
1 file changed, 3 insertions(+), 15 deletions(-)

diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index a255fc8aa483..7812b861b6da 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -1185,21 +1185,9 @@ int __init platform_bus_init(void)
*/
u64 dma_direct_get_required_mask(struct device *dev)
{
- u32 low_totalram = ((max_pfn - 1) << PAGE_SHIFT);
- u32 high_totalram = ((max_pfn - 1) >> (32 - PAGE_SHIFT));
- u64 mask;
-
- if (!high_totalram) {
- /* convert to mask just covering totalram */
- low_totalram = (1 << (fls(low_totalram) - 1));
- low_totalram += low_totalram - 1;
- mask = low_totalram;
- } else {
- high_totalram = (1 << (fls(high_totalram) - 1));
- high_totalram += high_totalram - 1;
- mask = (((u64)high_totalram) << 32) + 0xffffffff;
- }
- return mask;
+ u64 end = ((max_pfn - 1) << PAGE_SHIFT);
+
+ return (1 << (fls64(end) - 1)) * 2 - 1;
}

#ifndef ARCH_HAS_DMA_GET_REQUIRED_MASK
--
2.18.0
\
 
 \ /
  Last update: 2018-09-10 08:14    [W:0.051 / U:2.364 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site