From dd0ab21370a678e41f7f7dd711ff89745ca26db8 Mon Sep 17 00:00:00 2001 From: Shiraz Hashim Date: Sat, 12 Sep 2015 12:31:10 +0530 Subject: [PATCH] drivers: dma-removed: align size first Align size first and then find required number of bits and order out of it. Change-Id: I9b12fb45e5c1ff79e24fe7584cd23923b1a88c87 Signed-off-by: Shiraz Hashim --- drivers/base/dma-removed.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/base/dma-removed.c b/drivers/base/dma-removed.c index 0763e8db41bd..0da44ded61db 100644 --- a/drivers/base/dma-removed.c +++ b/drivers/base/dma-removed.c @@ -79,17 +79,19 @@ void *removed_alloc(struct device *dev, size_t size, dma_addr_t *handle, attrs); bool skip_zeroing = dma_get_attr(DMA_ATTR_SKIP_ZEROING, attrs); int pageno; - unsigned long order = get_order(size); + unsigned long order; void *addr = NULL; struct removed_region *dma_mem = dev->removed_mem; - int nbits = size >> PAGE_SHIFT; + int nbits; unsigned int align; - size = PAGE_ALIGN(size); - if (!(gfp & __GFP_WAIT)) return NULL; + size = PAGE_ALIGN(size); + nbits = size >> PAGE_SHIFT; + order = get_order(size); + if (order > get_order(SZ_1M)) order = get_order(SZ_1M);