summaryrefslogtreecommitdiffstats
path: root/drivers/media/pci/cx23885
diff options
context:
space:
mode:
authorMarek Szyprowski <m.szyprowski@samsung.com>2020-09-04 15:17:10 +0200
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>2020-09-26 10:34:44 +0200
commitf95fc014e036c06203c0c5d75045e4ac890ef335 (patch)
tree75019c755330afaabc941f582b7ce26fd733209b /drivers/media/pci/cx23885
parentab11fae0be7a7bcb7aec75c5b081d37ed0a0ed08 (diff)
downloadlinux-stable-f95fc014e036c06203c0c5d75045e4ac890ef335.tar.gz
linux-stable-f95fc014e036c06203c0c5d75045e4ac890ef335.tar.bz2
linux-stable-f95fc014e036c06203c0c5d75045e4ac890ef335.zip
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>
Diffstat (limited to 'drivers/media/pci/cx23885')
-rw-r--r--drivers/media/pci/cx23885/cx23885-alsa.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/media/pci/cx23885/cx23885-alsa.c b/drivers/media/pci/cx23885/cx23885-alsa.c
index 141852f02236..13689c5dd47f 100644
--- a/drivers/media/pci/cx23885/cx23885-alsa.c
+++ b/drivers/media/pci/cx23885/cx23885-alsa.c
@@ -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;
}