diff options
| author | James Bottomley <jejb@raven.il.steeleye.com> | 2002-12-21 10:37:49 -0600 |
|---|---|---|
| committer | Linus Torvalds <torvalds@home.transmeta.com> | 2002-12-21 10:37:49 -0600 |
| commit | 1ebad6d8cc190eadc03f76c177a098be233466cf (patch) | |
| tree | cbf840b4c164086a0881bddd3bdb4f7378629573 /include/linux | |
| parent | 011f5659a8cf7e26866157a55e0d59fa208976ef (diff) | |
generic device DMA API
add dma_ API to mirror pci_ DMA API but phrased to use struct
device instead of struct pci_dev.
See Documentation/DMA-API.txt for details
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/dma-mapping.h | 17 | ||||
| -rw-r--r-- | include/linux/pci.h | 87 |
2 files changed, 104 insertions, 0 deletions
diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h new file mode 100644 index 000000000000..9d88549ff2fc --- /dev/null +++ b/include/linux/dma-mapping.h @@ -0,0 +1,17 @@ +#ifndef _ASM_LINUX_DMA_MAPPING_H +#define _ASM_LINUX_DMA_MAPPING_H + +/* These definitions mirror those in pci.h, so they can be used + * interchangeably with their PCI_ counterparts */ +enum dma_data_direction { + DMA_BIDIRECTIONAL = 0, + DMA_TO_DEVICE = 1, + DMA_FROM_DEVICE = 2, + DMA_NONE = 3, +}; + +#include <asm/dma-mapping.h> + +#endif + + diff --git a/include/linux/pci.h b/include/linux/pci.h index 557b17d959c1..b4265360d2ec 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -826,5 +826,92 @@ extern int pci_pci_problems; #define PCIPCI_VIAETBF 8 #define PCIPCI_VSFX 16 +#include <linux/dma-mapping.h> + +/* If you define PCI_NEW_DMA_COMPAT_API it means you support the new DMA API + * and you want the pci_ DMA API to be implemented using it. + */ +#if defined(PCI_NEW_DMA_COMPAT_API) && defined(CONFIG_PCI) + +/* note pci_set_dma_mask isn't here, since it's a public function + * exported from drivers/pci, use dma_supported instead */ + +static inline int +pci_dma_supported(struct pci_dev *hwdev, u64 mask) +{ + return dma_supported(&hwdev->dev, mask); +} + +static inline void * +pci_alloc_consistent(struct pci_dev *hwdev, size_t size, + dma_addr_t *dma_handle) +{ + return dma_alloc_coherent(&hwdev->dev, size, dma_handle); +} + +static inline void +pci_free_consistent(struct pci_dev *hwdev, size_t size, + void *vaddr, dma_addr_t dma_handle) +{ + dma_free_coherent(&hwdev->dev, size, vaddr, dma_handle); +} + +static inline dma_addr_t +pci_map_single(struct pci_dev *hwdev, void *ptr, size_t size, int direction) +{ + return dma_map_single(&hwdev->dev, ptr, size, (enum dma_data_direction)direction); +} + +static inline void +pci_unmap_single(struct pci_dev *hwdev, dma_addr_t dma_addr, + size_t size, int direction) +{ + dma_unmap_single(&hwdev->dev, dma_addr, size, (enum dma_data_direction)direction); +} + +static inline dma_addr_t +pci_map_page(struct pci_dev *hwdev, struct page *page, + unsigned long offset, size_t size, int direction) +{ + return dma_map_page(&hwdev->dev, page, offset, size, (enum dma_data_direction)direction); +} + +static inline void +pci_unmap_page(struct pci_dev *hwdev, dma_addr_t dma_address, + size_t size, int direction) +{ + dma_unmap_page(&hwdev->dev, dma_address, size, (enum dma_data_direction)direction); +} + +static inline int +pci_map_sg(struct pci_dev *hwdev, struct scatterlist *sg, + int nents, int direction) +{ + return dma_map_sg(&hwdev->dev, sg, nents, (enum dma_data_direction)direction); +} + +static inline void +pci_unmap_sg(struct pci_dev *hwdev, struct scatterlist *sg, + int nents, int direction) +{ + dma_unmap_sg(&hwdev->dev, sg, nents, (enum dma_data_direction)direction); +} + +static inline void +pci_dma_sync_single(struct pci_dev *hwdev, dma_addr_t dma_handle, + size_t size, int direction) +{ + dma_sync_single(&hwdev->dev, dma_handle, size, (enum dma_data_direction)direction); +} + +static inline void +pci_dma_sync_sg(struct pci_dev *hwdev, struct scatterlist *sg, + int nelems, int direction) +{ + dma_sync_sg(&hwdev->dev, sg, nelems, (enum dma_data_direction)direction); +} + +#endif + #endif /* __KERNEL__ */ #endif /* LINUX_PCI_H */ |
