blob: f78b9dd9dc7c31b16a0a97d97b9170bd27924f7a [file] [log] [blame]
Simon Glass6e295182015-09-02 17:24:57 -06001/*
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
19static 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 */