aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/hpsa.c
diff options
context:
space:
mode:
authorStephen M. Cameron <scameron@beardog.cce.hp.com>2010-05-27 16:13:07 -0400
committerJames Bottomley <James.Bottomley@suse.de>2010-07-27 13:01:05 -0400
commit3a7774ceb89f02f78e269b5c900096b066b66c3c (patch)
treeebc98774eb2328758f3fe04f55b21df68c1dca73 /drivers/scsi/hpsa.c
parent6b3f4c52b29eee17285a6cd57071c9ac7736d172 (diff)
[SCSI] hpsa: factor out hpsa_find_memory_BAR
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, 19 insertions, 15 deletions
diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 66b7dcfb7276..0582f2fc11f0 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -3285,6 +3285,23 @@ static inline bool hpsa_board_disabled(struct pci_dev *pdev)
3285 return ((command & PCI_COMMAND_MEMORY) == 0); 3285 return ((command & PCI_COMMAND_MEMORY) == 0);
3286} 3286}
3287 3287
3288static int __devinit hpsa_pci_find_memory_BAR(struct ctlr_info *h,
3289 unsigned long *memory_bar)
3290{
3291 int i;
3292
3293 for (i = 0; i < DEVICE_COUNT_RESOURCE; i++)
3294 if (pci_resource_flags(h->pdev, i) & IORESOURCE_MEM) {
3295 /* addressing mode bits already removed */
3296 *memory_bar = pci_resource_start(h->pdev, i);
3297 dev_dbg(&h->pdev->dev, "memory BAR = %lx\n",
3298 *memory_bar);
3299 return 0;
3300 }
3301 dev_warn(&h->pdev->dev, "no memory BAR found\n");
3302 return -ENODEV;
3303}
3304
3288static int __devinit hpsa_pci_init(struct ctlr_info *h) 3305static int __devinit hpsa_pci_init(struct ctlr_info *h)
3289{ 3306{
3290 u32 scratchpad = 0; 3307 u32 scratchpad = 0;
@@ -3317,22 +3334,9 @@ static int __devinit hpsa_pci_init(struct ctlr_info *h)
3317 return err; 3334 return err;
3318 } 3335 }
3319 hpsa_interrupt_mode(h); 3336 hpsa_interrupt_mode(h);
3320 3337 err = hpsa_pci_find_memory_BAR(h, &h->paddr);
3321 /* find the memory BAR */ 3338 if (err)
3322 for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) {
3323 if (pci_resource_flags(h->pdev, i) & IORESOURCE_MEM)
3324 break;
3325 }
3326 if (i == DEVICE_COUNT_RESOURCE) {
3327 dev_warn(&h->pdev->dev, "no memory BAR found\n");
3328 err = -ENODEV;
3329 goto err_out_free_res; 3339 goto err_out_free_res;
3330 }
3331
3332 h->paddr = pci_resource_start(h->pdev, i); /* addressing mode bits
3333 * already removed
3334 */
3335
3336 h->vaddr = remap_pci_mem(h->paddr, 0x250); 3340 h->vaddr = remap_pci_mem(h->paddr, 0x250);
3337 3341
3338 /* Wait for the board to become ready. */ 3342 /* Wait for the board to become ready. */