Commit c1dbcf62 authored by Christophe JAILLET's avatar Christophe JAILLET Committed by Mauro Carvalho Chehab

media: tw686x: switch from 'pci_' to 'dma_' API

The wrappers in include/linux/pci-dma-compat.h should go away.

The patch has been generated with the coccinelle script below and has been
hand modified to replace GFP_ with a correct flag.
It has been compile tested.

When memory is allocated in 'tw686x_audio_dma_alloc()' (tw686x-audio.c)
GFP_KERNEL can be used because it is only called from a probe function
and no spinlock is taken in the between.
The call chain is:
  tw686x_probe					(tw686x-core.c)
    --> tw686x_audio_init					(tw686x-audio.c)
      --> tw686x_audio_dma_alloc					(tw686x-audio.c)

When memory is allocated in 'tw686x_memcpy_dma_alloc()' and in
'tw686x_sg_dma_alloc()' (tw686x-video.c) GFP_KERNEL can be used because
these functions are .alloc functions from a tw686x_dma_ops structure.

@@
@@
-    PCI_DMA_BIDIRECTIONAL
+    DMA_BIDIRECTIONAL

@@
@@
-    PCI_DMA_TODEVICE
+    DMA_TO_DEVICE

@@
@@
-    PCI_DMA_FROMDEVICE
+    DMA_FROM_DEVICE

@@
@@
-    PCI_DMA_NONE
+    DMA_NONE

@@
expression e1, e2, e3;
@@
-    pci_alloc_consistent(e1, e2, e3)
+    dma_alloc_coherent(&e1->dev, e2, e3, GFP_)

@@
expression e1, e2, e3;
@@
-    pci_zalloc_consistent(e1, e2, e3)
+    dma_alloc_coherent(&e1->dev, e2, e3, GFP_)

@@
expression e1, e2, e3, e4;
@@
-    pci_free_consistent(e1, e2, e3, e4)
+    dma_free_coherent(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-    pci_map_single(e1, e2, e3, e4)
+    dma_map_single(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-    pci_unmap_single(e1, e2, e3, e4)
+    dma_unmap_single(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4, e5;
@@
-    pci_map_page(e1, e2, e3, e4, e5)
+    dma_map_page(&e1->dev, e2, e3, e4, e5)

@@
expression e1, e2, e3, e4;
@@
-    pci_unmap_page(e1, e2, e3, e4)
+    dma_unmap_page(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-    pci_map_sg(e1, e2, e3, e4)
+    dma_map_sg(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-    pci_unmap_sg(e1, e2, e3, e4)
+    dma_unmap_sg(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-    pci_dma_sync_single_for_cpu(e1, e2, e3, e4)
+    dma_sync_single_for_cpu(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-    pci_dma_sync_single_for_device(e1, e2, e3, e4)
+    dma_sync_single_for_device(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-    pci_dma_sync_sg_for_cpu(e1, e2, e3, e4)
+    dma_sync_sg_for_cpu(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-    pci_dma_sync_sg_for_device(e1, e2, e3, e4)
+    dma_sync_sg_for_device(&e1->dev, e2, e3, e4)

@@
expression e1, e2;
@@
-    pci_dma_mapping_error(e1, e2)
+    dma_mapping_error(&e1->dev, e2)

@@
expression e1, e2;
@@
-    pci_set_dma_mask(e1, e2)
+    dma_set_mask(&e1->dev, e2)

@@
expression e1, e2;
@@
-    pci_set_consistent_dma_mask(e1, e2)
+    dma_set_coherent_mask(&e1->dev, e2)
Signed-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent 7a77379f
......@@ -300,9 +300,9 @@ static void tw686x_audio_dma_free(struct tw686x_dev *dev,
for (pb = 0; pb < 2; pb++) {
if (!ac->dma_descs[pb].virt)
continue;
pci_free_consistent(dev->pci_dev, ac->dma_descs[pb].size,
ac->dma_descs[pb].virt,
ac->dma_descs[pb].phys);
dma_free_coherent(&dev->pci_dev->dev, ac->dma_descs[pb].size,
ac->dma_descs[pb].virt,
ac->dma_descs[pb].phys);
ac->dma_descs[pb].virt = NULL;
}
}
......@@ -313,7 +313,7 @@ static int tw686x_audio_dma_alloc(struct tw686x_dev *dev,
int pb;
/*
* In the memcpy DMA mode we allocate a consistent buffer
* In the memcpy DMA mode we allocate a coherent buffer
* and use it for the DMA capture. Otherwise, DMA
* acts on the ALSA buffers as received in pcm_prepare.
*/
......@@ -324,8 +324,9 @@ static int tw686x_audio_dma_alloc(struct tw686x_dev *dev,
u32 reg = pb ? ADMA_B_ADDR[ac->ch] : ADMA_P_ADDR[ac->ch];
void *virt;
virt = pci_alloc_consistent(dev->pci_dev, AUDIO_DMA_SIZE_MAX,
&ac->dma_descs[pb].phys);
virt = dma_alloc_coherent(&dev->pci_dev->dev,
AUDIO_DMA_SIZE_MAX,
&ac->dma_descs[pb].phys, GFP_KERNEL);
if (!virt) {
dev_err(&dev->pci_dev->dev,
"dma%d: unable to allocate audio DMA %s-buffer\n",
......
......@@ -276,7 +276,7 @@ static int tw686x_probe(struct pci_dev *pci_dev,
}
pci_set_master(pci_dev);
err = pci_set_dma_mask(pci_dev, DMA_BIT_MASK(32));
err = dma_set_mask(&pci_dev->dev, DMA_BIT_MASK(32));
if (err) {
dev_err(&pci_dev->dev, "32-bit PCI DMA not supported\n");
err = -EIO;
......
......@@ -92,8 +92,8 @@ static void tw686x_memcpy_dma_free(struct tw686x_video_channel *vc,
}
if (desc->virt) {
pci_free_consistent(dev->pci_dev, desc->size,
desc->virt, desc->phys);
dma_free_coherent(&dev->pci_dev->dev, desc->size, desc->virt,
desc->phys);
desc->virt = NULL;
}
}
......@@ -110,8 +110,8 @@ static int tw686x_memcpy_dma_alloc(struct tw686x_video_channel *vc,
"Allocating buffer but previous still here\n");
len = (vc->width * vc->height * vc->format->depth) >> 3;
virt = pci_alloc_consistent(dev->pci_dev, len,
&vc->dma_descs[pb].phys);
virt = dma_alloc_coherent(&dev->pci_dev->dev, len,
&vc->dma_descs[pb].phys, GFP_KERNEL);
if (!virt) {
v4l2_err(&dev->v4l2_dev,
"dma%d: unable to allocate %s-buffer\n",
......@@ -258,8 +258,8 @@ static void tw686x_sg_dma_free(struct tw686x_video_channel *vc,
struct tw686x_dev *dev = vc->dev;
if (desc->size) {
pci_free_consistent(dev->pci_dev, desc->size,
desc->virt, desc->phys);
dma_free_coherent(&dev->pci_dev->dev, desc->size, desc->virt,
desc->phys);
desc->virt = NULL;
}
......@@ -276,9 +276,8 @@ static int tw686x_sg_dma_alloc(struct tw686x_video_channel *vc,
void *virt;
if (desc->size) {
virt = pci_alloc_consistent(dev->pci_dev, desc->size,
&desc->phys);
virt = dma_alloc_coherent(&dev->pci_dev->dev, desc->size,
&desc->phys, GFP_KERNEL);
if (!virt) {
v4l2_err(&dev->v4l2_dev,
"dma%d: unable to allocate %s-buffer\n",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment