aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--kernel/dma-coherent.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/kernel/dma-coherent.c b/kernel/dma-coherent.c
index 7517115a8cce..91e96950cd52 100644
--- a/kernel/dma-coherent.c
+++ b/kernel/dma-coherent.c
@@ -77,15 +77,14 @@ void *dma_mark_declared_memory_occupied(struct device *dev,
77{ 77{
78 struct dma_coherent_mem *mem = dev->dma_mem; 78 struct dma_coherent_mem *mem = dev->dma_mem;
79 int pos, err; 79 int pos, err;
80 int pages = (size + (device_addr & ~PAGE_MASK) + PAGE_SIZE - 1);
81 80
82 pages >>= PAGE_SHIFT; 81 size += device_addr & ~PAGE_MASK;
83 82
84 if (!mem) 83 if (!mem)
85 return ERR_PTR(-EINVAL); 84 return ERR_PTR(-EINVAL);
86 85
87 pos = (device_addr - mem->device_base) >> PAGE_SHIFT; 86 pos = (device_addr - mem->device_base) >> PAGE_SHIFT;
88 err = bitmap_allocate_region(mem->bitmap, pos, get_order(pages)); 87 err = bitmap_allocate_region(mem->bitmap, pos, get_order(size));
89 if (err != 0) 88 if (err != 0)
90 return ERR_PTR(err); 89 return ERR_PTR(err);
91 return mem->virt_base + (pos << PAGE_SHIFT); 90 return mem->virt_base + (pos << PAGE_SHIFT);