diff options
author | Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> | 2012-04-25 14:50:53 -0400 |
---|---|---|
committer | Vinod Koul <vinod.koul@linux.intel.com> | 2012-05-11 02:34:39 -0400 |
commit | 922ee08baad2052d0759f100e026d49798c51fef (patch) | |
tree | 516d14b41b5831c2b7a571ad5851ef6d00062f14 /include/linux/dmaengine.h | |
parent | fdaf9c4b22247a6cc6cda9459be3e52764c14d95 (diff) |
dmaengine: Fixup dmaengine_prep_slave_single() to be actually useful
dmaengine_prep_slave_single() is a helper function which is supposed to be used
to prepare a transfer of a single contingous buffer. Currently the function
takes a pointer to such a buffer from which it builds a scatterlist and passes
it on to device_prep_slave_sg. The dmaengine framework requires that any
scatterlist that is passed to device_prep_slave_sg is mapped and it may not be
unmapped until the DMA operation has completed. This is not the here and any use
of dmaengine_prep_slave_single() will lead to undefined behaviour (Most likely a
system crash).
This patch changes dmaengine_prep_slave_single() to take a dma_addr_t instead of
a pointer to a buffer and moves the responsibility of mapping and unmapping the
buffer up to the caller.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Vinod Koul <vinod.koul@linux.intel.com>
Diffstat (limited to 'include/linux/dmaengine.h')
-rw-r--r-- | include/linux/dmaengine.h | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h index 676f967390ae..0e6b595e95c8 100644 --- a/include/linux/dmaengine.h +++ b/include/linux/dmaengine.h | |||
@@ -615,11 +615,13 @@ static inline int dmaengine_slave_config(struct dma_chan *chan, | |||
615 | } | 615 | } |
616 | 616 | ||
617 | static inline struct dma_async_tx_descriptor *dmaengine_prep_slave_single( | 617 | static inline struct dma_async_tx_descriptor *dmaengine_prep_slave_single( |
618 | struct dma_chan *chan, void *buf, size_t len, | 618 | struct dma_chan *chan, dma_addr_t buf, size_t len, |
619 | enum dma_transfer_direction dir, unsigned long flags) | 619 | enum dma_transfer_direction dir, unsigned long flags) |
620 | { | 620 | { |
621 | struct scatterlist sg; | 621 | struct scatterlist sg; |
622 | sg_init_one(&sg, buf, len); | 622 | sg_init_table(&sg, 1); |
623 | sg_dma_address(&sg) = buf; | ||
624 | sg_dma_len(&sg) = len; | ||
623 | 625 | ||
624 | return chan->device->device_prep_slave_sg(chan, &sg, 1, | 626 | return chan->device->device_prep_slave_sg(chan, &sg, 1, |
625 | dir, flags, NULL); | 627 | dir, flags, NULL); |