diff options
Diffstat (limited to 'include/asm-generic/pci-dma-compat.h')
-rw-r--r-- | include/asm-generic/pci-dma-compat.h | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/include/asm-generic/pci-dma-compat.h b/include/asm-generic/pci-dma-compat.h new file mode 100644 index 000000000000..25c10e96b2b7 --- /dev/null +++ b/include/asm-generic/pci-dma-compat.h | |||
@@ -0,0 +1,107 @@ | |||
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 | |||
9 | /* note pci_set_dma_mask isn't here, since it's a public function | ||
10 | * exported from drivers/pci, use dma_supported instead */ | ||
11 | |||
12 | static inline int | ||
13 | pci_dma_supported(struct pci_dev *hwdev, u64 mask) | ||
14 | { | ||
15 | return dma_supported(hwdev == NULL ? NULL : &hwdev->dev, mask); | ||
16 | } | ||
17 | |||
18 | static inline void * | ||
19 | pci_alloc_consistent(struct pci_dev *hwdev, size_t size, | ||
20 | dma_addr_t *dma_handle) | ||
21 | { | ||
22 | return dma_alloc_coherent(hwdev == NULL ? NULL : &hwdev->dev, size, dma_handle, GFP_ATOMIC); | ||
23 | } | ||
24 | |||
25 | static inline void | ||
26 | pci_free_consistent(struct pci_dev *hwdev, size_t size, | ||
27 | void *vaddr, dma_addr_t dma_handle) | ||
28 | { | ||
29 | dma_free_coherent(hwdev == NULL ? NULL : &hwdev->dev, size, vaddr, dma_handle); | ||
30 | } | ||
31 | |||
32 | static inline dma_addr_t | ||
33 | pci_map_single(struct pci_dev *hwdev, void *ptr, size_t size, int direction) | ||
34 | { | ||
35 | return dma_map_single(hwdev == NULL ? NULL : &hwdev->dev, ptr, size, (enum dma_data_direction)direction); | ||
36 | } | ||
37 | |||
38 | static inline void | ||
39 | pci_unmap_single(struct pci_dev *hwdev, dma_addr_t dma_addr, | ||
40 | size_t size, int direction) | ||
41 | { | ||
42 | dma_unmap_single(hwdev == NULL ? NULL : &hwdev->dev, dma_addr, size, (enum dma_data_direction)direction); | ||
43 | } | ||
44 | |||
45 | static inline dma_addr_t | ||
46 | pci_map_page(struct pci_dev *hwdev, struct page *page, | ||
47 | unsigned long offset, size_t size, int direction) | ||
48 | { | ||
49 | return dma_map_page(hwdev == NULL ? NULL : &hwdev->dev, page, offset, size, (enum dma_data_direction)direction); | ||
50 | } | ||
51 | |||
52 | static inline void | ||
53 | pci_unmap_page(struct pci_dev *hwdev, dma_addr_t dma_address, | ||
54 | size_t size, int direction) | ||
55 | { | ||
56 | dma_unmap_page(hwdev == NULL ? NULL : &hwdev->dev, dma_address, size, (enum dma_data_direction)direction); | ||
57 | } | ||
58 | |||
59 | static inline int | ||
60 | pci_map_sg(struct pci_dev *hwdev, struct scatterlist *sg, | ||
61 | int nents, int direction) | ||
62 | { | ||
63 | return dma_map_sg(hwdev == NULL ? NULL : &hwdev->dev, sg, nents, (enum dma_data_direction)direction); | ||
64 | } | ||
65 | |||
66 | static inline void | ||
67 | pci_unmap_sg(struct pci_dev *hwdev, struct scatterlist *sg, | ||
68 | int nents, int direction) | ||
69 | { | ||
70 | dma_unmap_sg(hwdev == NULL ? NULL : &hwdev->dev, sg, nents, (enum dma_data_direction)direction); | ||
71 | } | ||
72 | |||
73 | static inline void | ||
74 | pci_dma_sync_single_for_cpu(struct pci_dev *hwdev, dma_addr_t dma_handle, | ||
75 | size_t size, int direction) | ||
76 | { | ||
77 | dma_sync_single_for_cpu(hwdev == NULL ? NULL : &hwdev->dev, dma_handle, size, (enum dma_data_direction)direction); | ||
78 | } | ||
79 | |||
80 | static inline void | ||
81 | pci_dma_sync_single_for_device(struct pci_dev *hwdev, dma_addr_t dma_handle, | ||
82 | size_t size, int direction) | ||
83 | { | ||
84 | dma_sync_single_for_device(hwdev == NULL ? NULL : &hwdev->dev, dma_handle, size, (enum dma_data_direction)direction); | ||
85 | } | ||
86 | |||
87 | static inline void | ||
88 | pci_dma_sync_sg_for_cpu(struct pci_dev *hwdev, struct scatterlist *sg, | ||
89 | int nelems, int direction) | ||
90 | { | ||
91 | dma_sync_sg_for_cpu(hwdev == NULL ? NULL : &hwdev->dev, sg, nelems, (enum dma_data_direction)direction); | ||
92 | } | ||
93 | |||
94 | static inline void | ||
95 | pci_dma_sync_sg_for_device(struct pci_dev *hwdev, struct scatterlist *sg, | ||
96 | int nelems, int direction) | ||
97 | { | ||
98 | dma_sync_sg_for_device(hwdev == NULL ? NULL : &hwdev->dev, sg, nelems, (enum dma_data_direction)direction); | ||
99 | } | ||
100 | |||
101 | static inline int | ||
102 | pci_dma_mapping_error(dma_addr_t dma_addr) | ||
103 | { | ||
104 | return dma_mapping_error(dma_addr); | ||
105 | } | ||
106 | |||
107 | #endif | ||