Commit cb5ae60f authored by Michael Hennerich's avatar Michael Hennerich Committed by Mike Frysinger

Blackfin: convert DMA code to a proper bitmap

Rather than using our own data structures that basically boil down to a
bitmap, use the standard bitmap functions.
Reported-by: default avatarPaul Mundt <lethal@linux-sh.org>
Signed-off-by: default avatarMichael Hennerich <michael.hennerich@analog.com>
Signed-off-by: default avatarMike Frysinger <vapier@gentoo.org>
parent ddcd7cb8
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
#include <asm/bfin-global.h> #include <asm/bfin-global.h>
static spinlock_t dma_page_lock; static spinlock_t dma_page_lock;
static unsigned int *dma_page; static unsigned long *dma_page;
static unsigned int dma_pages; static unsigned int dma_pages;
static unsigned long dma_base; static unsigned long dma_base;
static unsigned long dma_size; static unsigned long dma_size;
...@@ -30,7 +30,7 @@ void dma_alloc_init(unsigned long start, unsigned long end) ...@@ -30,7 +30,7 @@ void dma_alloc_init(unsigned long start, unsigned long end)
spin_lock_init(&dma_page_lock); spin_lock_init(&dma_page_lock);
dma_initialized = 0; dma_initialized = 0;
dma_page = (unsigned int *)__get_free_page(GFP_KERNEL); dma_page = (unsigned long *)__get_free_page(GFP_KERNEL);
memset(dma_page, 0, PAGE_SIZE); memset(dma_page, 0, PAGE_SIZE);
dma_base = PAGE_ALIGN(start); dma_base = PAGE_ALIGN(start);
dma_size = PAGE_ALIGN(end) - PAGE_ALIGN(start); dma_size = PAGE_ALIGN(end) - PAGE_ALIGN(start);
...@@ -58,10 +58,11 @@ static unsigned long __alloc_dma_pages(unsigned int pages) ...@@ -58,10 +58,11 @@ static unsigned long __alloc_dma_pages(unsigned int pages)
spin_lock_irqsave(&dma_page_lock, flags); spin_lock_irqsave(&dma_page_lock, flags);
for (i = 0; i < dma_pages;) { for (i = 0; i < dma_pages;) {
if (dma_page[i++] == 0) { if (test_bit(i++, dma_page) == 0) {
if (++count == pages) { if (++count == pages) {
while (count--) while (count--)
dma_page[--i] = 1; __set_bit(--i, dma_page);
ret = dma_base + (i << PAGE_SHIFT); ret = dma_base + (i << PAGE_SHIFT);
break; break;
} }
...@@ -84,9 +85,9 @@ static void __free_dma_pages(unsigned long addr, unsigned int pages) ...@@ -84,9 +85,9 @@ static void __free_dma_pages(unsigned long addr, unsigned int pages)
} }
spin_lock_irqsave(&dma_page_lock, flags); spin_lock_irqsave(&dma_page_lock, flags);
for (i = page; i < page + pages; i++) { for (i = page; i < page + pages; i++)
dma_page[i] = 0; __clear_bit(i, dma_page);
}
spin_unlock_irqrestore(&dma_page_lock, flags); spin_unlock_irqrestore(&dma_page_lock, flags);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment