media: mantis: 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 'mantis_alloc_buffers()' (mantis_dma.c) GFP_KERNEL can be used because it is called from 'mantis_dma_init()' which is only called from probe functions and no lock is taken in the between. @@ @@ - 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) Link: https://lore.kernel.org/linux-media/20200913145716.361507-1-christophe.jaillet@wanadoo.fr Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
This commit is contained in:
parent
c0e3bcb253
commit
2e774b3699
@ -52,8 +52,8 @@ int mantis_dma_exit(struct mantis_pci *mantis)
|
||||
mantis->buf_cpu,
|
||||
MANTIS_BUF_SIZE);
|
||||
|
||||
pci_free_consistent(mantis->pdev, MANTIS_BUF_SIZE,
|
||||
mantis->buf_cpu, mantis->buf_dma);
|
||||
dma_free_coherent(&mantis->pdev->dev, MANTIS_BUF_SIZE,
|
||||
mantis->buf_cpu, mantis->buf_dma);
|
||||
|
||||
mantis->buf_cpu = NULL;
|
||||
}
|
||||
@ -64,8 +64,8 @@ int mantis_dma_exit(struct mantis_pci *mantis)
|
||||
mantis->risc_cpu,
|
||||
MANTIS_RISC_SIZE);
|
||||
|
||||
pci_free_consistent(mantis->pdev, MANTIS_RISC_SIZE,
|
||||
mantis->risc_cpu, mantis->risc_dma);
|
||||
dma_free_coherent(&mantis->pdev->dev, MANTIS_RISC_SIZE,
|
||||
mantis->risc_cpu, mantis->risc_dma);
|
||||
|
||||
mantis->risc_cpu = NULL;
|
||||
}
|
||||
@ -77,9 +77,9 @@ EXPORT_SYMBOL_GPL(mantis_dma_exit);
|
||||
static inline int mantis_alloc_buffers(struct mantis_pci *mantis)
|
||||
{
|
||||
if (!mantis->buf_cpu) {
|
||||
mantis->buf_cpu = pci_alloc_consistent(mantis->pdev,
|
||||
MANTIS_BUF_SIZE,
|
||||
&mantis->buf_dma);
|
||||
mantis->buf_cpu = dma_alloc_coherent(&mantis->pdev->dev,
|
||||
MANTIS_BUF_SIZE,
|
||||
&mantis->buf_dma, GFP_KERNEL);
|
||||
if (!mantis->buf_cpu) {
|
||||
dprintk(MANTIS_ERROR, 1,
|
||||
"DMA buffer allocation failed");
|
||||
@ -92,9 +92,9 @@ static inline int mantis_alloc_buffers(struct mantis_pci *mantis)
|
||||
mantis->buf_cpu, MANTIS_BUF_SIZE);
|
||||
}
|
||||
if (!mantis->risc_cpu) {
|
||||
mantis->risc_cpu = pci_alloc_consistent(mantis->pdev,
|
||||
MANTIS_RISC_SIZE,
|
||||
&mantis->risc_dma);
|
||||
mantis->risc_cpu = dma_alloc_coherent(&mantis->pdev->dev,
|
||||
MANTIS_RISC_SIZE,
|
||||
&mantis->risc_dma, GFP_KERNEL);
|
||||
|
||||
if (!mantis->risc_cpu) {
|
||||
dprintk(MANTIS_ERROR, 1,
|
||||
|
@ -55,7 +55,7 @@ int mantis_pci_init(struct mantis_pci *mantis)
|
||||
goto fail0;
|
||||
}
|
||||
|
||||
err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
|
||||
err = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
|
||||
if (err != 0) {
|
||||
dprintk(MANTIS_ERROR, 1, "ERROR: Unable to obtain 32 bit DMA <%i>", err);
|
||||
ret = -ENOMEM;
|
||||
|
Loading…
Reference in New Issue
Block a user