diff options
author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2012-12-17 18:59:52 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-12-17 20:15:13 -0500 |
commit | 632fd28326c0cc7be9c51ea0d76d8bec39a695e9 (patch) | |
tree | bfd853fed61e3692aab0bdd327c56e4c9ea7fa8c /drivers/dma | |
parent | 0f34c400914f165b7b3812459be2d77b8aa1f1e4 (diff) |
dmatest: implement two helpers to unmap dma memory
The unmap_src() and unmap_dst() will be used later as well.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/dma')
-rw-r--r-- | drivers/dma/dmatest.c | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/drivers/dma/dmatest.c b/drivers/dma/dmatest.c index 24225f0fdcd8..6be893baadd9 100644 --- a/drivers/dma/dmatest.c +++ b/drivers/dma/dmatest.c | |||
@@ -228,6 +228,20 @@ static void dmatest_callback(void *arg) | |||
228 | wake_up_all(done->wait); | 228 | wake_up_all(done->wait); |
229 | } | 229 | } |
230 | 230 | ||
231 | static inline void unmap_src(struct device *dev, dma_addr_t *addr, size_t len, | ||
232 | unsigned int count) | ||
233 | { | ||
234 | while (count--) | ||
235 | dma_unmap_single(dev, addr[count], len, DMA_TO_DEVICE); | ||
236 | } | ||
237 | |||
238 | static inline void unmap_dst(struct device *dev, dma_addr_t *addr, size_t len, | ||
239 | unsigned int count) | ||
240 | { | ||
241 | while (count--) | ||
242 | dma_unmap_single(dev, addr[count], len, DMA_BIDIRECTIONAL); | ||
243 | } | ||
244 | |||
231 | /* | 245 | /* |
232 | * This function repeatedly tests DMA transfers of various lengths and | 246 | * This function repeatedly tests DMA transfers of various lengths and |
233 | * offsets for a given operation type until it is told to exit by | 247 | * offsets for a given operation type until it is told to exit by |
@@ -383,13 +397,8 @@ static int dmatest_func(void *data) | |||
383 | } | 397 | } |
384 | 398 | ||
385 | if (!tx) { | 399 | if (!tx) { |
386 | for (i = 0; i < src_cnt; i++) | 400 | unmap_src(dev->dev, dma_srcs, len, src_cnt); |
387 | dma_unmap_single(dev->dev, dma_srcs[i], len, | 401 | unmap_dst(dev->dev, dma_dsts, test_buf_size, dst_cnt); |
388 | DMA_TO_DEVICE); | ||
389 | for (i = 0; i < dst_cnt; i++) | ||
390 | dma_unmap_single(dev->dev, dma_dsts[i], | ||
391 | test_buf_size, | ||
392 | DMA_BIDIRECTIONAL); | ||
393 | pr_warning("%s: #%u: prep error with src_off=0x%x " | 402 | pr_warning("%s: #%u: prep error with src_off=0x%x " |
394 | "dst_off=0x%x len=0x%x\n", | 403 | "dst_off=0x%x len=0x%x\n", |
395 | thread_name, total_tests - 1, | 404 | thread_name, total_tests - 1, |
@@ -443,9 +452,7 @@ static int dmatest_func(void *data) | |||
443 | } | 452 | } |
444 | 453 | ||
445 | /* Unmap by myself (see DMA_COMPL_SKIP_DEST_UNMAP above) */ | 454 | /* Unmap by myself (see DMA_COMPL_SKIP_DEST_UNMAP above) */ |
446 | for (i = 0; i < dst_cnt; i++) | 455 | unmap_dst(dev->dev, dma_dsts, test_buf_size, dst_cnt); |
447 | dma_unmap_single(dev->dev, dma_dsts[i], test_buf_size, | ||
448 | DMA_BIDIRECTIONAL); | ||
449 | 456 | ||
450 | error_count = 0; | 457 | error_count = 0; |
451 | 458 | ||