aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mm
diff options
context:
space:
mode:
authorRussell King <rmk@dyn-67.arm.linux.org.uk>2008-09-25 11:30:57 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2008-09-25 15:48:45 -0400
commitafd1a321c49a250dab97cef6f2d3c3c9b9d0174a (patch)
tree7468c0055b088df5456cb2fa40d27f6c4f2e1732 /arch/arm/mm
parent0ddbccd1187e12bf77e1f19d8b9dec700e09e734 (diff)
[ARM] Update dma_map_sg()/dma_unmap_sg() API
Update the ARM DMA scatter gather APIs for the scatterlist changes. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/mm')
-rw-r--r--arch/arm/mm/dma-mapping.c92
1 files changed, 92 insertions, 0 deletions
diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
index 9f312248d5af..7bf3e6fdfb57 100644
--- a/arch/arm/mm/dma-mapping.c
+++ b/arch/arm/mm/dma-mapping.c
@@ -512,3 +512,95 @@ void dma_cache_maint(const void *start, size_t size, int direction)
512 } 512 }
513} 513}
514EXPORT_SYMBOL(dma_cache_maint); 514EXPORT_SYMBOL(dma_cache_maint);
515
516#ifndef CONFIG_DMABOUNCE
517/**
518 * 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
520 * @sg: list of buffers
521 * @nents: number of buffers to map
522 * @dir: DMA transfer direction
523 *
524 * Map a set of buffers described by scatterlist in streaming mode for DMA.
525 * This is the scatter-gather version of the dma_map_single interface.
526 * Here the scatter gather list elements are each tagged with the
527 * appropriate dma address and length. They are obtained via
528 * sg_dma_{address,length}.
529 *
530 * Device ownership issues as mentioned for dma_map_single are the same
531 * here.
532 */
533int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
534 enum dma_data_direction dir)
535{
536 struct scatterlist *s;
537 int i;
538
539 for_each_sg(sg, s, nents, i) {
540 s->dma_address = page_to_dma(dev, sg_page(s)) + s->offset;
541
542 if (!arch_is_coherent())
543 dma_cache_maint(sg_virt(s), s->length, dir);
544 }
545
546 return nents;
547}
548EXPORT_SYMBOL(dma_map_sg);
549
550/**
551 * dma_unmap_sg - unmap a set of SG buffers mapped by dma_map_sg
552 * @dev: valid struct device pointer, or NULL for ISA and EISA-like devices
553 * @sg: list of buffers
554 * @nents: number of buffers to unmap (returned from dma_map_sg)
555 * @dir: DMA transfer direction (same as was passed to dma_map_sg)
556 *
557 * Unmap a set of streaming mode DMA translations. Again, CPU access
558 * rules concerning calls here are the same as for dma_unmap_single().
559 */
560void dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nents,
561 enum dma_data_direction dir)
562{
563 /* nothing to do */
564}
565EXPORT_SYMBOL(dma_unmap_sg);
566
567/**
568 * dma_sync_sg_for_cpu
569 * @dev: valid struct device pointer, or NULL for ISA and EISA-like devices
570 * @sg: list of buffers
571 * @nents: number of buffers to map (returned from dma_map_sg)
572 * @dir: DMA transfer direction (same as was passed to dma_map_sg)
573 */
574void dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg,
575 int nents, enum dma_data_direction dir)
576{
577 struct scatterlist *s;
578 int i;
579
580 for_each_sg(sg, s, nents, i) {
581 if (!arch_is_coherent())
582 dma_cache_maint(sg_virt(s), s->length, dir);
583 }
584}
585EXPORT_SYMBOL(dma_sync_sg_for_cpu);
586
587/**
588 * dma_sync_sg_for_device
589 * @dev: valid struct device pointer, or NULL for ISA and EISA-like devices
590 * @sg: list of buffers
591 * @nents: number of buffers to map (returned from dma_map_sg)
592 * @dir: DMA transfer direction (same as was passed to dma_map_sg)
593 */
594void dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg,
595 int nents, enum dma_data_direction dir)
596{
597 struct scatterlist *s;
598 int i;
599
600 for_each_sg(sg, s, nents, i) {
601 if (!arch_is_coherent())
602 dma_cache_maint(sg_virt(s), s->length, dir);
603 }
604}
605EXPORT_SYMBOL(dma_sync_sg_for_device);
606#endif