Root/include/asm-generic/pci-dma-compat.h

1/* include this file if the platform implements the dma_ DMA Mapping API
2 * and wants to provide the pci_ DMA Mapping API in terms of it */
3
4#ifndef _ASM_GENERIC_PCI_DMA_COMPAT_H
5#define _ASM_GENERIC_PCI_DMA_COMPAT_H
6
7#include <linux/dma-mapping.h>
8
9static inline int
10pci_dma_supported(struct pci_dev *hwdev, u64 mask)
11{
12    return dma_supported(hwdev == NULL ? NULL : &hwdev->dev, mask);
13}
14
15static inline void *
16pci_alloc_consistent(struct pci_dev *hwdev, size_t size,
17             dma_addr_t *dma_handle)
18{
19    return dma_alloc_coherent(hwdev == NULL ? NULL : &hwdev->dev, size, dma_handle, GFP_ATOMIC);
20}
21
22static inline void
23pci_free_consistent(struct pci_dev *hwdev, size_t size,
24            void *vaddr, dma_addr_t dma_handle)
25{
26    dma_free_coherent(hwdev == NULL ? NULL : &hwdev->dev, size, vaddr, dma_handle);
27}
28
29static inline dma_addr_t
30pci_map_single(struct pci_dev *hwdev, void *ptr, size_t size, int direction)
31{
32    return dma_map_single(hwdev == NULL ? NULL : &hwdev->dev, ptr, size, (enum dma_data_direction)direction);
33}
34
35static inline void
36pci_unmap_single(struct pci_dev *hwdev, dma_addr_t dma_addr,
37         size_t size, int direction)
38{
39    dma_unmap_single(hwdev == NULL ? NULL : &hwdev->dev, dma_addr, size, (enum dma_data_direction)direction);
40}
41
42static inline dma_addr_t
43pci_map_page(struct pci_dev *hwdev, struct page *page,
44         unsigned long offset, size_t size, int direction)
45{
46    return dma_map_page(hwdev == NULL ? NULL : &hwdev->dev, page, offset, size, (enum dma_data_direction)direction);
47}
48
49static inline void
50pci_unmap_page(struct pci_dev *hwdev, dma_addr_t dma_address,
51           size_t size, int direction)
52{
53    dma_unmap_page(hwdev == NULL ? NULL : &hwdev->dev, dma_address, size, (enum dma_data_direction)direction);
54}
55
56static inline int
57pci_map_sg(struct pci_dev *hwdev, struct scatterlist *sg,
58       int nents, int direction)
59{
60    return dma_map_sg(hwdev == NULL ? NULL : &hwdev->dev, sg, nents, (enum dma_data_direction)direction);
61}
62
63static inline void
64pci_unmap_sg(struct pci_dev *hwdev, struct scatterlist *sg,
65         int nents, int direction)
66{
67    dma_unmap_sg(hwdev == NULL ? NULL : &hwdev->dev, sg, nents, (enum dma_data_direction)direction);
68}
69
70static inline void
71pci_dma_sync_single_for_cpu(struct pci_dev *hwdev, dma_addr_t dma_handle,
72            size_t size, int direction)
73{
74    dma_sync_single_for_cpu(hwdev == NULL ? NULL : &hwdev->dev, dma_handle, size, (enum dma_data_direction)direction);
75}
76
77static inline void
78pci_dma_sync_single_for_device(struct pci_dev *hwdev, dma_addr_t dma_handle,
79            size_t size, int direction)
80{
81    dma_sync_single_for_device(hwdev == NULL ? NULL : &hwdev->dev, dma_handle, size, (enum dma_data_direction)direction);
82}
83
84static inline void
85pci_dma_sync_sg_for_cpu(struct pci_dev *hwdev, struct scatterlist *sg,
86        int nelems, int direction)
87{
88    dma_sync_sg_for_cpu(hwdev == NULL ? NULL : &hwdev->dev, sg, nelems, (enum dma_data_direction)direction);
89}
90
91static inline void
92pci_dma_sync_sg_for_device(struct pci_dev *hwdev, struct scatterlist *sg,
93        int nelems, int direction)
94{
95    dma_sync_sg_for_device(hwdev == NULL ? NULL : &hwdev->dev, sg, nelems, (enum dma_data_direction)direction);
96}
97
98static inline int
99pci_dma_mapping_error(struct pci_dev *pdev, dma_addr_t dma_addr)
100{
101    return dma_mapping_error(&pdev->dev, dma_addr);
102}
103
104#ifdef CONFIG_PCI
105static inline int pci_set_dma_mask(struct pci_dev *dev, u64 mask)
106{
107    return dma_set_mask(&dev->dev, mask);
108}
109
110static inline int pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask)
111{
112    return dma_set_coherent_mask(&dev->dev, mask);
113}
114#endif
115
116#endif
117

Archive Download this file



interactive