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

media: cx25821: 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 'cx25821_riscmem_alloc()' GFP_KERNEL can be
used because either this flag is already used in the call chain, or it is
called from a 'buf_prepare' function.

The call chains are:
  vb2_ops.buf_prepare              (in cx25821-video.c)
    cx25821_buffer_prepare         (in cx25821-video.c)
      cx25821_risc_buffer
        cx25821_riscmem_alloc

  snd_cx25821_hw_params            (in cx25821-alsa.c) <-- use GFP_KERNEL
    cx25821_risc_databuffer_audio
      cx25821_riscmem_alloc

@@
@@
-    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 1ef5b9b8
...@@ -403,7 +403,7 @@ static int dsp_buffer_free(struct cx25821_audio_dev *chip) ...@@ -403,7 +403,7 @@ static int dsp_buffer_free(struct cx25821_audio_dev *chip)
dprintk(2, "Freeing buffer\n"); dprintk(2, "Freeing buffer\n");
cx25821_alsa_dma_unmap(chip); cx25821_alsa_dma_unmap(chip);
cx25821_alsa_dma_free(chip->buf); cx25821_alsa_dma_free(chip->buf);
pci_free_consistent(chip->pci, risc->size, risc->cpu, risc->dma); dma_free_coherent(&chip->pci->dev, risc->size, risc->cpu, risc->dma);
kfree(chip->buf); kfree(chip->buf);
chip->buf = NULL; chip->buf = NULL;
......
...@@ -977,11 +977,11 @@ int cx25821_riscmem_alloc(struct pci_dev *pci, ...@@ -977,11 +977,11 @@ int cx25821_riscmem_alloc(struct pci_dev *pci,
dma_addr_t dma = 0; dma_addr_t dma = 0;
if (risc->cpu && risc->size < size) { if (risc->cpu && risc->size < size) {
pci_free_consistent(pci, risc->size, risc->cpu, risc->dma); dma_free_coherent(&pci->dev, risc->size, risc->cpu, risc->dma);
risc->cpu = NULL; risc->cpu = NULL;
} }
if (NULL == risc->cpu) { if (NULL == risc->cpu) {
cpu = pci_zalloc_consistent(pci, size, &dma); cpu = dma_alloc_coherent(&pci->dev, size, &dma, GFP_KERNEL);
if (NULL == cpu) if (NULL == cpu)
return -ENOMEM; return -ENOMEM;
risc->cpu = cpu; risc->cpu = cpu;
...@@ -1202,8 +1202,8 @@ void cx25821_free_buffer(struct cx25821_dev *dev, struct cx25821_buffer *buf) ...@@ -1202,8 +1202,8 @@ void cx25821_free_buffer(struct cx25821_dev *dev, struct cx25821_buffer *buf)
{ {
if (WARN_ON(buf->risc.size == 0)) if (WARN_ON(buf->risc.size == 0))
return; return;
pci_free_consistent(dev->pci, dma_free_coherent(&dev->pci->dev, buf->risc.size, buf->risc.cpu,
buf->risc.size, buf->risc.cpu, buf->risc.dma); buf->risc.dma);
memset(&buf->risc, 0, sizeof(buf->risc)); memset(&buf->risc, 0, sizeof(buf->risc));
} }
...@@ -1302,7 +1302,7 @@ static int cx25821_initdev(struct pci_dev *pci_dev, ...@@ -1302,7 +1302,7 @@ static int cx25821_initdev(struct pci_dev *pci_dev,
dev->pci_lat, (unsigned long long)dev->base_io_addr); dev->pci_lat, (unsigned long long)dev->base_io_addr);
pci_set_master(pci_dev); pci_set_master(pci_dev);
err = pci_set_dma_mask(pci_dev, 0xffffffff); err = dma_set_mask(&pci_dev->dev, 0xffffffff);
if (err) { if (err) {
pr_err("%s/0: Oops: no 32bit PCI DMA ???\n", dev->name); pr_err("%s/0: Oops: no 32bit PCI DMA ???\n", dev->name);
err = -EIO; err = -EIO;
......
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