Subversion Repositories Kolibri OS

Rev

Rev 6102 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. #ifndef _LINUX_DMA_MAPPING_H
  2. #define _LINUX_DMA_MAPPING_H
  3.  
  4. #include <linux/sizes.h>
  5. #include <linux/string.h>
  6. #include <linux/device.h>
  7. #include <linux/err.h>
  8. #include <linux/dma-attrs.h>
  9. #include <linux/dma-direction.h>
  10. #include <linux/scatterlist.h>
  11.  
  12. extern void *
  13. dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle,
  14.                    gfp_t flag);
  15. #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
  16.  
  17. #define DMA_MASK_NONE   0x0ULL
  18.  
  19. static inline int valid_dma_direction(int dma_direction)
  20. {
  21.         return ((dma_direction == DMA_BIDIRECTIONAL) ||
  22.                 (dma_direction == DMA_TO_DEVICE) ||
  23.                 (dma_direction == DMA_FROM_DEVICE));
  24. }
  25.  
  26. static inline int is_device_dma_capable(struct device *dev)
  27. {
  28.         return dev->dma_mask != NULL && *dev->dma_mask != DMA_MASK_NONE;
  29. }
  30.  
  31. #ifdef CONFIG_HAS_DMA
  32. #include <asm/dma-mapping.h>
  33. #else
  34. #include <asm-generic/dma-mapping-broken.h>
  35. #endif
  36. #ifndef dma_max_pfn
  37. static inline unsigned long dma_max_pfn(struct device *dev)
  38. {
  39.         return *dev->dma_mask >> PAGE_SHIFT;
  40. }
  41. #endif
  42.  
  43. static inline void *dma_zalloc_coherent(struct device *dev, size_t size,
  44.                                         dma_addr_t *dma_handle, gfp_t flag)
  45. {
  46.         void *ret = dma_alloc_coherent(dev, size, dma_handle,
  47.                                        flag | __GFP_ZERO);
  48.         return ret;
  49. }
  50.  
  51. #endif
  52.