summaryrefslogtreecommitdiffstats
path: root/drivers/scsi/hpsa.c
diff options
context:
space:
mode:
authorStephen M. Cameron <scameron@beardog.cce.hp.com>2010-05-27 15:13:17 -0500
committerJames Bottomley <James.Bottomley@suse.de>2010-07-27 12:01:07 -0500
commit77c4495c17d7508bdef1cfd2c3c933ff5379908b (patch)
tree74d1ee0f3a580d92956416763f193ee417d2ac82 /drivers/scsi/hpsa.c
parent2c4c8c8b662286230a798c60408d217aeab55f7f (diff)
[SCSI] hpsa: factor out hpsa_find_cfgtables
Signed-off-by: Stephen M. Cameron <scameron@beardog.cce.hp.com> Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Diffstat (limited to 'drivers/scsi/hpsa.c')
-rw-r--r--drivers/scsi/hpsa.c50
1 files changed, 30 insertions, 20 deletions
diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 66c4fc306f2..cb0cc0993b9 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -3317,12 +3317,39 @@ static int __devinit hpsa_wait_for_board_ready(struct ctlr_info *h)
return -ENODEV;
}
-static int __devinit hpsa_pci_init(struct ctlr_info *h)
+static int __devinit hpsa_find_cfgtables(struct ctlr_info *h)
{
u64 cfg_offset;
u32 cfg_base_addr;
u64 cfg_base_addr_index;
u32 trans_offset;
+
+ /* get the address index number */
+ cfg_base_addr = readl(h->vaddr + SA5_CTCFG_OFFSET);
+ cfg_base_addr &= (u32) 0x0000ffff;
+ cfg_base_addr_index = find_PCI_BAR_index(h->pdev, cfg_base_addr);
+ if (cfg_base_addr_index == -1) {
+ dev_warn(&h->pdev->dev, "cannot find cfg_base_addr_index\n");
+ return -ENODEV;
+ }
+ cfg_offset = readl(h->vaddr + SA5_CTMEM_OFFSET);
+ h->cfgtable = remap_pci_mem(pci_resource_start(h->pdev,
+ cfg_base_addr_index) + cfg_offset,
+ sizeof(h->cfgtable));
+ if (!h->cfgtable)
+ return -ENOMEM;
+ /* Find performant mode table. */
+ trans_offset = readl(&(h->cfgtable->TransMethodOffset));
+ h->transtable = remap_pci_mem(pci_resource_start(h->pdev,
+ cfg_base_addr_index)+cfg_offset+trans_offset,
+ sizeof(*h->transtable));
+ if (!h->transtable)
+ return -ENOMEM;
+ return 0;
+}
+
+static int __devinit hpsa_pci_init(struct ctlr_info *h)
+{
int i, prod_index, err;
prod_index = hpsa_lookup_board_id(h->pdev, &h->board_id);
@@ -3356,26 +3383,9 @@ static int __devinit hpsa_pci_init(struct ctlr_info *h)
err = hpsa_wait_for_board_ready(h);
if (err)
goto err_out_free_res;
-
- /* get the address index number */
- cfg_base_addr = readl(h->vaddr + SA5_CTCFG_OFFSET);
- cfg_base_addr &= (u32) 0x0000ffff;
- cfg_base_addr_index = find_PCI_BAR_index(h->pdev, cfg_base_addr);
- if (cfg_base_addr_index == -1) {
- dev_warn(&h->pdev->dev, "cannot find cfg_base_addr_index\n");
- err = -ENODEV;
+ err = hpsa_find_cfgtables(h);
+ if (err)
goto err_out_free_res;
- }
-
- cfg_offset = readl(h->vaddr + SA5_CTMEM_OFFSET);
- h->cfgtable = remap_pci_mem(pci_resource_start(h->pdev,
- cfg_base_addr_index) + cfg_offset,
- sizeof(h->cfgtable));
- /* Find performant mode table. */
- trans_offset = readl(&(h->cfgtable->TransMethodOffset));
- h->transtable = remap_pci_mem(pci_resource_start(h->pdev,
- cfg_base_addr_index)+cfg_offset+trans_offset,
- sizeof(*h->transtable));
h->max_commands = readl(&(h->cfgtable->MaxPerformantModeCommands));
h->maxsgentries = readl(&(h->cfgtable->MaxScatterGatherElements));