blob: 25c10e96b2b794099ead8769dad4b5f8146a19ba [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/* 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
12static inline int
13pci_dma_supported(struct pci_dev *hwdev, u64 mask)
14{
15 return dma_supported(hwdev == NULL ? NULL : &hwdev->dev, mask);
16}
17
18static inline void *
19pci_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
25static inline void
26pci_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
32static inline dma_addr_t
33pci_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
38static inline void
39pci_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
45static inline dma_addr_t
46pci_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
52static inline void
53pci_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
59static inline int
60pci_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
66static inline void
67pci_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
73static inline void
74pci_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
80static inline void
81pci_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
87static inline void
88pci_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
94static inline void
95pci_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
101static inline int
102pci_dma_mapping_error(dma_addr_t dma_addr)
103{
104 return dma_mapping_error(dma_addr);
105}
106
107#endif