Re: [PATCH V2] message: fusion: switch from 'pci_' to 'dma_' API

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

Le 28/09/2021 à 05:42, Qing Wang a écrit :
The wrappers in include/linux/pci-dma-compat.h should go away.

The patch has been generated with the coccinelle script below.
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)

While at it, some 'dma_set_mask()/dma_set_coherent_mask()' have been
updated to a much less verbose 'dma_set_mask_and_coherent()'.

Signed-off-by: Qing Wang <wangqing@xxxxxxxx>
---
  drivers/message/fusion/mptbase.c | 31 +++++++++----------------------
  1 file changed, 9 insertions(+), 22 deletions(-)

diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
index 7f7abc9..c255d8a
--- a/drivers/message/fusion/mptbase.c
+++ b/drivers/message/fusion/mptbase.c
@@ -1666,16 +1666,12 @@ mpt_mapresources(MPT_ADAPTER *ioc)
  		const uint64_t required_mask = dma_get_required_mask
  		    (&pdev->dev);
  		if (required_mask > DMA_BIT_MASK(32)
-			&& !pci_set_dma_mask(pdev, DMA_BIT_MASK(64))
-			&& !pci_set_consistent_dma_mask(pdev,
-						 DMA_BIT_MASK(64))) {
+			&& dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64))) {

The logic is reversed here. We used to have a !, but it is now missing.

CJ

  			ioc->dma_mask = DMA_BIT_MASK(64);
  			dinitprintk(ioc, printk(MYIOC_s_INFO_FMT
  				": 64 BIT PCI BUS DMA ADDRESSING SUPPORTED\n",
  				ioc->name));
-		} else if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(32))
-			&& !pci_set_consistent_dma_mask(pdev,
-						DMA_BIT_MASK(32))) {
+		} else if (!dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32))) {
  			ioc->dma_mask = DMA_BIT_MASK(32);
  			dinitprintk(ioc, printk(MYIOC_s_INFO_FMT
  				": 32 BIT PCI BUS DMA ADDRESSING SUPPORTED\n",
@@ -1686,9 +1682,7 @@ mpt_mapresources(MPT_ADAPTER *ioc)
  			goto out_pci_release_region;
  		}
  	} else {
-		if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(32))
-			&& !pci_set_consistent_dma_mask(pdev,
-						DMA_BIT_MASK(32))) {
+		if (!dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32))) {
  			ioc->dma_mask = DMA_BIT_MASK(32);
  			dinitprintk(ioc, printk(MYIOC_s_INFO_FMT
  				": 32 BIT PCI BUS DMA ADDRESSING SUPPORTED\n",
@@ -4452,9 +4446,7 @@ PrimeIocFifos(MPT_ADAPTER *ioc)
  		 */
  		if (ioc->pcidev->device == MPI_MANUFACTPAGE_DEVID_SAS1078 &&
  		    ioc->dma_mask > DMA_BIT_MASK(35)) {
-			if (!pci_set_dma_mask(ioc->pcidev, DMA_BIT_MASK(32))
-			    && !pci_set_consistent_dma_mask(ioc->pcidev,
-			    DMA_BIT_MASK(32))) {
+			if (!dma_set_mask_and_coherent(&ioc->pcidev, DMA_BIT_MASK(32))) {
  				dma_mask = DMA_BIT_MASK(35);
  				d36memprintk(ioc, printk(MYIOC_s_DEBUG_FMT
  				    "setting 35 bit addressing for "
@@ -4462,10 +4454,7 @@ PrimeIocFifos(MPT_ADAPTER *ioc)
  				    ioc->name));
  			} else {
  				/*Reseting DMA mask to 64 bit*/
-				pci_set_dma_mask(ioc->pcidev,
-					DMA_BIT_MASK(64));
-				pci_set_consistent_dma_mask(ioc->pcidev,
-					DMA_BIT_MASK(64));
+				dma_set_mask_and_coherent(&ioc->pcidev, DMA_BIT_MASK(64));
printk(MYIOC_s_ERR_FMT
  				    "failed setting 35 bit addressing for "
@@ -4600,9 +4589,8 @@ PrimeIocFifos(MPT_ADAPTER *ioc)
  		alloc_dma += ioc->reply_sz;
  	}
- if (dma_mask == DMA_BIT_MASK(35) && !pci_set_dma_mask(ioc->pcidev,
-	    ioc->dma_mask) && !pci_set_consistent_dma_mask(ioc->pcidev,
-	    ioc->dma_mask))
+	if (dma_mask == DMA_BIT_MASK(35) &&
+	    !dma_set_mask_and_coherent(&ioc->pcidev, ioc->dma_mask))
  		d36memprintk(ioc, printk(MYIOC_s_DEBUG_FMT
  		    "restoring 64 bit addressing\n", ioc->name));
@@ -4625,9 +4613,8 @@ PrimeIocFifos(MPT_ADAPTER *ioc)
  		ioc->sense_buf_pool = NULL;
  	}
- if (dma_mask == DMA_BIT_MASK(35) && !pci_set_dma_mask(ioc->pcidev,
-	    DMA_BIT_MASK(64)) && !pci_set_consistent_dma_mask(ioc->pcidev,
-	    DMA_BIT_MASK(64)))
+	if (dma_mask == DMA_BIT_MASK(35) &&
+	    !dma_set_mask_and_coherent(&ioc->pcidev, DMA_BIT_MASK(64)))
  		d36memprintk(ioc, printk(MYIOC_s_DEBUG_FMT
  		    "restoring 64 bit addressing\n", ioc->name));




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]

  Powered by Linux