i40e/i40evf: Use dma_set_mask_and_coherent
authorMitch Williams <mitch.a.williams@intel.com>
Tue, 11 Feb 2014 08:26:33 +0000 (08:26 +0000)
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>
Fri, 14 Mar 2014 23:30:05 +0000 (16:30 -0700)
In Linux 3.13, dma_set_mask_and_coherent was introduced, and we have
been encouraged to use it. It simplifies the DMA mapping code a bit as
well.

Change-ID: I66e340245af7d0dedfa8b40fec1f5e352754432e
Signed-off-by: Mitch Williams <mitch.a.williams@intel.com>
Signed-off-by: Catherine Sullivan <catherine.sullivan@intel.com>
Tested-by: Kavindya Deegala <kavindya.s.deegala@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
drivers/net/ethernet/intel/i40e/i40e_main.c
drivers/net/ethernet/intel/i40evf/i40evf_main.c

index 54e1462..7379e5a 100644 (file)
@@ -7970,16 +7970,12 @@ static int i40e_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
                return err;
 
        /* set up for high or low dma */
-       if (!dma_set_mask(&pdev->dev, DMA_BIT_MASK(64))) {
-               /* coherent mask for the same size will always succeed if
-                * dma_set_mask does
-                */
-               dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(64));
-       } else if (!dma_set_mask(&pdev->dev, DMA_BIT_MASK(32))) {
-               dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
-       } else {
-               dev_err(&pdev->dev, "DMA configuration failed: %d\n", err);
-               err = -EIO;
+       err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
+       if (err)
+               err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
+       if (err) {
+               dev_err(&pdev->dev,
+                       "DMA configuration failed: 0x%x\n", err);
                goto err_dma;
        }
 
index 8daab3a..d62e27f 100644 (file)
@@ -2182,17 +2182,12 @@ static int i40evf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
        if (err)
                return err;
 
-       if (!dma_set_mask(&pdev->dev, DMA_BIT_MASK(64))) {
-               /* coherent mask for the same size will always succeed if
-                * dma_set_mask does
-                */
-               dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(64));
-       } else if (!dma_set_mask(&pdev->dev, DMA_BIT_MASK(32))) {
-               dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
-       } else {
-               dev_err(&pdev->dev, "%s: DMA configuration failed: %d\n",
-                        __func__, err);
-               err = -EIO;
+       err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
+       if (err)
+               err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
+       if (err) {
+               dev_err(&pdev->dev,
+                       "DMA configuration failed: 0x%x\n", err);
                goto err_dma;
        }