aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/hpsa.c
diff options
context:
space:
mode:
authorStephen M. Cameron <scameron@beardog.cce.hp.com>2010-06-16 14:51:30 -0400
committerJames Bottomley <James.Bottomley@suse.de>2010-07-27 13:01:58 -0400
commita51fd47f1b8f2b9937011c433269d2ec182b9879 (patch)
tree90e83e24c37d1aabeb23d0f77446d437ef216d84 /drivers/scsi/hpsa.c
parent12d2cd4711b9e3ddcf911281ec4fe511b5cfff63 (diff)
[SCSI] hpsa: factor out hpsa_find_cfg_addrs.
Rationale for this is that I will also need to use this code in fixing kdump host reset code prior to having the hba structure. 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.c34
1 files changed, 22 insertions, 12 deletions
diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index f5305a4b8b32..44f81a0ae531 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -3345,29 +3345,39 @@ static int __devinit hpsa_wait_for_board_ready(struct ctlr_info *h)
3345 return -ENODEV; 3345 return -ENODEV;
3346} 3346}
3347 3347
3348static int __devinit hpsa_find_cfg_addrs(struct pci_dev *pdev,
3349 void __iomem *vaddr, u32 *cfg_base_addr, u64 *cfg_base_addr_index,
3350 u64 *cfg_offset)
3351{
3352 *cfg_base_addr = readl(vaddr + SA5_CTCFG_OFFSET);
3353 *cfg_offset = readl(vaddr + SA5_CTMEM_OFFSET);
3354 *cfg_base_addr &= (u32) 0x0000ffff;
3355 *cfg_base_addr_index = find_PCI_BAR_index(pdev, *cfg_base_addr);
3356 if (*cfg_base_addr_index == -1) {
3357 dev_warn(&pdev->dev, "cannot find cfg_base_addr_index\n");
3358 return -ENODEV;
3359 }
3360 return 0;
3361}
3362
3348static int __devinit hpsa_find_cfgtables(struct ctlr_info *h) 3363static int __devinit hpsa_find_cfgtables(struct ctlr_info *h)
3349{ 3364{
3350 u64 cfg_offset; 3365 u64 cfg_offset;
3351 u32 cfg_base_addr; 3366 u32 cfg_base_addr;
3352 u64 cfg_base_addr_index; 3367 u64 cfg_base_addr_index;
3353 u32 trans_offset; 3368 u32 trans_offset;
3369 int rc;
3354 3370
3355 /* get the address index number */ 3371 rc = hpsa_find_cfg_addrs(h->pdev, h->vaddr, &cfg_base_addr,
3356 cfg_base_addr = readl(h->vaddr + SA5_CTCFG_OFFSET); 3372 &cfg_base_addr_index, &cfg_offset);
3357 cfg_base_addr &= (u32) 0x0000ffff; 3373 if (rc)
3358 cfg_base_addr_index = find_PCI_BAR_index(h->pdev, cfg_base_addr); 3374 return rc;
3359 if (cfg_base_addr_index == -1) {
3360 dev_warn(&h->pdev->dev, "cannot find cfg_base_addr_index\n");
3361 return -ENODEV;
3362 }
3363 cfg_offset = readl(h->vaddr + SA5_CTMEM_OFFSET);
3364 h->cfgtable = remap_pci_mem(pci_resource_start(h->pdev, 3375 h->cfgtable = remap_pci_mem(pci_resource_start(h->pdev,
3365 cfg_base_addr_index) + cfg_offset, 3376 cfg_base_addr_index) + cfg_offset, sizeof(*h->cfgtable));
3366 sizeof(h->cfgtable));
3367 if (!h->cfgtable) 3377 if (!h->cfgtable)
3368 return -ENOMEM; 3378 return -ENOMEM;
3369 /* Find performant mode table. */ 3379 /* Find performant mode table. */
3370 trans_offset = readl(&(h->cfgtable->TransMethodOffset)); 3380 trans_offset = readl(&h->cfgtable->TransMethodOffset);
3371 h->transtable = remap_pci_mem(pci_resource_start(h->pdev, 3381 h->transtable = remap_pci_mem(pci_resource_start(h->pdev,
3372 cfg_base_addr_index)+cfg_offset+trans_offset, 3382 cfg_base_addr_index)+cfg_offset+trans_offset,
3373 sizeof(*h->transtable)); 3383 sizeof(*h->transtable));