diff mbox series

HID: amd_sfh: switch from 'pci_' to 'dma_' API

Message ID 439924a3414563a6ccc26eddb75efba6f54521c4.1629663605.git.christophe.jaillet@wanadoo.fr
State Accepted
Commit e70b703347ddd594a94bbdb136fb2eb3e48f2289
Headers show
Series HID: amd_sfh: switch from 'pci_' to 'dma_' API | expand

Commit Message

Christophe JAILLET Aug. 22, 2021, 8:21 p.m. UTC
The wrappers in include/linux/pci-dma-compat.h should go away.

The patch has been generated with the coccinelle script below.

It has been 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_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: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
If needed, see post from Christoph Hellwig on the kernel-janitors ML:
   https://marc.info/?l=kernel-janitors&m=158745678307186&w=4

It is *NOT* been compile tested, but it looks safe enough!
---
 drivers/hid/amd-sfh-hid/amd_sfh_pcie.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Basavaraj Natikar Aug. 23, 2021, 5:08 a.m. UTC | #1
On 8/23/2021 1:51 AM, Christophe JAILLET wrote:
> [CAUTION: External Email]

>

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

>

> The patch has been generated with the coccinelle script below.

>

> It has been 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_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: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

> ---

> If needed, see post from Christoph Hellwig on the kernel-janitors ML:

>    https://marc.info/?l=kernel-janitors&m=158745678307186&w=4

>

> It is *NOT* been compile tested, but it looks safe enough!

> ---

>  drivers/hid/amd-sfh-hid/amd_sfh_pcie.c | 4 ++--

>  1 file changed, 2 insertions(+), 2 deletions(-)

>

> diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c

> index 8d68796aa905..fa313c75a8a0 100644

> --- a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c

> +++ b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c

> @@ -229,9 +229,9 @@ static int amd_mp2_pci_probe(struct pci_dev *pdev, const struct pci_device_id *i

>

>         privdata->mmio = pcim_iomap_table(pdev)[2];

>         pci_set_master(pdev);

> -       rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(64));

> +       rc = dma_set_mask(&pdev->dev, DMA_BIT_MASK(64));

>         if (rc) {

> -               rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));

> +               rc = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32));

>                 return rc;

>         }


Acked-by: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
Jiri Kosina Sept. 15, 2021, 2:28 p.m. UTC | #2
On Sun, 22 Aug 2021, Christophe JAILLET wrote:

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

> 

> The patch has been generated with the coccinelle script below.

> 

> It has been compile tested.

[ ... snip ... ]
> diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c

> index 8d68796aa905..fa313c75a8a0 100644

> --- a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c

> +++ b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c

> @@ -229,9 +229,9 @@ static int amd_mp2_pci_probe(struct pci_dev *pdev, const struct pci_device_id *i

>  

>  	privdata->mmio = pcim_iomap_table(pdev)[2];

>  	pci_set_master(pdev);

> -	rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(64));

> +	rc = dma_set_mask(&pdev->dev, DMA_BIT_MASK(64));

>  	if (rc) {

> -		rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));

> +		rc = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32));

>  		return rc;

>  	}

>  


Applied, thanks.

-- 
Jiri Kosina
SUSE Labs
diff mbox series

Patch

diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c
index 8d68796aa905..fa313c75a8a0 100644
--- a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c
+++ b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c
@@ -229,9 +229,9 @@  static int amd_mp2_pci_probe(struct pci_dev *pdev, const struct pci_device_id *i
 
 	privdata->mmio = pcim_iomap_table(pdev)[2];
 	pci_set_master(pdev);
-	rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(64));
+	rc = dma_set_mask(&pdev->dev, DMA_BIT_MASK(64));
 	if (rc) {
-		rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
+		rc = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32));
 		return rc;
 	}