iwlwifi: fix dma mappings and skbs leak
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / include / asm-generic / pci-dma-compat.h
blob1437b7da09b251ad79427af493ff4a6b688229f5
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 */
4 #ifndef _ASM_GENERIC_PCI_DMA_COMPAT_H
5 #define _ASM_GENERIC_PCI_DMA_COMPAT_H
7 #include <linux/dma-mapping.h>
9 static inline int
10 pci_dma_supported(struct pci_dev *hwdev, u64 mask)
12 return dma_supported(hwdev == NULL ? NULL : &hwdev->dev, mask);
15 static inline void *
16 pci_alloc_consistent(struct pci_dev *hwdev, size_t size,
17 dma_addr_t *dma_handle)
19 return dma_alloc_coherent(hwdev == NULL ? NULL : &hwdev->dev, size, dma_handle, GFP_ATOMIC);
22 static inline void
23 pci_free_consistent(struct pci_dev *hwdev, size_t size,
24 void *vaddr, dma_addr_t dma_handle)
26 dma_free_coherent(hwdev == NULL ? NULL : &hwdev->dev, size, vaddr, dma_handle);
29 static inline dma_addr_t
30 pci_map_single(struct pci_dev *hwdev, void *ptr, size_t size, int direction)
32 return dma_map_single(hwdev == NULL ? NULL : &hwdev->dev, ptr, size, (enum dma_data_direction)direction);
35 static inline void
36 pci_unmap_single(struct pci_dev *hwdev, dma_addr_t dma_addr,
37 size_t size, int direction)
39 dma_unmap_single(hwdev == NULL ? NULL : &hwdev->dev, dma_addr, size, (enum dma_data_direction)direction);
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)
46 return dma_map_page(hwdev == NULL ? NULL : &hwdev->dev, page, offset, size, (enum dma_data_direction)direction);
49 static inline void
50 pci_unmap_page(struct pci_dev *hwdev, dma_addr_t dma_address,
51 size_t size, int direction)
53 dma_unmap_page(hwdev == NULL ? NULL : &hwdev->dev, dma_address, size, (enum dma_data_direction)direction);
56 static inline int
57 pci_map_sg(struct pci_dev *hwdev, struct scatterlist *sg,
58 int nents, int direction)
60 return dma_map_sg(hwdev == NULL ? NULL : &hwdev->dev, sg, nents, (enum dma_data_direction)direction);
63 static inline void
64 pci_unmap_sg(struct pci_dev *hwdev, struct scatterlist *sg,
65 int nents, int direction)
67 dma_unmap_sg(hwdev == NULL ? NULL : &hwdev->dev, sg, nents, (enum dma_data_direction)direction);
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)
74 dma_sync_single_for_cpu(hwdev == NULL ? NULL : &hwdev->dev, dma_handle, size, (enum dma_data_direction)direction);
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)
81 dma_sync_single_for_device(hwdev == NULL ? NULL : &hwdev->dev, dma_handle, size, (enum dma_data_direction)direction);
84 static inline void
85 pci_dma_sync_sg_for_cpu(struct pci_dev *hwdev, struct scatterlist *sg,
86 int nelems, int direction)
88 dma_sync_sg_for_cpu(hwdev == NULL ? NULL : &hwdev->dev, sg, nelems, (enum dma_data_direction)direction);
91 static inline void
92 pci_dma_sync_sg_for_device(struct pci_dev *hwdev, struct scatterlist *sg,
93 int nelems, int direction)
95 dma_sync_sg_for_device(hwdev == NULL ? NULL : &hwdev->dev, sg, nelems, (enum dma_data_direction)direction);
98 static inline int
99 pci_dma_mapping_error(struct pci_dev *pdev, dma_addr_t dma_addr)
101 return dma_mapping_error(&pdev->dev, dma_addr);
104 #ifdef CONFIG_PCI
105 static inline int pci_set_dma_mask(struct pci_dev *dev, u64 mask)
107 return dma_set_mask(&dev->dev, mask);
110 static inline int pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask)
112 return dma_set_coherent_mask(&dev->dev, mask);
114 #endif
116 #endif