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

media: solo6x10: 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 'snd_solo_pcm_open()' (solo6x10-g723.c)
GFP_KERNEL can be used because this flag is already used jew a few lines
above.

When memory is allocated in 'solo_enc_alloc()' (solo6x10-v4l2-enc.c)
GFP_KERNEL can be used because this flag is already used jew a few lines
above.

When memory is allocated in 'solo_enc_v4l2_init()' (solo6x10-v4l2-enc.c)
GFP_KERNEL can be used because calls 'solo_enc_alloc()' which already uses
this flag.

@@
@@
-    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 avatarIsmael Luceno <ismael@iodev.co.uk>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent 5049c15e
...@@ -124,9 +124,10 @@ static int snd_solo_pcm_open(struct snd_pcm_substream *ss) ...@@ -124,9 +124,10 @@ static int snd_solo_pcm_open(struct snd_pcm_substream *ss)
if (solo_pcm == NULL) if (solo_pcm == NULL)
goto oom; goto oom;
solo_pcm->g723_buf = pci_alloc_consistent(solo_dev->pdev, solo_pcm->g723_buf = dma_alloc_coherent(&solo_dev->pdev->dev,
G723_PERIOD_BYTES, G723_PERIOD_BYTES,
&solo_pcm->g723_dma); &solo_pcm->g723_dma,
GFP_KERNEL);
if (solo_pcm->g723_buf == NULL) if (solo_pcm->g723_buf == NULL)
goto oom; goto oom;
...@@ -148,8 +149,8 @@ static int snd_solo_pcm_close(struct snd_pcm_substream *ss) ...@@ -148,8 +149,8 @@ static int snd_solo_pcm_close(struct snd_pcm_substream *ss)
struct solo_snd_pcm *solo_pcm = snd_pcm_substream_chip(ss); struct solo_snd_pcm *solo_pcm = snd_pcm_substream_chip(ss);
snd_pcm_substream_chip(ss) = solo_pcm->solo_dev; snd_pcm_substream_chip(ss) = solo_pcm->solo_dev;
pci_free_consistent(solo_pcm->solo_dev->pdev, G723_PERIOD_BYTES, dma_free_coherent(&solo_pcm->solo_dev->pdev->dev, G723_PERIOD_BYTES,
solo_pcm->g723_buf, solo_pcm->g723_dma); solo_pcm->g723_buf, solo_pcm->g723_dma);
kfree(solo_pcm); kfree(solo_pcm);
return 0; return 0;
......
...@@ -37,16 +37,16 @@ int solo_p2m_dma(struct solo_dev *solo_dev, int wr, ...@@ -37,16 +37,16 @@ int solo_p2m_dma(struct solo_dev *solo_dev, int wr,
if (WARN_ON_ONCE(!size)) if (WARN_ON_ONCE(!size))
return -EINVAL; return -EINVAL;
dma_addr = pci_map_single(solo_dev->pdev, sys_addr, size, dma_addr = dma_map_single(&solo_dev->pdev->dev, sys_addr, size,
wr ? PCI_DMA_TODEVICE : PCI_DMA_FROMDEVICE); wr ? DMA_TO_DEVICE : DMA_FROM_DEVICE);
if (pci_dma_mapping_error(solo_dev->pdev, dma_addr)) if (dma_mapping_error(&solo_dev->pdev->dev, dma_addr))
return -ENOMEM; return -ENOMEM;
ret = solo_p2m_dma_t(solo_dev, wr, dma_addr, ext_addr, size, ret = solo_p2m_dma_t(solo_dev, wr, dma_addr, ext_addr, size,
repeat, ext_size); repeat, ext_size);
pci_unmap_single(solo_dev->pdev, dma_addr, size, dma_unmap_single(&solo_dev->pdev->dev, dma_addr, size,
wr ? PCI_DMA_TODEVICE : PCI_DMA_FROMDEVICE); wr ? DMA_TO_DEVICE : DMA_FROM_DEVICE);
return ret; return ret;
} }
......
...@@ -1286,10 +1286,11 @@ static struct solo_enc_dev *solo_enc_alloc(struct solo_dev *solo_dev, ...@@ -1286,10 +1286,11 @@ static struct solo_enc_dev *solo_enc_alloc(struct solo_dev *solo_dev,
memcpy(solo_enc->jpeg_header, jpeg_header, solo_enc->jpeg_len); memcpy(solo_enc->jpeg_header, jpeg_header, solo_enc->jpeg_len);
solo_enc->desc_nelts = 32; solo_enc->desc_nelts = 32;
solo_enc->desc_items = pci_alloc_consistent(solo_dev->pdev, solo_enc->desc_items = dma_alloc_coherent(&solo_dev->pdev->dev,
sizeof(struct solo_p2m_desc) * sizeof(struct solo_p2m_desc) *
solo_enc->desc_nelts, solo_enc->desc_nelts,
&solo_enc->desc_dma); &solo_enc->desc_dma,
GFP_KERNEL);
ret = -ENOMEM; ret = -ENOMEM;
if (solo_enc->desc_items == NULL) if (solo_enc->desc_items == NULL)
goto hdl_free; goto hdl_free;
...@@ -1317,9 +1318,9 @@ static struct solo_enc_dev *solo_enc_alloc(struct solo_dev *solo_dev, ...@@ -1317,9 +1318,9 @@ static struct solo_enc_dev *solo_enc_alloc(struct solo_dev *solo_dev,
vdev_release: vdev_release:
video_device_release(solo_enc->vfd); video_device_release(solo_enc->vfd);
pci_free: pci_free:
pci_free_consistent(solo_enc->solo_dev->pdev, dma_free_coherent(&solo_enc->solo_dev->pdev->dev,
sizeof(struct solo_p2m_desc) * solo_enc->desc_nelts, sizeof(struct solo_p2m_desc) * solo_enc->desc_nelts,
solo_enc->desc_items, solo_enc->desc_dma); solo_enc->desc_items, solo_enc->desc_dma);
hdl_free: hdl_free:
v4l2_ctrl_handler_free(hdl); v4l2_ctrl_handler_free(hdl);
kfree(solo_enc); kfree(solo_enc);
...@@ -1331,9 +1332,9 @@ static void solo_enc_free(struct solo_enc_dev *solo_enc) ...@@ -1331,9 +1332,9 @@ static void solo_enc_free(struct solo_enc_dev *solo_enc)
if (solo_enc == NULL) if (solo_enc == NULL)
return; return;
pci_free_consistent(solo_enc->solo_dev->pdev, dma_free_coherent(&solo_enc->solo_dev->pdev->dev,
sizeof(struct solo_p2m_desc) * solo_enc->desc_nelts, sizeof(struct solo_p2m_desc) * solo_enc->desc_nelts,
solo_enc->desc_items, solo_enc->desc_dma); solo_enc->desc_items, solo_enc->desc_dma);
video_unregister_device(solo_enc->vfd); video_unregister_device(solo_enc->vfd);
v4l2_ctrl_handler_free(&solo_enc->hdl); v4l2_ctrl_handler_free(&solo_enc->hdl);
kfree(solo_enc); kfree(solo_enc);
...@@ -1346,9 +1347,9 @@ int solo_enc_v4l2_init(struct solo_dev *solo_dev, unsigned nr) ...@@ -1346,9 +1347,9 @@ int solo_enc_v4l2_init(struct solo_dev *solo_dev, unsigned nr)
init_waitqueue_head(&solo_dev->ring_thread_wait); init_waitqueue_head(&solo_dev->ring_thread_wait);
solo_dev->vh_size = sizeof(vop_header); solo_dev->vh_size = sizeof(vop_header);
solo_dev->vh_buf = pci_alloc_consistent(solo_dev->pdev, solo_dev->vh_buf = dma_alloc_coherent(&solo_dev->pdev->dev,
solo_dev->vh_size, solo_dev->vh_size,
&solo_dev->vh_dma); &solo_dev->vh_dma, GFP_KERNEL);
if (solo_dev->vh_buf == NULL) if (solo_dev->vh_buf == NULL)
return -ENOMEM; return -ENOMEM;
...@@ -1363,8 +1364,8 @@ int solo_enc_v4l2_init(struct solo_dev *solo_dev, unsigned nr) ...@@ -1363,8 +1364,8 @@ int solo_enc_v4l2_init(struct solo_dev *solo_dev, unsigned nr)
while (i--) while (i--)
solo_enc_free(solo_dev->v4l2_enc[i]); solo_enc_free(solo_dev->v4l2_enc[i]);
pci_free_consistent(solo_dev->pdev, solo_dev->vh_size, dma_free_coherent(&solo_dev->pdev->dev, solo_dev->vh_size,
solo_dev->vh_buf, solo_dev->vh_dma); solo_dev->vh_buf, solo_dev->vh_dma);
solo_dev->vh_buf = NULL; solo_dev->vh_buf = NULL;
return ret; return ret;
} }
...@@ -1391,6 +1392,6 @@ void solo_enc_v4l2_exit(struct solo_dev *solo_dev) ...@@ -1391,6 +1392,6 @@ void solo_enc_v4l2_exit(struct solo_dev *solo_dev)
solo_enc_free(solo_dev->v4l2_enc[i]); solo_enc_free(solo_dev->v4l2_enc[i]);
if (solo_dev->vh_buf) if (solo_dev->vh_buf)
pci_free_consistent(solo_dev->pdev, solo_dev->vh_size, dma_free_coherent(&solo_dev->pdev->dev, solo_dev->vh_size,
solo_dev->vh_buf, solo_dev->vh_dma); solo_dev->vh_buf, solo_dev->vh_dma);
} }
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