Skip to content

Commit 9fbd8dc

Browse files
tititiou36Christoph Hellwig
authored andcommitted
dma-mapping: use 'bitmap_zalloc()' when applicable
'dma_mem->bitmap' is a bitmap. So use 'bitmap_zalloc()' to simplify code, improve the semantic and avoid some open-coded arithmetic in allocator arguments. Also change the corresponding 'kfree()' into 'bitmap_free()' to keep consistency. Signed-off-by: Christophe JAILLET <[email protected]> Signed-off-by: Christoph Hellwig <[email protected]>
1 parent 7d6db80 commit 9fbd8dc

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

kernel/dma/coherent.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ static struct dma_coherent_mem *dma_init_coherent_memory(phys_addr_t phys_addr,
4040
{
4141
struct dma_coherent_mem *dma_mem;
4242
int pages = size >> PAGE_SHIFT;
43-
int bitmap_size = BITS_TO_LONGS(pages) * sizeof(long);
4443
void *mem_base;
4544

4645
if (!size)
@@ -53,7 +52,7 @@ static struct dma_coherent_mem *dma_init_coherent_memory(phys_addr_t phys_addr,
5352
dma_mem = kzalloc(sizeof(struct dma_coherent_mem), GFP_KERNEL);
5453
if (!dma_mem)
5554
goto out_unmap_membase;
56-
dma_mem->bitmap = kzalloc(bitmap_size, GFP_KERNEL);
55+
dma_mem->bitmap = bitmap_zalloc(pages, GFP_KERNEL);
5756
if (!dma_mem->bitmap)
5857
goto out_free_dma_mem;
5958

@@ -81,7 +80,7 @@ static void dma_release_coherent_memory(struct dma_coherent_mem *mem)
8180
return;
8281

8382
memunmap(mem->virt_base);
84-
kfree(mem->bitmap);
83+
bitmap_free(mem->bitmap);
8584
kfree(mem);
8685
}
8786

0 commit comments

Comments
 (0)