diff options
author | Stephen M. Cameron <scameron@beardog.cce.hp.com> | 2010-07-19 14:44:55 -0400 |
---|---|---|
committer | Jens Axboe <jaxboe@fusionio.com> | 2010-08-07 12:52:10 -0400 |
commit | 6539fa9b2e2e7fc3b3fe819e54aa7be83f0370fa (patch) | |
tree | 45d9ca79fc33769094f66c868940a43b0e5058c3 /drivers/block | |
parent | 292e50dd393a8359798f1f20ac4d48ec835ffa04 (diff) |
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>
Diffstat (limited to 'drivers/block')
-rw-r--r-- | drivers/block/cciss.c | 66 |
1 files changed, 35 insertions, 31 deletions
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c index b79ce8e960f8..d4167c29213d 100644 --- a/drivers/block/cciss.c +++ b/drivers/block/cciss.c | |||
@@ -3980,35 +3980,43 @@ default_int_mode: | |||
3980 | return; | 3980 | return; |
3981 | } | 3981 | } |
3982 | 3982 | ||
3983 | static int __devinit cciss_pci_init(ctlr_info_t *c) | 3983 | static int __devinit cciss_lookup_board_id(struct pci_dev *pdev, u32 *board_id) |
3984 | { | 3984 | { |
3985 | ushort subsystem_vendor_id, subsystem_device_id, command; | 3985 | int i; |
3986 | __u32 board_id, scratchpad = 0; | 3986 | u32 subsystem_vendor_id, subsystem_device_id; |
3987 | __u64 cfg_offset; | ||
3988 | __u32 cfg_base_addr; | ||
3989 | __u64 cfg_base_addr_index; | ||
3990 | int i, prod_index, err; | ||
3991 | __u32 trans_offset; | ||
3992 | 3987 | ||
3993 | subsystem_vendor_id = c->pdev->subsystem_vendor; | 3988 | subsystem_vendor_id = pdev->subsystem_vendor; |
3994 | subsystem_device_id = c->pdev->subsystem_device; | 3989 | subsystem_device_id = pdev->subsystem_device; |
3995 | board_id = (((__u32) (subsystem_device_id << 16) & 0xffff0000) | | 3990 | *board_id = ((subsystem_device_id << 16) & 0xffff0000) | |
3996 | subsystem_vendor_id); | 3991 | subsystem_vendor_id; |
3997 | 3992 | ||
3998 | for (i = 0; i < ARRAY_SIZE(products); i++) { | 3993 | for (i = 0; i < ARRAY_SIZE(products); i++) { |
3999 | /* Stand aside for hpsa driver on request */ | 3994 | /* Stand aside for hpsa driver on request */ |
4000 | if (cciss_allow_hpsa && products[i].board_id == HPSA_BOUNDARY) | 3995 | if (cciss_allow_hpsa && products[i].board_id == HPSA_BOUNDARY) |
4001 | return -ENODEV; | 3996 | return -ENODEV; |
4002 | if (board_id == products[i].board_id) | 3997 | if (*board_id == products[i].board_id) |
4003 | break; | 3998 | return i; |
4004 | } | 3999 | } |
4005 | prod_index = i; | 4000 | dev_warn(&pdev->dev, "unrecognized board ID: 0x%08x, ignoring.\n", |
4006 | if (prod_index == ARRAY_SIZE(products)) { | 4001 | *board_id); |
4007 | dev_warn(&c->pdev->dev, | 4002 | return -ENODEV; |
4008 | "unrecognized board ID: 0x%08lx, ignoring.\n", | 4003 | } |
4009 | (unsigned long) board_id); | 4004 | |
4005 | static int __devinit cciss_pci_init(ctlr_info_t *c) | ||
4006 | { | ||
4007 | ushort command; | ||
4008 | __u32 scratchpad = 0; | ||
4009 | __u64 cfg_offset; | ||
4010 | __u32 cfg_base_addr; | ||
4011 | __u64 cfg_base_addr_index; | ||
4012 | __u32 trans_offset; | ||
4013 | int i, prod_index, err; | ||
4014 | |||
4015 | prod_index = cciss_lookup_board_id(c->pdev, &c->board_id); | ||
4016 | if (prod_index < 0) | ||
4010 | return -ENODEV; | 4017 | return -ENODEV; |
4011 | } | 4018 | c->product_name = products[prod_index].product_name; |
4019 | c->access = *(products[prod_index].access); | ||
4012 | 4020 | ||
4013 | /* check to see if controller has been disabled */ | 4021 | /* check to see if controller has been disabled */ |
4014 | /* BEFORE trying to enable it */ | 4022 | /* BEFORE trying to enable it */ |
@@ -4035,13 +4043,13 @@ static int __devinit cciss_pci_init(ctlr_info_t *c) | |||
4035 | #ifdef CCISS_DEBUG | 4043 | #ifdef CCISS_DEBUG |
4036 | printk(KERN_INFO "command = %x\n", command); | 4044 | printk(KERN_INFO "command = %x\n", command); |
4037 | printk(KERN_INFO "irq = %x\n", c->pdev->irq); | 4045 | printk(KERN_INFO "irq = %x\n", c->pdev->irq); |
4038 | printk(KERN_INFO "board_id = %x\n", board_id); | 4046 | printk(KERN_INFO "board_id = %x\n", c->board_id); |
4039 | #endif /* CCISS_DEBUG */ | 4047 | #endif /* CCISS_DEBUG */ |
4040 | 4048 | ||
4041 | /* If the kernel supports MSI/MSI-X we will try to enable that functionality, | 4049 | /* If the kernel supports MSI/MSI-X we will try to enable that functionality, |
4042 | * else we use the IO-APIC interrupt assigned to us by system ROM. | 4050 | * else we use the IO-APIC interrupt assigned to us by system ROM. |
4043 | */ | 4051 | */ |
4044 | cciss_interrupt_mode(c, board_id); | 4052 | cciss_interrupt_mode(c, c->board_id); |
4045 | 4053 | ||
4046 | /* find the memory BAR */ | 4054 | /* find the memory BAR */ |
4047 | for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) { | 4055 | for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) { |
@@ -4107,11 +4115,9 @@ static int __devinit cciss_pci_init(ctlr_info_t *c) | |||
4107 | c->transtable = remap_pci_mem(pci_resource_start(c->pdev, | 4115 | c->transtable = remap_pci_mem(pci_resource_start(c->pdev, |
4108 | cfg_base_addr_index) + cfg_offset+trans_offset, | 4116 | cfg_base_addr_index) + cfg_offset+trans_offset, |
4109 | sizeof(*c->transtable)); | 4117 | sizeof(*c->transtable)); |
4110 | c->board_id = board_id; | 4118 | #ifdef CCISS_DEBUG |
4111 | 4119 | print_cfg_table(c->cfgtable); | |
4112 | #ifdef CCISS_DEBUG | 4120 | #endif /* CCISS_DEBUG */ |
4113 | print_cfg_table(c->cfgtable); | ||
4114 | #endif /* CCISS_DEBUG */ | ||
4115 | 4121 | ||
4116 | /* Some controllers support Zero Memory Raid (ZMR). | 4122 | /* Some controllers support Zero Memory Raid (ZMR). |
4117 | * When configured in ZMR mode the number of supported | 4123 | * When configured in ZMR mode the number of supported |
@@ -4139,8 +4145,6 @@ static int __devinit cciss_pci_init(ctlr_info_t *c) | |||
4139 | c->chainsize = 0; /* traditional */ | 4145 | c->chainsize = 0; /* traditional */ |
4140 | } | 4146 | } |
4141 | 4147 | ||
4142 | c->product_name = products[prod_index].product_name; | ||
4143 | c->access = *(products[prod_index].access); | ||
4144 | c->nr_cmds = c->max_commands - 4; | 4148 | c->nr_cmds = c->max_commands - 4; |
4145 | if ((readb(&c->cfgtable->Signature[0]) != 'C') || | 4149 | if ((readb(&c->cfgtable->Signature[0]) != 'C') || |
4146 | (readb(&c->cfgtable->Signature[1]) != 'I') || | 4150 | (readb(&c->cfgtable->Signature[1]) != 'I') || |
@@ -4165,8 +4169,8 @@ static int __devinit cciss_pci_init(ctlr_info_t *c) | |||
4165 | * We've disabled prefetch for some time now. Testing with XEN | 4169 | * We've disabled prefetch for some time now. Testing with XEN |
4166 | * kernels revealed a bug in the refetch if dom0 resides on a P600. | 4170 | * kernels revealed a bug in the refetch if dom0 resides on a P600. |
4167 | */ | 4171 | */ |
4168 | if(board_id == 0x3225103C) { | 4172 | if (c->board_id == 0x3225103C) { |
4169 | __u32 dma_prefetch; | 4173 | __u32 dma_prefetch; |
4170 | __u32 dma_refetch; | 4174 | __u32 dma_refetch; |
4171 | dma_prefetch = readl(c->vaddr + I2O_DMA1_CFG); | 4175 | dma_prefetch = readl(c->vaddr + I2O_DMA1_CFG); |
4172 | dma_prefetch |= 0x8000; | 4176 | dma_prefetch |= 0x8000; |