cciss: factor out cciss_lookup_board_id

cciss: factor out cciss_lookup_board_id

Signed-off-by: Stephen M. Cameron <scameron@beardog.cce.hp.com>
Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
This commit is contained in:
Stephen M. Cameron 2010-07-19 13:44:55 -05:00 committed by Jens Axboe
parent 292e50dd39
commit 6539fa9b2e

View File

@ -3980,36 +3980,44 @@ static void __devinit cciss_interrupt_mode(ctlr_info_t *c, __u32 board_id)
return; return;
} }
static int __devinit cciss_pci_init(ctlr_info_t *c) static int __devinit cciss_lookup_board_id(struct pci_dev *pdev, u32 *board_id)
{ {
ushort subsystem_vendor_id, subsystem_device_id, command; int i;
__u32 board_id, scratchpad = 0; u32 subsystem_vendor_id, subsystem_device_id;
__u64 cfg_offset;
__u32 cfg_base_addr;
__u64 cfg_base_addr_index;
int i, prod_index, err;
__u32 trans_offset;
subsystem_vendor_id = c->pdev->subsystem_vendor; subsystem_vendor_id = pdev->subsystem_vendor;
subsystem_device_id = c->pdev->subsystem_device; subsystem_device_id = pdev->subsystem_device;
board_id = (((__u32) (subsystem_device_id << 16) & 0xffff0000) | *board_id = ((subsystem_device_id << 16) & 0xffff0000) |
subsystem_vendor_id); subsystem_vendor_id;
for (i = 0; i < ARRAY_SIZE(products); i++) { for (i = 0; i < ARRAY_SIZE(products); i++) {
/* Stand aside for hpsa driver on request */ /* Stand aside for hpsa driver on request */
if (cciss_allow_hpsa && products[i].board_id == HPSA_BOUNDARY) if (cciss_allow_hpsa && products[i].board_id == HPSA_BOUNDARY)
return -ENODEV; return -ENODEV;
if (board_id == products[i].board_id) if (*board_id == products[i].board_id)
break; return i;
} }
prod_index = i; dev_warn(&pdev->dev, "unrecognized board ID: 0x%08x, ignoring.\n",
if (prod_index == ARRAY_SIZE(products)) { *board_id);
dev_warn(&c->pdev->dev,
"unrecognized board ID: 0x%08lx, ignoring.\n",
(unsigned long) board_id);
return -ENODEV; return -ENODEV;
} }
static int __devinit cciss_pci_init(ctlr_info_t *c)
{
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;
prod_index = cciss_lookup_board_id(c->pdev, &c->board_id);
if (prod_index < 0)
return -ENODEV;
c->product_name = products[prod_index].product_name;
c->access = *(products[prod_index].access);
/* check to see if controller has been disabled */ /* check to see if controller has been disabled */
/* BEFORE trying to enable it */ /* BEFORE trying to enable it */
(void)pci_read_config_word(c->pdev, PCI_COMMAND, &command); (void)pci_read_config_word(c->pdev, PCI_COMMAND, &command);
@ -4035,13 +4043,13 @@ static int __devinit cciss_pci_init(ctlr_info_t *c)
#ifdef CCISS_DEBUG #ifdef CCISS_DEBUG
printk(KERN_INFO "command = %x\n", command); printk(KERN_INFO "command = %x\n", command);
printk(KERN_INFO "irq = %x\n", c->pdev->irq); printk(KERN_INFO "irq = %x\n", c->pdev->irq);
printk(KERN_INFO "board_id = %x\n", board_id); printk(KERN_INFO "board_id = %x\n", c->board_id);
#endif /* CCISS_DEBUG */ #endif /* CCISS_DEBUG */
/* If the kernel supports MSI/MSI-X we will try to enable that functionality, /* If the kernel supports MSI/MSI-X we will try to enable that functionality,
* else we use the IO-APIC interrupt assigned to us by system ROM. * else we use the IO-APIC interrupt assigned to us by system ROM.
*/ */
cciss_interrupt_mode(c, board_id); cciss_interrupt_mode(c, c->board_id);
/* find the memory BAR */ /* find the memory BAR */
for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) { for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) {
@ -4107,8 +4115,6 @@ static int __devinit cciss_pci_init(ctlr_info_t *c)
c->transtable = remap_pci_mem(pci_resource_start(c->pdev, c->transtable = remap_pci_mem(pci_resource_start(c->pdev,
cfg_base_addr_index) + cfg_offset+trans_offset, cfg_base_addr_index) + cfg_offset+trans_offset,
sizeof(*c->transtable)); sizeof(*c->transtable));
c->board_id = board_id;
#ifdef CCISS_DEBUG #ifdef CCISS_DEBUG
print_cfg_table(c->cfgtable); print_cfg_table(c->cfgtable);
#endif /* CCISS_DEBUG */ #endif /* CCISS_DEBUG */
@ -4139,8 +4145,6 @@ static int __devinit cciss_pci_init(ctlr_info_t *c)
c->chainsize = 0; /* traditional */ c->chainsize = 0; /* traditional */
} }
c->product_name = products[prod_index].product_name;
c->access = *(products[prod_index].access);
c->nr_cmds = c->max_commands - 4; c->nr_cmds = c->max_commands - 4;
if ((readb(&c->cfgtable->Signature[0]) != 'C') || if ((readb(&c->cfgtable->Signature[0]) != 'C') ||
(readb(&c->cfgtable->Signature[1]) != 'I') || (readb(&c->cfgtable->Signature[1]) != 'I') ||
@ -4165,7 +4169,7 @@ static int __devinit cciss_pci_init(ctlr_info_t *c)
* We've disabled prefetch for some time now. Testing with XEN * We've disabled prefetch for some time now. Testing with XEN
* kernels revealed a bug in the refetch if dom0 resides on a P600. * kernels revealed a bug in the refetch if dom0 resides on a P600.
*/ */
if(board_id == 0x3225103C) { if (c->board_id == 0x3225103C) {
__u32 dma_prefetch; __u32 dma_prefetch;
__u32 dma_refetch; __u32 dma_refetch;
dma_prefetch = readl(c->vaddr + I2O_DMA1_CFG); dma_prefetch = readl(c->vaddr + I2O_DMA1_CFG);