diff options
author | Stephen M. Cameron <scameron@beardog.cce.hp.com> | 2010-05-27 15:12:52 -0500 |
---|---|---|
committer | James Bottomley <James.Bottomley@suse.de> | 2010-07-27 12:01:03 -0500 |
commit | e5c880d1d5923c341ac7ba537fb1e6b73c5977a2 (patch) | |
tree | c5468265e722e4ba11acbf8b94fd51d96c269e81 /drivers/scsi/hpsa.c | |
parent | 55c06c7171f63aaac1f9009729d1cb5107fa0626 (diff) | |
download | linux-e5c880d1d5923c341ac7ba537fb1e6b73c5977a2.tar.bz2 |
[SCSI] hpsa: factor out hpsa_lookup_board_id
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.c | 58 |
1 files changed, 31 insertions, 27 deletions
diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c index d6f897016e24..b6c6e7f88fa4 100644 --- a/drivers/scsi/hpsa.c +++ b/drivers/scsi/hpsa.c @@ -3256,37 +3256,44 @@ default_int_mode: h->intr[PERF_MODE_INT] = h->pdev->irq; } +static int __devinit hpsa_lookup_board_id(struct pci_dev *pdev, u32 *board_id) +{ + int i; + u32 subsystem_vendor_id, subsystem_device_id; + + subsystem_vendor_id = pdev->subsystem_vendor; + subsystem_device_id = pdev->subsystem_device; + *board_id = ((subsystem_device_id << 16) & 0xffff0000) | + subsystem_vendor_id; + + for (i = 0; i < ARRAY_SIZE(products); i++) + if (*board_id == products[i].board_id) + return i; + + if (subsystem_vendor_id != PCI_VENDOR_ID_HP || !hpsa_allow_any) { + dev_warn(&pdev->dev, "unrecognized board ID: " + "0x%08x, ignoring.\n", *board_id); + return -ENODEV; + } + return ARRAY_SIZE(products) - 1; /* generic unknown smart array */ +} + static int __devinit hpsa_pci_init(struct ctlr_info *h) { - ushort subsystem_vendor_id, subsystem_device_id, command; - u32 board_id, scratchpad = 0; + ushort command; + u32 scratchpad = 0; u64 cfg_offset; u32 cfg_base_addr; u64 cfg_base_addr_index; u32 trans_offset; int i, prod_index, err; - subsystem_vendor_id = h->pdev->subsystem_vendor; - subsystem_device_id = h->pdev->subsystem_device; - board_id = (((u32) (subsystem_device_id << 16) & 0xffff0000) | - subsystem_vendor_id); - - for (i = 0; i < ARRAY_SIZE(products); i++) - if (board_id == products[i].board_id) - break; - - prod_index = i; + prod_index = hpsa_lookup_board_id(h->pdev, &h->board_id); + if (prod_index < 0) + return -ENODEV; + h->product_name = products[prod_index].product_name; + h->access = *(products[prod_index].access); - if (prod_index == ARRAY_SIZE(products)) { - prod_index--; - if (subsystem_vendor_id != PCI_VENDOR_ID_HP || - !hpsa_allow_any) { - dev_warn(&h->pdev->dev, "unrecognized board ID:" - " 0x%08lx, ignoring.\n", - (unsigned long) board_id); - return -ENODEV; - } - } /* check to see if controller has been disabled * BEFORE trying to enable it */ @@ -3312,7 +3319,7 @@ static int __devinit hpsa_pci_init(struct ctlr_info *h) /* If the kernel supports MSI/MSI-X we will try to enable that, * else we use the IO-APIC interrupt assigned to us by system ROM. */ - hpsa_interrupt_mode(h, board_id); + hpsa_interrupt_mode(h, h->board_id); /* find the memory BAR */ for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) { @@ -3364,7 +3371,6 @@ static int __devinit hpsa_pci_init(struct ctlr_info *h) cfg_base_addr_index)+cfg_offset+trans_offset, sizeof(*h->transtable)); - h->board_id = board_id; h->max_commands = readl(&(h->cfgtable->MaxPerformantModeCommands)); h->maxsgentries = readl(&(h->cfgtable->MaxScatterGatherElements)); @@ -3383,8 +3389,6 @@ static int __devinit hpsa_pci_init(struct ctlr_info *h) h->chainsize = 0; } - h->product_name = products[prod_index].product_name; - h->access = *(products[prod_index].access); /* Allow room for some ioctls */ h->nr_cmds = h->max_commands - 4; @@ -3410,7 +3414,7 @@ static int __devinit hpsa_pci_init(struct ctlr_info *h) * An ASIC bug may result in a prefetch beyond * physical memory. */ - if (board_id == 0x3225103C) { + if (h->board_id == 0x3225103C) { u32 dma_prefetch; dma_prefetch = readl(h->vaddr + I2O_DMA1_CFG); dma_prefetch |= 0x8000; |