diff options
author | Lars-Peter Clausen <lars@metafoo.de> | 2012-04-25 14:50:52 -0400 |
---|---|---|
committer | Vinod Koul <vinod.koul@linux.intel.com> | 2012-05-11 02:34:38 -0400 |
commit | fdaf9c4b22247a6cc6cda9459be3e52764c14d95 (patch) | |
tree | c567736f1f47f91003a658b11075e974cee4321b /drivers/dma/amba-pl08x.c | |
parent | cbb796ccd8c33c50249b876d9773dfa8e67d39cb (diff) |
dmaengine: Use dma_sg_len(sg) instead of sg->length
sg->length may or may not contain the length of the dma region to transfer,
depending on the architecture - dma_sg_len(sg) always will though. For the
architectures which use the drivers modified by this patch it probably is the
case that sg->length contains the dma transfer length. But to be consistent and
future proof change them to use dma_sg_len.
To quote Russel King:
sg->length is meaningless to something performing DMA.
In cases where sg_dma_len(sg) and sg->length are the same storage, then
there's no problem. But scatterlists _can_ (and one some architectures) do
split them - especially when you have an IOMMU which can allow you to
combine a scatterlist into fewer entries.
So, anything using sg->length for the size of a scatterlist's DMA transfer
_after_ a call to dma_map_sg() is almost certainly buggy.
The patch has been generated using the following coccinelle patch:
<smpl>
@@
struct scatterlist *sg;
expression X;
@@
-sg[X].length
+sg_dma_len(&sg[X])
@@
struct scatterlist *sg;
@@
-sg->length
+sg_dma_len(sg)
</smpl>
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 'drivers/dma/amba-pl08x.c')
-rw-r--r-- | drivers/dma/amba-pl08x.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/dma/amba-pl08x.c b/drivers/dma/amba-pl08x.c index 003220a60bcb..49ecbbb8932d 100644 --- a/drivers/dma/amba-pl08x.c +++ b/drivers/dma/amba-pl08x.c | |||
@@ -1328,7 +1328,7 @@ static struct dma_async_tx_descriptor *pl08x_prep_slave_sg( | |||
1328 | int ret, tmp; | 1328 | int ret, tmp; |
1329 | 1329 | ||
1330 | dev_dbg(&pl08x->adev->dev, "%s prepare transaction of %d bytes from %s\n", | 1330 | dev_dbg(&pl08x->adev->dev, "%s prepare transaction of %d bytes from %s\n", |
1331 | __func__, sgl->length, plchan->name); | 1331 | __func__, sg_dma_len(sgl), plchan->name); |
1332 | 1332 | ||
1333 | txd = pl08x_get_txd(plchan, flags); | 1333 | txd = pl08x_get_txd(plchan, flags); |
1334 | if (!txd) { | 1334 | if (!txd) { |