Skip to contentSkip to conversation

dma-coherent: switch to bitmap_zalloc() in dma_init_coherent_memory()

PATCH Applied Yunfeng Ye 2 participants 2 messages May 16, 2020 – Jul 16, 2020 DMA mapping helpers

lore
Share & tools
lore

Yunfeng Ye

author
#0 lore raw

PATCH 1/1 dma-coherent: switch to bitmap_zalloc() in dma_init_coherent_memory()

Switch to bitmap_zalloc() to show clearly in dma_init_coherent_memory().

No functional change.

---
 kernel/dma/coherent.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
kernel/dma/coherent.c +2 -3
index 2a0c4985f38e..794b31e61ca0 100644
@@ -44,7 +44,6 @@ static int dma_init_coherent_memory(phys_addr_t phys_addr,
 	struct dma_coherent_mem *dma_mem = NULL;
 	void *mem_base = NULL;
 	int pages = size >> PAGE_SHIFT;
-	int bitmap_size = BITS_TO_LONGS(pages) * sizeof(long);
 	int ret;
 
 	if (!size) {
@@ -62,7 +61,7 @@ static int dma_init_coherent_memory(phys_addr_t phys_addr,
 		ret = -ENOMEM;
 		goto out;
 	}
-	dma_mem->bitmap = kzalloc(bitmap_size, GFP_KERNEL);
+	dma_mem->bitmap = bitmap_zalloc(pages, GFP_KERNEL);
 	if (!dma_mem->bitmap) {
 		ret = -ENOMEM;
 		goto out;
@@ -90,7 +89,7 @@ static void dma_release_coherent_memory(struct dma_coherent_mem *mem)
 		return;
 
 	memunmap(mem->virt_base);
-	kfree(mem->bitmap);
+	bitmap_free(mem->bitmap);
 	kfree(mem);
 }
 
Signature · 1 line
1.8.3.1