dma-mapping.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #ifndef _ASM_S390_DMA_MAPPING_H
  2. #define _ASM_S390_DMA_MAPPING_H
  3. #include <linux/kernel.h>
  4. #include <linux/types.h>
  5. #include <linux/mm.h>
  6. #include <linux/scatterlist.h>
  7. #include <linux/dma-attrs.h>
  8. #include <linux/dma-debug.h>
  9. #include <linux/io.h>
  10. #define DMA_ERROR_CODE (~(dma_addr_t) 0x0)
  11. extern struct dma_map_ops s390_dma_ops;
  12. static inline struct dma_map_ops *get_dma_ops(struct device *dev)
  13. {
  14. return &s390_dma_ops;
  15. }
  16. extern int dma_set_mask(struct device *dev, u64 mask);
  17. static inline void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
  18. enum dma_data_direction direction)
  19. {
  20. }
  21. #define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
  22. #define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
  23. #include <asm-generic/dma-mapping-common.h>
  24. static inline int dma_supported(struct device *dev, u64 mask)
  25. {
  26. struct dma_map_ops *dma_ops = get_dma_ops(dev);
  27. if (dma_ops->dma_supported == NULL)
  28. return 1;
  29. return dma_ops->dma_supported(dev, mask);
  30. }
  31. static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size)
  32. {
  33. if (!dev->dma_mask)
  34. return 0;
  35. return addr + size - 1 <= *dev->dma_mask;
  36. }
  37. static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
  38. {
  39. struct dma_map_ops *dma_ops = get_dma_ops(dev);
  40. if (dma_ops->mapping_error)
  41. return dma_ops->mapping_error(dev, dma_addr);
  42. return (dma_addr == 0UL);
  43. }
  44. static inline void *dma_alloc_coherent(struct device *dev, size_t size,
  45. dma_addr_t *dma_handle, gfp_t flag)
  46. {
  47. struct dma_map_ops *ops = get_dma_ops(dev);
  48. void *ret;
  49. ret = ops->alloc(dev, size, dma_handle, flag, NULL);
  50. debug_dma_alloc_coherent(dev, size, *dma_handle, ret);
  51. return ret;
  52. }
  53. static inline void dma_free_coherent(struct device *dev, size_t size,
  54. void *cpu_addr, dma_addr_t dma_handle)
  55. {
  56. struct dma_map_ops *dma_ops = get_dma_ops(dev);
  57. dma_ops->free(dev, size, cpu_addr, dma_handle, NULL);
  58. debug_dma_free_coherent(dev, size, cpu_addr, dma_handle);
  59. }
  60. #endif /* _ASM_S390_DMA_MAPPING_H */