aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm
diff options
context:
space:
mode:
authorRussell King <rmk@dyn-67.arm.linux.org.uk>2008-09-25 16:38:41 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2008-09-29 05:40:16 -0400
commit2638b4dbe768aba023a06acd8e7eba708bb76ee6 (patch)
tree41e464b337ec85444d8c551947de13bb8731af70 /arch/arm
parent01135d92c1a540cd3370f7cf3d1c762320b85034 (diff)
[ARM] dma: Reduce to one dma_sync_sg_* implementation
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm')
-rw-r--r--arch/arm/common/dmabounce.c48
-rw-r--r--arch/arm/include/asm/dma-mapping.h11
-rw-r--r--arch/arm/mm/dma-mapping.c10
3 files changed, 31 insertions, 38 deletions
diff --git a/arch/arm/common/dmabounce.c b/arch/arm/common/dmabounce.c
index 20d967376fa9..0a98148279b1 100644
--- a/arch/arm/common/dmabounce.c
+++ b/arch/arm/common/dmabounce.c
@@ -468,45 +468,23 @@ void dma_sync_single_range_for_device(struct device *dev, dma_addr_t dma_addr,
468} 468}
469EXPORT_SYMBOL(dma_sync_single_range_for_device); 469EXPORT_SYMBOL(dma_sync_single_range_for_device);
470 470
471void 471int dmabounce_sync_for_cpu(struct device *dev, dma_addr_t addr,
472dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, int nents, 472 unsigned long off, size_t sz, enum dma_data_direction dir)
473 enum dma_data_direction dir)
474{ 473{
475 struct scatterlist *s; 474 dev_dbg(dev, "%s(dma=%#lx,off=%#lx,sz=%zx,dir=%x)\n",
476 int i; 475 __func__, addr, off, sz, dir);
477 476 return sync_single(dev, addr, off + sz, dir);
478 dev_dbg(dev, "%s(sg=%p,nents=%d,dir=%x)\n",
479 __func__, sg, nents, dir);
480
481 BUG_ON(dir == DMA_NONE);
482
483 for_each_sg(sg, s, nents, i) {
484 dma_addr_t dma_addr = s->dma_address;
485 unsigned int length = s->length;
486
487 sync_single(dev, dma_addr, length, dir);
488 }
489} 477}
478EXPORT_SYMBOL(dmabounce_sync_for_cpu);
490 479
491void 480int dmabounce_sync_for_device(struct device *dev, dma_addr_t addr,
492dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, int nents, 481 unsigned long off, size_t sz, enum dma_data_direction dir)
493 enum dma_data_direction dir)
494{ 482{
495 struct scatterlist *s; 483 dev_dbg(dev, "%s(dma=%#lx,off=%#lx,sz=%zx,dir=%x)\n",
496 int i; 484 __func__, addr, off, sz, dir);
497 485 return sync_single(dev, addr, off + sz, dir);
498 dev_dbg(dev, "%s(sg=%p,nents=%d,dir=%x)\n",
499 __func__, sg, nents, dir);
500
501 BUG_ON(dir == DMA_NONE);
502
503 for_each_sg(sg, s, nents, i) {
504 dma_addr_t dma_addr = s->dma_address;
505 unsigned int length = s->length;
506
507 sync_single(dev, dma_addr, length, dir);
508 }
509} 486}
487EXPORT_SYMBOL(dmabounce_sync_for_device);
510 488
511static int 489static int
512dmabounce_init_pool(struct dmabounce_pool *pool, struct device *dev, const char *name, 490dmabounce_init_pool(struct dmabounce_pool *pool, struct device *dev, const char *name,
@@ -618,8 +596,6 @@ dmabounce_unregister_dev(struct device *dev)
618 596
619EXPORT_SYMBOL(dma_map_single); 597EXPORT_SYMBOL(dma_map_single);
620EXPORT_SYMBOL(dma_unmap_single); 598EXPORT_SYMBOL(dma_unmap_single);
621EXPORT_SYMBOL(dma_sync_sg_for_cpu);
622EXPORT_SYMBOL(dma_sync_sg_for_device);
623EXPORT_SYMBOL(dmabounce_register_dev); 599EXPORT_SYMBOL(dmabounce_register_dev);
624EXPORT_SYMBOL(dmabounce_unregister_dev); 600EXPORT_SYMBOL(dmabounce_unregister_dev);
625 601
diff --git a/arch/arm/include/asm/dma-mapping.h b/arch/arm/include/asm/dma-mapping.h
index 856ee1bdee57..29404f71ab87 100644
--- a/arch/arm/include/asm/dma-mapping.h
+++ b/arch/arm/include/asm/dma-mapping.h
@@ -410,6 +410,17 @@ extern void dmabounce_unregister_dev(struct device *);
410 * 410 *
411 */ 411 */
412extern int dma_needs_bounce(struct device*, dma_addr_t, size_t); 412extern int dma_needs_bounce(struct device*, dma_addr_t, size_t);
413
414/*
415 * Private functions
416 */
417int dmabounce_sync_for_cpu(struct device *, dma_addr_t, unsigned long,
418 size_t, enum dma_data_direction);
419int dmabounce_sync_for_device(struct device *, dma_addr_t, unsigned long,
420 size_t, enum dma_data_direction);
421#else
422#define dmabounce_sync_for_cpu(dev,dma,off,sz,dir) (1)
423#define dmabounce_sync_for_device(dev,dma,off,sz,dir) (1)
413#endif /* CONFIG_DMABOUNCE */ 424#endif /* CONFIG_DMABOUNCE */
414 425
415#endif /* __KERNEL__ */ 426#endif /* __KERNEL__ */
diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
index c9c1206e358c..0e28cf33f7dd 100644
--- a/arch/arm/mm/dma-mapping.c
+++ b/arch/arm/mm/dma-mapping.c
@@ -571,7 +571,6 @@ void dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nents,
571} 571}
572EXPORT_SYMBOL(dma_unmap_sg); 572EXPORT_SYMBOL(dma_unmap_sg);
573 573
574#ifndef CONFIG_DMABOUNCE
575/** 574/**
576 * dma_sync_sg_for_cpu 575 * dma_sync_sg_for_cpu
577 * @dev: valid struct device pointer, or NULL for ISA and EISA-like devices 576 * @dev: valid struct device pointer, or NULL for ISA and EISA-like devices
@@ -586,6 +585,10 @@ void dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg,
586 int i; 585 int i;
587 586
588 for_each_sg(sg, s, nents, i) { 587 for_each_sg(sg, s, nents, i) {
588 if (!dmabounce_sync_for_cpu(dev, sg_dma_address(s), 0,
589 sg_dma_len(s), dir))
590 continue;
591
589 if (!arch_is_coherent()) 592 if (!arch_is_coherent())
590 dma_cache_maint(sg_virt(s), s->length, dir); 593 dma_cache_maint(sg_virt(s), s->length, dir);
591 } 594 }
@@ -606,9 +609,12 @@ void dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg,
606 int i; 609 int i;
607 610
608 for_each_sg(sg, s, nents, i) { 611 for_each_sg(sg, s, nents, i) {
612 if (!dmabounce_sync_for_device(dev, sg_dma_address(s), 0,
613 sg_dma_len(s), dir))
614 continue;
615
609 if (!arch_is_coherent()) 616 if (!arch_is_coherent())
610 dma_cache_maint(sg_virt(s), s->length, dir); 617 dma_cache_maint(sg_virt(s), s->length, dir);
611 } 618 }
612} 619}
613EXPORT_SYMBOL(dma_sync_sg_for_device); 620EXPORT_SYMBOL(dma_sync_sg_for_device);
614#endif