Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
pci-dma-compat.h
Go to the documentation of this file.
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 static inline int
10 pci_dma_supported(struct pci_dev *hwdev, u64 mask)
11 {
12  return dma_supported(hwdev == NULL ? NULL : &hwdev->dev, mask);
13 }
14 
15 static inline void *
16 pci_alloc_consistent(struct pci_dev *hwdev, size_t size,
18 {
19  return dma_alloc_coherent(hwdev == NULL ? NULL : &hwdev->dev, size, dma_handle, GFP_ATOMIC);
20 }
21 
22 static inline void
23 pci_free_consistent(struct pci_dev *hwdev, size_t size,
25 {
26  dma_free_coherent(hwdev == NULL ? NULL : &hwdev->dev, size, vaddr, dma_handle);
27 }
28 
29 static inline dma_addr_t
30 pci_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 
35 static inline void
36 pci_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 
42 static inline dma_addr_t
43 pci_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 
49 static inline void
50 pci_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 
56 static inline int
57 pci_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 
63 static inline void
64 pci_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 
70 static inline void
71 pci_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 
77 static inline void
78 pci_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 
84 static inline void
85 pci_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 
91 static inline void
92 pci_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 
98 static inline int
99 pci_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
105 static inline int pci_set_dma_mask(struct pci_dev *dev, u64 mask)
106 {
107  return dma_set_mask(&dev->dev, mask);
108 }
109 
110 static 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