Simon Glass | 6e29518 | 2015-09-02 17:24:57 -0600 | [diff] [blame^] | 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 */ |