diff options
author | Russell King <rmk@dyn-67.arm.linux.org.uk> | 2008-08-10 07:18:26 -0400 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2008-08-10 09:05:14 -0400 |
commit | 9dd428680573d7867ee5e40fa3f059a98301d416 (patch) | |
tree | cedec454e5490d2f09b3cad4b6c2fed46a6f857b /arch/arm/common | |
parent | 98ed7d4b1a4eebc1ac25929b6968673bef4d54c3 (diff) |
[ARM] dma-mapping: provide sync_range APIs
Convert the existing dma_sync_single_for_* APIs to the new range based
APIs, and make the dma_sync_single_for_* API a superset of it.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/common')
-rw-r--r-- | arch/arm/common/dmabounce.c | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/arch/arm/common/dmabounce.c b/arch/arm/common/dmabounce.c index 1ea6482cdf6e..aecc6c3f908f 100644 --- a/arch/arm/common/dmabounce.c +++ b/arch/arm/common/dmabounce.c | |||
@@ -321,9 +321,8 @@ unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size, | |||
321 | } | 321 | } |
322 | } | 322 | } |
323 | 323 | ||
324 | static inline void | 324 | static int sync_single(struct device *dev, dma_addr_t dma_addr, size_t size, |
325 | sync_single(struct device *dev, dma_addr_t dma_addr, size_t size, | 325 | enum dma_data_direction dir) |
326 | enum dma_data_direction dir) | ||
327 | { | 326 | { |
328 | struct dmabounce_device_info *device_info = dev->archdata.dmabounce; | 327 | struct dmabounce_device_info *device_info = dev->archdata.dmabounce; |
329 | struct safe_buffer *buf = NULL; | 328 | struct safe_buffer *buf = NULL; |
@@ -383,8 +382,9 @@ sync_single(struct device *dev, dma_addr_t dma_addr, size_t size, | |||
383 | * No need to sync the safe buffer - it was allocated | 382 | * No need to sync the safe buffer - it was allocated |
384 | * via the coherent allocators. | 383 | * via the coherent allocators. |
385 | */ | 384 | */ |
385 | return 0; | ||
386 | } else { | 386 | } else { |
387 | dma_cache_maint(dma_to_virt(dev, dma_addr), size, dir); | 387 | return 1; |
388 | } | 388 | } |
389 | } | 389 | } |
390 | 390 | ||
@@ -474,25 +474,29 @@ dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nents, | |||
474 | } | 474 | } |
475 | } | 475 | } |
476 | 476 | ||
477 | void | 477 | void dma_sync_single_range_for_cpu(struct device *dev, dma_addr_t dma_addr, |
478 | dma_sync_single_for_cpu(struct device *dev, dma_addr_t dma_addr, size_t size, | 478 | unsigned long offset, size_t size, |
479 | enum dma_data_direction dir) | 479 | enum dma_data_direction dir) |
480 | { | 480 | { |
481 | dev_dbg(dev, "%s(ptr=%p,size=%d,dir=%x)\n", | 481 | dev_dbg(dev, "%s(dma=%#x,off=%#lx,size=%zx,dir=%x)\n", |
482 | __func__, (void *) dma_addr, size, dir); | 482 | __func__, dma_addr, offset, size, dir); |
483 | 483 | ||
484 | sync_single(dev, dma_addr, size, dir); | 484 | if (sync_single(dev, dma_addr, offset + size, dir)) |
485 | dma_cache_maint(dma_to_virt(dev, dma_addr) + offset, size, dir); | ||
485 | } | 486 | } |
487 | EXPORT_SYMBOL(dma_sync_single_range_for_cpu); | ||
486 | 488 | ||
487 | void | 489 | void dma_sync_single_range_for_device(struct device *dev, dma_addr_t dma_addr, |
488 | dma_sync_single_for_device(struct device *dev, dma_addr_t dma_addr, size_t size, | 490 | unsigned long offset, size_t size, |
489 | enum dma_data_direction dir) | 491 | enum dma_data_direction dir) |
490 | { | 492 | { |
491 | dev_dbg(dev, "%s(ptr=%p,size=%d,dir=%x)\n", | 493 | dev_dbg(dev, "%s(dma=%#x,off=%#lx,size=%zx,dir=%x)\n", |
492 | __func__, (void *) dma_addr, size, dir); | 494 | __func__, dma_addr, offset, size, dir); |
493 | 495 | ||
494 | sync_single(dev, dma_addr, size, dir); | 496 | if (sync_single(dev, dma_addr, offset + size, dir)) |
497 | dma_cache_maint(dma_to_virt(dev, dma_addr) + offset, size, dir); | ||
495 | } | 498 | } |
499 | EXPORT_SYMBOL(dma_sync_single_range_for_device); | ||
496 | 500 | ||
497 | void | 501 | void |
498 | dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, int nents, | 502 | dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, int nents, |
@@ -644,8 +648,6 @@ EXPORT_SYMBOL(dma_map_single); | |||
644 | EXPORT_SYMBOL(dma_unmap_single); | 648 | EXPORT_SYMBOL(dma_unmap_single); |
645 | EXPORT_SYMBOL(dma_map_sg); | 649 | EXPORT_SYMBOL(dma_map_sg); |
646 | EXPORT_SYMBOL(dma_unmap_sg); | 650 | EXPORT_SYMBOL(dma_unmap_sg); |
647 | EXPORT_SYMBOL(dma_sync_single_for_cpu); | ||
648 | EXPORT_SYMBOL(dma_sync_single_for_device); | ||
649 | EXPORT_SYMBOL(dma_sync_sg_for_cpu); | 651 | EXPORT_SYMBOL(dma_sync_sg_for_cpu); |
650 | EXPORT_SYMBOL(dma_sync_sg_for_device); | 652 | EXPORT_SYMBOL(dma_sync_sg_for_device); |
651 | EXPORT_SYMBOL(dmabounce_register_dev); | 653 | EXPORT_SYMBOL(dmabounce_register_dev); |