media: pci: fix common ALSA DMA-mapping related codes
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. While touching this code, update it to use the modern DMA_FROM_DEVICE definitions. Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
This commit is contained in:
parent
ab11fae0be
commit
f95fc014e0
|
@ -114,7 +114,7 @@ static int cx23885_alsa_dma_map(struct cx23885_audio_dev *dev)
|
|||
struct cx23885_audio_buffer *buf = dev->buf;
|
||||
|
||||
buf->sglen = dma_map_sg(&dev->pci->dev, buf->sglist,
|
||||
buf->nr_pages, PCI_DMA_FROMDEVICE);
|
||||
buf->nr_pages, DMA_FROM_DEVICE);
|
||||
|
||||
if (0 == buf->sglen) {
|
||||
pr_warn("%s: cx23885_alsa_map_sg failed\n", __func__);
|
||||
|
@ -130,7 +130,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, DMA_FROM_DEVICE);
|
||||
buf->sglen = 0;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -178,7 +178,7 @@ static int cx25821_alsa_dma_map(struct cx25821_audio_dev *dev)
|
|||
struct cx25821_audio_buffer *buf = dev->buf;
|
||||
|
||||
buf->sglen = dma_map_sg(&dev->pci->dev, buf->sglist,
|
||||
buf->nr_pages, PCI_DMA_FROMDEVICE);
|
||||
buf->nr_pages, DMA_FROM_DEVICE);
|
||||
|
||||
if (0 == buf->sglen) {
|
||||
pr_warn("%s: cx25821_alsa_map_sg failed\n", __func__);
|
||||
|
@ -194,7 +194,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, DMA_FROM_DEVICE);
|
||||
buf->sglen = 0;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -317,7 +317,7 @@ static int cx88_alsa_dma_map(struct cx88_audio_dev *dev)
|
|||
struct cx88_audio_buffer *buf = dev->buf;
|
||||
|
||||
buf->sglen = dma_map_sg(&dev->pci->dev, buf->sglist,
|
||||
buf->nr_pages, PCI_DMA_FROMDEVICE);
|
||||
buf->nr_pages, DMA_FROM_DEVICE);
|
||||
|
||||
if (buf->sglen == 0) {
|
||||
pr_warn("%s: cx88_alsa_map_sg failed\n", __func__);
|
||||
|
@ -333,8 +333,8 @@ 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,
|
||||
PCI_DMA_FROMDEVICE);
|
||||
dma_unmap_sg(&dev->pci->dev, buf->sglist, buf->nr_pages,
|
||||
DMA_FROM_DEVICE);
|
||||
buf->sglen = 0;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -298,7 +298,7 @@ static int saa7134_alsa_dma_map(struct saa7134_dev *dev)
|
|||
struct saa7134_dmasound *dma = &dev->dmasound;
|
||||
|
||||
dma->sglen = dma_map_sg(&dev->pci->dev, dma->sglist,
|
||||
dma->nr_pages, PCI_DMA_FROMDEVICE);
|
||||
dma->nr_pages, DMA_FROM_DEVICE);
|
||||
|
||||
if (0 == dma->sglen) {
|
||||
pr_warn("%s: saa7134_alsa_map_sg failed\n", __func__);
|
||||
|
@ -314,7 +314,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, DMA_FROM_DEVICE);
|
||||
dma->sglen = 0;
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue