Commit 9fbd8dc1 authored by Christophe JAILLET's avatar Christophe JAILLET Committed by Christoph Hellwig
Browse files

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: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
parent 7d6db80b
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -40,7 +40,6 @@ static struct dma_coherent_mem *dma_init_coherent_memory(phys_addr_t phys_addr,
{
	struct dma_coherent_mem *dma_mem;
	int pages = size >> PAGE_SHIFT;
	int bitmap_size = BITS_TO_LONGS(pages) * sizeof(long);
	void *mem_base;

	if (!size)
@@ -53,7 +52,7 @@ static struct dma_coherent_mem *dma_init_coherent_memory(phys_addr_t phys_addr,
	dma_mem = kzalloc(sizeof(struct dma_coherent_mem), GFP_KERNEL);
	if (!dma_mem)
		goto out_unmap_membase;
	dma_mem->bitmap = kzalloc(bitmap_size, GFP_KERNEL);
	dma_mem->bitmap = bitmap_zalloc(pages, GFP_KERNEL);
	if (!dma_mem->bitmap)
		goto out_free_dma_mem;

@@ -81,7 +80,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);
}