The Documentation/DMA-API-HOWTO.txt states that dma_map_sg returns the
numer of the created entries in the DMA address space. However the
subsequent calls to dma_sync_sg_for_{device,cpu} and dma_unmap_sg must be
called with the original number of entries passed to dma_map_sg. The
sg_table->nents in turn holds the result of the dma_map_sg call as stated
in include/linux/scatterlist.h. Adapt the code to obey those rules.

Signed-off-by: Marek Szyprowski <m.szyprow...@samsung.com>
---
 drivers/media/pci/cx23885/cx23885-alsa.c | 2 +-
 drivers/media/pci/cx25821/cx25821-alsa.c | 2 +-
 drivers/media/pci/cx88/cx88-alsa.c       | 2 +-
 drivers/media/pci/saa7134/saa7134-alsa.c | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/media/pci/cx23885/cx23885-alsa.c 
b/drivers/media/pci/cx23885/cx23885-alsa.c
index df44ed7393a0..3f366e4e4685 100644
--- a/drivers/media/pci/cx23885/cx23885-alsa.c
+++ b/drivers/media/pci/cx23885/cx23885-alsa.c
@@ -129,7 +129,7 @@ static int cx23885_alsa_dma_unmap(struct cx23885_audio_dev 
*dev)
        if (!buf->sglen)
                return 0;
 
-       dma_unmap_sg(&dev->pci->dev, buf->sglist, buf->sglen, 
PCI_DMA_FROMDEVICE);
+       dma_unmap_sg(&dev->pci->dev, buf->sglist, buf->nr_pages, 
PCI_DMA_FROMDEVICE);
        buf->sglen = 0;
        return 0;
 }
diff --git a/drivers/media/pci/cx25821/cx25821-alsa.c 
b/drivers/media/pci/cx25821/cx25821-alsa.c
index 301616426d8a..c40304d33776 100644
--- a/drivers/media/pci/cx25821/cx25821-alsa.c
+++ b/drivers/media/pci/cx25821/cx25821-alsa.c
@@ -193,7 +193,7 @@ static int cx25821_alsa_dma_unmap(struct cx25821_audio_dev 
*dev)
        if (!buf->sglen)
                return 0;
 
-       dma_unmap_sg(&dev->pci->dev, buf->sglist, buf->sglen, 
PCI_DMA_FROMDEVICE);
+       dma_unmap_sg(&dev->pci->dev, buf->sglist, buf->nr_pages, 
PCI_DMA_FROMDEVICE);
        buf->sglen = 0;
        return 0;
 }
diff --git a/drivers/media/pci/cx88/cx88-alsa.c 
b/drivers/media/pci/cx88/cx88-alsa.c
index 7d7aceecc985..3c6fe6ceb0b7 100644
--- a/drivers/media/pci/cx88/cx88-alsa.c
+++ b/drivers/media/pci/cx88/cx88-alsa.c
@@ -332,7 +332,7 @@ static int cx88_alsa_dma_unmap(struct cx88_audio_dev *dev)
        if (!buf->sglen)
                return 0;
 
-       dma_unmap_sg(&dev->pci->dev, buf->sglist, buf->sglen,
+       dma_unmap_sg(&dev->pci->dev, buf->sglist, buf->nr_pages,
                     PCI_DMA_FROMDEVICE);
        buf->sglen = 0;
        return 0;
diff --git a/drivers/media/pci/saa7134/saa7134-alsa.c 
b/drivers/media/pci/saa7134/saa7134-alsa.c
index 544ca57eee75..398c47ff473d 100644
--- a/drivers/media/pci/saa7134/saa7134-alsa.c
+++ b/drivers/media/pci/saa7134/saa7134-alsa.c
@@ -313,7 +313,7 @@ static int saa7134_alsa_dma_unmap(struct saa7134_dev *dev)
        if (!dma->sglen)
                return 0;
 
-       dma_unmap_sg(&dev->pci->dev, dma->sglist, dma->sglen, 
PCI_DMA_FROMDEVICE);
+       dma_unmap_sg(&dev->pci->dev, dma->sglist, dma->nr_pages, 
PCI_DMA_FROMDEVICE);
        dma->sglen = 0;
        return 0;
 }
-- 
2.17.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Reply via email to