Commit 424cadae authored by Thiemo Seufer's avatar Thiemo Seufer Committed by Ralf Baechle

Don't set up a sg dma address if we have no page address for some reason.

Code cleanup.
Signed-off-by: default avatarThiemo Seufer <ths@networkno.de>
Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
parent 98e316d4
...@@ -105,22 +105,7 @@ dma_addr_t dma_map_single(struct device *dev, void *ptr, size_t size, ...@@ -105,22 +105,7 @@ dma_addr_t dma_map_single(struct device *dev, void *ptr, size_t size,
{ {
unsigned long addr = (unsigned long) ptr; unsigned long addr = (unsigned long) ptr;
switch (direction) { __dma_sync(addr, size, direction);
case DMA_TO_DEVICE:
dma_cache_wback(addr, size);
break;
case DMA_FROM_DEVICE:
dma_cache_inv(addr, size);
break;
case DMA_BIDIRECTIONAL:
dma_cache_wback_inv(addr, size);
break;
default:
BUG();
}
return virt_to_phys(ptr); return virt_to_phys(ptr);
} }
...@@ -133,22 +118,7 @@ void dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size, ...@@ -133,22 +118,7 @@ void dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size,
unsigned long addr; unsigned long addr;
addr = dma_addr + PAGE_OFFSET; addr = dma_addr + PAGE_OFFSET;
switch (direction) { //__dma_sync(addr, size, direction);
case DMA_TO_DEVICE:
//dma_cache_wback(addr, size);
break;
case DMA_FROM_DEVICE:
//dma_cache_inv(addr, size);
break;
case DMA_BIDIRECTIONAL:
//dma_cache_wback_inv(addr, size);
break;
default:
BUG();
}
} }
EXPORT_SYMBOL(dma_unmap_single); EXPORT_SYMBOL(dma_unmap_single);
...@@ -164,10 +134,11 @@ int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents, ...@@ -164,10 +134,11 @@ int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
unsigned long addr; unsigned long addr;
addr = (unsigned long) page_address(sg->page); addr = (unsigned long) page_address(sg->page);
if (addr) if (addr) {
__dma_sync(addr + sg->offset, sg->length, direction); __dma_sync(addr + sg->offset, sg->length, direction);
sg->dma_address = (dma_addr_t) sg->dma_address = (dma_addr_t)page_to_phys(sg->page)
(page_to_phys(sg->page) + sg->offset); + sg->offset;
}
} }
return nents; return nents;
...@@ -218,9 +189,8 @@ void dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nhwentries, ...@@ -218,9 +189,8 @@ void dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nhwentries,
for (i = 0; i < nhwentries; i++, sg++) { for (i = 0; i < nhwentries; i++, sg++) {
addr = (unsigned long) page_address(sg->page); addr = (unsigned long) page_address(sg->page);
if (!addr) if (addr)
continue; __dma_sync(addr + sg->offset, sg->length, direction);
dma_cache_wback_inv(addr + sg->offset, sg->length);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment