aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRussell King <rmk@dyn-67.arm.linux.org.uk>2008-09-25 16:05:02 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2008-09-25 18:39:24 -0400
commit01135d92c1a540cd3370f7cf3d1c762320b85034 (patch)
treea6344d942a4f63cba85290a93008ce211996d27d
parent56f55f8b58a02e95b401cb50df05086cabeaeeb5 (diff)
[ARM] dma: Reduce to one dma_map_sg()/dma_unmap_sg() implementation
No point having two of these; dma_map_page() can do all the work for us. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
-rw-r--r--arch/arm/common/dmabounce.c46
-rw-r--r--arch/arm/mm/dma-mapping.c24
2 files changed, 16 insertions, 54 deletions
diff --git a/arch/arm/common/dmabounce.c b/arch/arm/common/dmabounce.c
index c7f23ced0a36..20d967376fa9 100644
--- a/arch/arm/common/dmabounce.c
+++ b/arch/arm/common/dmabounce.c
@@ -444,50 +444,6 @@ dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size,
444 unmap_single(dev, dma_addr, size, dir); 444 unmap_single(dev, dma_addr, size, dir);
445} 445}
446 446
447int
448dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
449 enum dma_data_direction dir)
450{
451 struct scatterlist *s;
452 int i;
453
454 dev_dbg(dev, "%s(sg=%p,nents=%d,dir=%x)\n",
455 __func__, sg, nents, dir);
456
457 BUG_ON(dir == DMA_NONE);
458
459 for_each_sg(sg, s, nents, i) {
460 struct page *page = sg_page(s);
461 unsigned int offset = s->offset;
462 unsigned int length = s->length;
463 void *ptr = page_address(page) + offset;
464
465 s->dma_address = map_single(dev, ptr, length, dir);
466 }
467
468 return nents;
469}
470
471void
472dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nents,
473 enum dma_data_direction dir)
474{
475 struct scatterlist *s;
476 int i;
477
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 unmap_single(dev, dma_addr, length, dir);
488 }
489}
490
491void dma_sync_single_range_for_cpu(struct device *dev, dma_addr_t dma_addr, 447void dma_sync_single_range_for_cpu(struct device *dev, dma_addr_t dma_addr,
492 unsigned long offset, size_t size, 448 unsigned long offset, size_t size,
493 enum dma_data_direction dir) 449 enum dma_data_direction dir)
@@ -662,8 +618,6 @@ dmabounce_unregister_dev(struct device *dev)
662 618
663EXPORT_SYMBOL(dma_map_single); 619EXPORT_SYMBOL(dma_map_single);
664EXPORT_SYMBOL(dma_unmap_single); 620EXPORT_SYMBOL(dma_unmap_single);
665EXPORT_SYMBOL(dma_map_sg);
666EXPORT_SYMBOL(dma_unmap_sg);
667EXPORT_SYMBOL(dma_sync_sg_for_cpu); 621EXPORT_SYMBOL(dma_sync_sg_for_cpu);
668EXPORT_SYMBOL(dma_sync_sg_for_device); 622EXPORT_SYMBOL(dma_sync_sg_for_device);
669EXPORT_SYMBOL(dmabounce_register_dev); 623EXPORT_SYMBOL(dmabounce_register_dev);
diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
index 7bf3e6fdfb57..c9c1206e358c 100644
--- a/arch/arm/mm/dma-mapping.c
+++ b/arch/arm/mm/dma-mapping.c
@@ -513,7 +513,6 @@ void dma_cache_maint(const void *start, size_t size, int direction)
513} 513}
514EXPORT_SYMBOL(dma_cache_maint); 514EXPORT_SYMBOL(dma_cache_maint);
515 515
516#ifndef CONFIG_DMABOUNCE
517/** 516/**
518 * dma_map_sg - map a set of SG buffers for streaming mode DMA 517 * dma_map_sg - map a set of SG buffers for streaming mode DMA
519 * @dev: valid struct device pointer, or NULL for ISA and EISA-like devices 518 * @dev: valid struct device pointer, or NULL for ISA and EISA-like devices
@@ -534,16 +533,20 @@ int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
534 enum dma_data_direction dir) 533 enum dma_data_direction dir)
535{ 534{
536 struct scatterlist *s; 535 struct scatterlist *s;
537 int i; 536 int i, j;
538 537
539 for_each_sg(sg, s, nents, i) { 538 for_each_sg(sg, s, nents, i) {
540 s->dma_address = page_to_dma(dev, sg_page(s)) + s->offset; 539 s->dma_address = dma_map_page(dev, sg_page(s), s->offset,
541 540 s->length, dir);
542 if (!arch_is_coherent()) 541 if (dma_mapping_error(dev, s->dma_address))
543 dma_cache_maint(sg_virt(s), s->length, dir); 542 goto bad_mapping;
544 } 543 }
545
546 return nents; 544 return nents;
545
546 bad_mapping:
547 for_each_sg(sg, s, i, j)
548 dma_unmap_page(dev, sg_dma_address(s), sg_dma_len(s), dir);
549 return 0;
547} 550}
548EXPORT_SYMBOL(dma_map_sg); 551EXPORT_SYMBOL(dma_map_sg);
549 552
@@ -560,10 +563,15 @@ EXPORT_SYMBOL(dma_map_sg);
560void dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nents, 563void dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nents,
561 enum dma_data_direction dir) 564 enum dma_data_direction dir)
562{ 565{
563 /* nothing to do */ 566 struct scatterlist *s;
567 int i;
568
569 for_each_sg(sg, s, nents, i)
570 dma_unmap_page(dev, sg_dma_address(s), sg_dma_len(s), dir);
564} 571}
565EXPORT_SYMBOL(dma_unmap_sg); 572EXPORT_SYMBOL(dma_unmap_sg);
566 573
574#ifndef CONFIG_DMABOUNCE
567/** 575/**
568 * dma_sync_sg_for_cpu 576 * dma_sync_sg_for_cpu
569 * @dev: valid struct device pointer, or NULL for ISA and EISA-like devices 577 * @dev: valid struct device pointer, or NULL for ISA and EISA-like devices