Messages in this thread Patch in this message | | | From | Christoph Hellwig <> | Subject | [PATCH 2/3] dma-mapping: simplify dma_direct get_required_mask | Date | Mon, 10 Sep 2018 08:13:31 +0200 |
| |
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
| |