Reserve the device PCI I/O and Memory resources.

Signed-off-by: John Soni Jose <sony.joh...@emulex.com>
Signed-off-by: Jayamohan Kallickal <jayamohan.kallic...@emulex.com>
---
 drivers/scsi/be2iscsi/be_main.c |   22 ++++++++++++++++++----
 1 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index 98490da..2f5eb9c 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -670,14 +670,20 @@ static int beiscsi_enable_pci(struct pci_dev *pcidev)
                return ret;
        }
 
+       ret = pci_request_regions(pcidev, DRV_NAME);
+       if (ret) {
+               dev_err(&pcidev->dev,
+                               "beiscsi_enable_pci - request region failed\n");
+               goto pci_dev_disable;
+       }
+
        pci_set_master(pcidev);
        ret = pci_set_dma_mask(pcidev, DMA_BIT_MASK(64));
        if (ret) {
                ret = pci_set_dma_mask(pcidev, DMA_BIT_MASK(32));
                if (ret) {
                        dev_err(&pcidev->dev, "Could not set PCI DMA Mask\n");
-                       pci_disable_device(pcidev);
-                       return ret;
+                       goto pci_region_release;
                } else {
                        ret = pci_set_consistent_dma_mask(pcidev,
                                                          DMA_BIT_MASK(32));
@@ -686,11 +692,17 @@ static int beiscsi_enable_pci(struct pci_dev *pcidev)
                ret = pci_set_consistent_dma_mask(pcidev, DMA_BIT_MASK(64));
                if (ret) {
                        dev_err(&pcidev->dev, "Could not set PCI DMA Mask\n");
-                       pci_disable_device(pcidev);
-                       return ret;
+                       goto pci_region_release;
                }
        }
        return 0;
+
+pci_region_release:
+       pci_release_regions(pcidev);
+pci_dev_disable:
+       pci_disable_device(pcidev);
+
+       return ret;
 }
 
 static int be_ctrl_init(struct beiscsi_hba *phba, struct pci_dev *pdev)
@@ -5277,6 +5289,7 @@ static void beiscsi_remove(struct pci_dev *pcidev)
        iscsi_host_free(phba->shost);
        pci_disable_pcie_error_reporting(pcidev);
        pci_set_drvdata(pcidev, NULL);
+       pci_release_regions(pcidev);
        pci_disable_device(pcidev);
 }
 
@@ -5757,6 +5770,7 @@ hba_free:
        pci_dev_put(phba->pcidev);
        iscsi_host_free(phba->shost);
 disable_pci:
+       pci_release_regions(pcidev);
        pci_disable_device(pcidev);
        return ret;
 }
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to