pci-dma-compat.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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. #ifndef _ASM_GENERIC_PCI_DMA_COMPAT_H
  4. #define _ASM_GENERIC_PCI_DMA_COMPAT_H
  5. #include <linux/dma-mapping.h>
  6. static inline int
  7. pci_dma_supported(struct pci_dev *hwdev, u64 mask)
  8. {
  9. return dma_supported(hwdev == NULL ? NULL : &hwdev->dev, mask);
  10. }
  11. static inline void *
  12. pci_alloc_consistent(struct pci_dev *hwdev, size_t size,
  13. dma_addr_t *dma_handle)
  14. {
  15. return dma_alloc_coherent(hwdev == NULL ? NULL : &hwdev->dev, size, dma_handle, GFP_ATOMIC);
  16. }
  17. static inline void
  18. pci_free_consistent(struct pci_dev *hwdev, size_t size,
  19. void *vaddr, dma_addr_t dma_handle)
  20. {
  21. dma_free_coherent(hwdev == NULL ? NULL : &hwdev->dev, size, vaddr, dma_handle);
  22. }
  23. static inline dma_addr_t
  24. pci_map_single(struct pci_dev *hwdev, void *ptr, size_t size, int direction)
  25. {
  26. return dma_map_single(hwdev == NULL ? NULL : &hwdev->dev, ptr, size, (enum dma_data_direction)direction);
  27. }
  28. static inline void
  29. pci_unmap_single(struct pci_dev *hwdev, dma_addr_t dma_addr,
  30. size_t size, int direction)
  31. {
  32. dma_unmap_single(hwdev == NULL ? NULL : &hwdev->dev, dma_addr, size, (enum dma_data_direction)direction);
  33. }
  34. static inline dma_addr_t
  35. pci_map_page(struct pci_dev *hwdev, struct page *page,
  36. unsigned long offset, size_t size, int direction)
  37. {
  38. return dma_map_page(hwdev == NULL ? NULL : &hwdev->dev, page, offset, size, (enum dma_data_direction)direction);
  39. }
  40. static inline void
  41. pci_unmap_page(struct pci_dev *hwdev, dma_addr_t dma_address,
  42. size_t size, int direction)
  43. {
  44. dma_unmap_page(hwdev == NULL ? NULL : &hwdev->dev, dma_address, size, (enum dma_data_direction)direction);
  45. }
  46. static inline int
  47. pci_map_sg(struct pci_dev *hwdev, struct scatterlist *sg,
  48. int nents, int direction)
  49. {
  50. return dma_map_sg(hwdev == NULL ? NULL : &hwdev->dev, sg, nents, (enum dma_data_direction)direction);
  51. }
  52. static inline void
  53. pci_unmap_sg(struct pci_dev *hwdev, struct scatterlist *sg,
  54. int nents, int direction)
  55. {
  56. dma_unmap_sg(hwdev == NULL ? NULL : &hwdev->dev, sg, nents, (enum dma_data_direction)direction);
  57. }
  58. static inline void
  59. pci_dma_sync_single_for_cpu(struct pci_dev *hwdev, dma_addr_t dma_handle,
  60. size_t size, int direction)
  61. {
  62. dma_sync_single_for_cpu(hwdev == NULL ? NULL : &hwdev->dev, dma_handle, size, (enum dma_data_direction)direction);
  63. }
  64. static inline void
  65. pci_dma_sync_single_for_device(struct pci_dev *hwdev, dma_addr_t dma_handle,
  66. size_t size, int direction)
  67. {
  68. dma_sync_single_for_device(hwdev == NULL ? NULL : &hwdev->dev, dma_handle, size, (enum dma_data_direction)direction);
  69. }
  70. static inline void
  71. pci_dma_sync_sg_for_cpu(struct pci_dev *hwdev, struct scatterlist *sg,
  72. int nelems, int direction)
  73. {
  74. dma_sync_sg_for_cpu(hwdev == NULL ? NULL : &hwdev->dev, sg, nelems, (enum dma_data_direction)direction);
  75. }
  76. static inline void
  77. pci_dma_sync_sg_for_device(struct pci_dev *hwdev, struct scatterlist *sg,
  78. int nelems, int direction)
  79. {
  80. dma_sync_sg_for_device(hwdev == NULL ? NULL : &hwdev->dev, sg, nelems, (enum dma_data_direction)direction);
  81. }
  82. static inline int
  83. pci_dma_mapping_error(struct pci_dev *pdev, dma_addr_t dma_addr)
  84. {
  85. return dma_mapping_error(&pdev->dev, dma_addr);
  86. }
  87. #ifdef CONFIG_PCI
  88. static inline int pci_set_dma_mask(struct pci_dev *dev, u64 mask)
  89. {
  90. return dma_set_mask(&dev->dev, mask);
  91. }
  92. static inline int pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask)
  93. {
  94. return dma_set_coherent_mask(&dev->dev, mask);
  95. }
  96. #endif
  97. #endif