alloc: simplify align_ptr()

Simplify the align_ptr() function by re-using an existing ALIGN() macro.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
This commit is contained in:
Guennadi Liakhovetski 2020-11-20 10:43:59 +01:00 committed by Liam Girdwood
parent da073fbf80
commit 4316f3c836
1 changed files with 3 additions and 6 deletions

View File

@ -190,17 +190,14 @@ static void *rmalloc_sys(struct mm_heap *heap, uint32_t flags, int caps, size_t
static void *align_ptr(struct mm_heap *heap, uint32_t alignment,
void *ptr, struct block_hdr *hdr)
{
int mod_align = 0;
/* Save unaligned ptr to block hdr */
hdr->unaligned_ptr = ptr;
/* If ptr is not already aligned we calculate alignment shift */
if (alignment && (uintptr_t)ptr % alignment)
mod_align = alignment - ((uintptr_t)ptr % alignment);
if (alignment <= 1)
return ptr;
/* Calculate aligned pointer */
return (char *)ptr + mod_align;
return (void *)ALIGN((uintptr_t)ptr, alignment);
}
/* allocate single block */