summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell King <rmk@arm.linux.org.uk>2012-10-23 14:17:45 +0100
committerRussell King <rmk@arm.linux.org.uk>2012-10-23 14:17:45 +0100
commit720003e70b07bffdae677d501f6063bd1da2125b (patch)
treef54b24259a6cd74a4b24bd284c8202a5d75ee467
parent45d2123133c0918a5cfd301457a2301995edd688 (diff)
Convert to use bmm_malloc_aligned()
The bmm subsystem can now provide us with pre-aligned memory allocations, so let's use the new interface to avoid having to do our own alignment in the vmeta library.
-rw-r--r--vmeta_lib.c23
1 files changed, 5 insertions, 18 deletions
diff --git a/vmeta_lib.c b/vmeta_lib.c
index 8d5bb96..81a8abc 100644
--- a/vmeta_lib.c
+++ b/vmeta_lib.c
@@ -163,39 +163,26 @@ void *vdec_os_api_vmalloc(UNSG32 size, UNSG32 align)
void vdec_os_api_dma_free(void *ptr)
{
- unsigned int offset;
- unsigned int *paddr;
-
- paddr = ptr;
- offset = *(paddr - 1);
- paddr = (unsigned int *)((unsigned int)paddr - offset);
- bmm_free((void *)paddr);
+ bmm_free(ptr);
}
static void *vmeta_bmm_malloc_aligned(UNSG32 size, UNSG32 align, UNSG32 *phys, int attr)
{
- unsigned int tmp, *ptr;
+ void *ptr;
if (size == 0)
return NULL;
- dbg_printf(VDEC_DEBUG_MEM, "%s: size 0x%x attr %u\n",
- __FUNCTION__, size, attr);
+ dbg_printf(VDEC_DEBUG_MEM, "%s: size 0x%x attr %u align %u\n",
+ __FUNCTION__, size, attr, align);
- align = ALIGN(align, sizeof(int));
- size += align;
- ptr = bmm_malloc(size, attr);
+ ptr = bmm_malloc_aligned(size, attr, align);
if (!ptr) {
dbg_printf(VDEC_DEBUG_MEM, "%s: not enough memory\n",
__FUNCTION__);
return NULL;
}
- tmp = (unsigned int)((unsigned int)(ptr) & (align - 1));
- tmp = (unsigned int)(align - tmp);
- ptr = (unsigned int *)((unsigned int)ptr + tmp);
- *(ptr - 1) = tmp;
-
*phys = (UNSG32)bmm_get_paddr(ptr);
dbg_printf(VDEC_DEBUG_MEM, "%s: ptr: 0x%x\n", __FUNCTION__, ptr);