Commit a01df0fe authored by Roland Dreier's avatar Roland Dreier

mlx4_core: Use pci_request_regions()

The old code used two calls to pci_request_region() to get the two BARs
for the mlx4 device, for no particularly good reason.  Clean up the code
a little by converting this to a single call to pci_request_regions().
Signed-off-by: default avatarRoland Dreier <rolandd@cisco.com>
parent e07cccf4
...@@ -1070,18 +1070,12 @@ static int __mlx4_init_one(struct pci_dev *pdev, const struct pci_device_id *id) ...@@ -1070,18 +1070,12 @@ static int __mlx4_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
goto err_disable_pdev; goto err_disable_pdev;
} }
err = pci_request_region(pdev, 0, DRV_NAME); err = pci_request_regions(pdev, DRV_NAME);
if (err) { if (err) {
dev_err(&pdev->dev, "Cannot request control region, aborting.\n"); dev_err(&pdev->dev, "Couldn't get PCI resources, aborting\n");
goto err_disable_pdev; goto err_disable_pdev;
} }
err = pci_request_region(pdev, 2, DRV_NAME);
if (err) {
dev_err(&pdev->dev, "Cannot request UAR region, aborting.\n");
goto err_release_bar0;
}
pci_set_master(pdev); pci_set_master(pdev);
err = pci_set_dma_mask(pdev, DMA_BIT_MASK(64)); err = pci_set_dma_mask(pdev, DMA_BIT_MASK(64));
...@@ -1090,7 +1084,7 @@ static int __mlx4_init_one(struct pci_dev *pdev, const struct pci_device_id *id) ...@@ -1090,7 +1084,7 @@ static int __mlx4_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
if (err) { if (err) {
dev_err(&pdev->dev, "Can't set PCI DMA mask, aborting.\n"); dev_err(&pdev->dev, "Can't set PCI DMA mask, aborting.\n");
goto err_release_bar2; goto err_release_regions;
} }
} }
err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64)); err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64));
...@@ -1101,7 +1095,7 @@ static int __mlx4_init_one(struct pci_dev *pdev, const struct pci_device_id *id) ...@@ -1101,7 +1095,7 @@ static int __mlx4_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
if (err) { if (err) {
dev_err(&pdev->dev, "Can't set consistent PCI DMA mask, " dev_err(&pdev->dev, "Can't set consistent PCI DMA mask, "
"aborting.\n"); "aborting.\n");
goto err_release_bar2; goto err_release_regions;
} }
} }
...@@ -1110,7 +1104,7 @@ static int __mlx4_init_one(struct pci_dev *pdev, const struct pci_device_id *id) ...@@ -1110,7 +1104,7 @@ static int __mlx4_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
dev_err(&pdev->dev, "Device struct alloc failed, " dev_err(&pdev->dev, "Device struct alloc failed, "
"aborting.\n"); "aborting.\n");
err = -ENOMEM; err = -ENOMEM;
goto err_release_bar2; goto err_release_regions;
} }
dev = &priv->dev; dev = &priv->dev;
...@@ -1205,11 +1199,8 @@ static int __mlx4_init_one(struct pci_dev *pdev, const struct pci_device_id *id) ...@@ -1205,11 +1199,8 @@ static int __mlx4_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
err_free_dev: err_free_dev:
kfree(priv); kfree(priv);
err_release_bar2: err_release_regions:
pci_release_region(pdev, 2); pci_release_regions(pdev);
err_release_bar0:
pci_release_region(pdev, 0);
err_disable_pdev: err_disable_pdev:
pci_disable_device(pdev); pci_disable_device(pdev);
...@@ -1265,8 +1256,7 @@ static void mlx4_remove_one(struct pci_dev *pdev) ...@@ -1265,8 +1256,7 @@ static void mlx4_remove_one(struct pci_dev *pdev)
pci_disable_msix(pdev); pci_disable_msix(pdev);
kfree(priv); kfree(priv);
pci_release_region(pdev, 2); pci_release_regions(pdev);
pci_release_region(pdev, 0);
pci_disable_device(pdev); pci_disable_device(pdev);
pci_set_drvdata(pdev, NULL); pci_set_drvdata(pdev, NULL);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment