Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
[cris-mirror.git] / arch / arm / include / asm / dma-direct.h
blob5b0a8a421894618e1de3582f31aecf28a47a6abb
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef ASM_ARM_DMA_DIRECT_H
3 #define ASM_ARM_DMA_DIRECT_H 1
5 static inline dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr)
7 unsigned int offset = paddr & ~PAGE_MASK;
8 return pfn_to_dma(dev, __phys_to_pfn(paddr)) + offset;
11 static inline phys_addr_t dma_to_phys(struct device *dev, dma_addr_t dev_addr)
13 unsigned int offset = dev_addr & ~PAGE_MASK;
14 return __pfn_to_phys(dma_to_pfn(dev, dev_addr)) + offset;
17 static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size)
19 u64 limit, mask;
21 if (!dev->dma_mask)
22 return 0;
24 mask = *dev->dma_mask;
26 limit = (mask + 1) & ~mask;
27 if (limit && size > limit)
28 return 0;
30 if ((addr | (addr + size - 1)) & ~mask)
31 return 0;
33 return 1;
36 #endif /* ASM_ARM_DMA_DIRECT_H */