xref: /openbmc/u-boot/include/memalign.h (revision 6e295186c7fc8bf5be22a05f6ca9602f2bb507f2)
1 /*
2  * Copyright (c) 2015 Google, Inc
3  *
4  * SPDX-License-Identifier:    GPL-2.0+
5  */
6 
7 #ifndef __ALIGNMEM_H
8 #define __ALIGNMEM_H
9 
10 /*
11  * ARCH_DMA_MINALIGN is defined in asm/cache.h for each architecture.  It
12  * is used to align DMA buffers.
13  */
14 #ifndef __ASSEMBLY__
15 #include <asm/cache.h>
16 
17 #include <malloc.h>
18 
19 static inline void *malloc_cache_aligned(size_t size)
20 {
21 	return memalign(ARCH_DMA_MINALIGN, ALIGN(size, ARCH_DMA_MINALIGN));
22 }
23 #endif
24 
25 #endif /* __ALIGNMEM_H */
26