diff options
author | Russell King <rmk+kernel@arm.linux.org.uk> | 2011-01-02 19:00:17 -0500 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2011-01-03 06:27:43 -0500 |
commit | 9eedd96301cad8ab58ee8c1e579677d0a75c2ba1 (patch) | |
tree | 87f5ebbbd5769516771bef37574b39464177f496 /arch/arm/include/asm/dma-mapping.h | |
parent | 3d29005ab8d828e36108ecc2338612ce3acdd86f (diff) |
ARM: DMA: Replace page_to_dma()/dma_to_page() with pfn_to_dma()/dma_to_pfn()
Replace the page_to_dma() and dma_to_page() macros with their PFN
equivalents. This allows us to map parts of memory which do not have
a struct page allocated to them to bus addresses. This will be used
internally by dma_alloc_coherent()/dma_alloc_writecombine().
Build tested on Versatile, OMAP1, IOP13xx and KS8695.
Tested-by: Janusz Krzysztofik <jkrzyszt@tis.icnet.pl>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/include/asm/dma-mapping.h')
-rw-r--r-- | arch/arm/include/asm/dma-mapping.h | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/arch/arm/include/asm/dma-mapping.h b/arch/arm/include/asm/dma-mapping.h index c568da7dcae4..8f69b98f68fc 100644 --- a/arch/arm/include/asm/dma-mapping.h +++ b/arch/arm/include/asm/dma-mapping.h | |||
@@ -9,20 +9,24 @@ | |||
9 | #include <asm-generic/dma-coherent.h> | 9 | #include <asm-generic/dma-coherent.h> |
10 | #include <asm/memory.h> | 10 | #include <asm/memory.h> |
11 | 11 | ||
12 | #ifdef __arch_page_to_dma | ||
13 | #error Please update to __arch_pfn_to_dma | ||
14 | #endif | ||
15 | |||
12 | /* | 16 | /* |
13 | * page_to_dma/dma_to_virt/virt_to_dma are architecture private functions | 17 | * dma_to_pfn/pfn_to_dma/dma_to_virt/virt_to_dma are architecture private |
14 | * used internally by the DMA-mapping API to provide DMA addresses. They | 18 | * functions used internally by the DMA-mapping API to provide DMA |
15 | * must not be used by drivers. | 19 | * addresses. They must not be used by drivers. |
16 | */ | 20 | */ |
17 | #ifndef __arch_page_to_dma | 21 | #ifndef __arch_pfn_to_dma |
18 | static inline dma_addr_t page_to_dma(struct device *dev, struct page *page) | 22 | static inline dma_addr_t pfn_to_dma(struct device *dev, unsigned long pfn) |
19 | { | 23 | { |
20 | return (dma_addr_t)__pfn_to_bus(page_to_pfn(page)); | 24 | return (dma_addr_t)__pfn_to_bus(pfn); |
21 | } | 25 | } |
22 | 26 | ||
23 | static inline struct page *dma_to_page(struct device *dev, dma_addr_t addr) | 27 | static inline unsigned long dma_to_pfn(struct device *dev, dma_addr_t addr) |
24 | { | 28 | { |
25 | return pfn_to_page(__bus_to_pfn(addr)); | 29 | return __bus_to_pfn(addr); |
26 | } | 30 | } |
27 | 31 | ||
28 | static inline void *dma_to_virt(struct device *dev, dma_addr_t addr) | 32 | static inline void *dma_to_virt(struct device *dev, dma_addr_t addr) |
@@ -35,14 +39,14 @@ static inline dma_addr_t virt_to_dma(struct device *dev, void *addr) | |||
35 | return (dma_addr_t)__virt_to_bus((unsigned long)(addr)); | 39 | return (dma_addr_t)__virt_to_bus((unsigned long)(addr)); |
36 | } | 40 | } |
37 | #else | 41 | #else |
38 | static inline dma_addr_t page_to_dma(struct device *dev, struct page *page) | 42 | static inline dma_addr_t pfn_to_dma(struct device *dev, unsigned long pfn) |
39 | { | 43 | { |
40 | return __arch_page_to_dma(dev, page); | 44 | return __arch_pfn_to_dma(dev, pfn); |
41 | } | 45 | } |
42 | 46 | ||
43 | static inline struct page *dma_to_page(struct device *dev, dma_addr_t addr) | 47 | static inline unsigned long dma_to_pfn(struct device *dev, dma_addr_t addr) |
44 | { | 48 | { |
45 | return __arch_dma_to_page(dev, addr); | 49 | return __arch_dma_to_pfn(dev, addr); |
46 | } | 50 | } |
47 | 51 | ||
48 | static inline void *dma_to_virt(struct device *dev, dma_addr_t addr) | 52 | static inline void *dma_to_virt(struct device *dev, dma_addr_t addr) |
@@ -368,7 +372,7 @@ static inline dma_addr_t dma_map_page(struct device *dev, struct page *page, | |||
368 | 372 | ||
369 | __dma_page_cpu_to_dev(page, offset, size, dir); | 373 | __dma_page_cpu_to_dev(page, offset, size, dir); |
370 | 374 | ||
371 | return page_to_dma(dev, page) + offset; | 375 | return pfn_to_dma(dev, page_to_pfn(page)) + offset; |
372 | } | 376 | } |
373 | 377 | ||
374 | /** | 378 | /** |
@@ -408,8 +412,8 @@ static inline void dma_unmap_single(struct device *dev, dma_addr_t handle, | |||
408 | static inline void dma_unmap_page(struct device *dev, dma_addr_t handle, | 412 | static inline void dma_unmap_page(struct device *dev, dma_addr_t handle, |
409 | size_t size, enum dma_data_direction dir) | 413 | size_t size, enum dma_data_direction dir) |
410 | { | 414 | { |
411 | __dma_page_dev_to_cpu(dma_to_page(dev, handle), handle & ~PAGE_MASK, | 415 | __dma_page_dev_to_cpu(pfn_to_page(dma_to_pfn(dev, handle)), |
412 | size, dir); | 416 | handle & ~PAGE_MASK, size, dir); |
413 | } | 417 | } |
414 | #endif /* CONFIG_DMABOUNCE */ | 418 | #endif /* CONFIG_DMABOUNCE */ |
415 | 419 | ||