[5/4] RDMA/efa : Remove pci-dma-compat wrapper APIs
diff mbox series

Message ID 20200809074517.GA4419@blackclown
State New
Headers show
Series
  • Infiniband Subsystem: Remove pci-dma-compat wrapper APIs.
Related show

Commit Message

Suraj Upadhyay Aug. 9, 2020, 7:45 a.m. UTC
The legacy API wrappers in include/linux/pci-dma-compat.h
should go away as it creates unnecessary midlayering
for include/linux/dma-mapping.h APIs.

Instead use dma-mapping.h APIs directly.

The patch has been generated with the coccinelle script below
and compile-tested.

@@@@
- 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_consistent_dma_mask(E1, E2)
+ dma_set_coherent_mask(&E1->dev, E2)

@@ expression E1, E2; @@
- pci_set_dma_mask(E1, E2)
+ dma_set_mask(&E1->dev, E2)

Signed-off-by: Suraj Upadhyay <usuraj35@gmail.com>
---
 drivers/infiniband/hw/efa/efa_main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Joe Perches Aug. 9, 2020, 8:10 a.m. UTC | #1
On Sun, 2020-08-09 at 13:15 +0530, Suraj Upadhyay wrote:
> The legacy API wrappers in include/linux/pci-dma-compat.h
> should go away as it creates unnecessary midlayering
> for include/linux/dma-mapping.h APIs.
> 
> Instead use dma-mapping.h APIs directly.
> 
> The patch has been generated with the coccinelle script below
> and compile-tested.
[]
> diff --git a/drivers/infiniband/hw/efa/efa_main.c b/drivers/infiniband/hw/efa/efa_main.c
[]
> @@ -405,13 +405,13 @@ static int efa_device_init(struct efa_com_dev *edev, struct pci_dev *pdev)
>                 return err;
>         }
> 
> -       err = pci_set_dma_mask(pdev, DMA_BIT_MASK(dma_width));
> +       err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(dma_width));
>         if (err) {
>                 dev_err(&pdev->dev, "pci_set_dma_mask failed %d\n", err);

Coccinelle is great for some things, but not
necessarily for these sorts of changes in an
completely automated way.

The dev_err messages also need to be changed
as the format string contains the old name.

> -       err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(dma_width));
> +       err = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(dma_width));
>         if (err) {
>                 dev_err(&pdev->dev,
>                         "err_pci_set_consistent_dma_mask failed %d\n",

Patch
diff mbox series

diff --git a/drivers/infiniband/hw/efa/efa_main.c b/drivers/infiniband/hw/efa/efa_main.c
index 92d701146320..bcc931ad71b0 100644
--- a/drivers/infiniband/hw/efa/efa_main.c
+++ b/drivers/infiniband/hw/efa/efa_main.c
@@ -405,13 +405,13 @@  static int efa_device_init(struct efa_com_dev *edev, struct pci_dev *pdev)
                return err;
        }

-       err = pci_set_dma_mask(pdev, DMA_BIT_MASK(dma_width));
+       err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(dma_width));
        if (err) {
                dev_err(&pdev->dev, "pci_set_dma_mask failed %d\n", err);
                return err;
        }

-       err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(dma_width));
+       err = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(dma_width));
        if (err) {
                dev_err(&pdev->dev,
                        "err_pci_set_consistent_dma_mask failed %d\n",