aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/hpsa.c
diff options
context:
space:
mode:
authorStephen M. Cameron <scameron@beardog.cce.hp.com>2010-05-27 16:12:52 -0400
committerJames Bottomley <James.Bottomley@suse.de>2010-07-27 13:01:03 -0400
commite5c880d1d5923c341ac7ba537fb1e6b73c5977a2 (patch)
treec5468265e722e4ba11acbf8b94fd51d96c269e81 /drivers/scsi/hpsa.c
parent55c06c7171f63aaac1f9009729d1cb5107fa0626 (diff)
[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.c58
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:
3256 h->intr[PERF_MODE_INT] = h->pdev->irq; 3256 h->intr[PERF_MODE_INT] = h->pdev->irq;
3257} 3257}
3258 3258
3259static int __devinit hpsa_lookup_board_id(struct pci_dev *pdev, u32 *board_id)
3260{
3261 int i;
3262 u32 subsystem_vendor_id, subsystem_device_id;
3263
3264 subsystem_vendor_id = pdev->subsystem_vendor;
3265 subsystem_device_id = pdev->subsystem_device;
3266 *board_id = ((subsystem_device_id << 16) & 0xffff0000) |
3267 subsystem_vendor_id;
3268
3269 for (i = 0; i < ARRAY_SIZE(products); i++)
3270 if (*board_id == products[i].board_id)
3271 return i;
3272
3273 if (subsystem_vendor_id != PCI_VENDOR_ID_HP || !hpsa_allow_any) {
3274 dev_warn(&pdev->dev, "unrecognized board ID: "
3275 "0x%08x, ignoring.\n", *board_id);
3276 return -ENODEV;
3277 }
3278 return ARRAY_SIZE(products) - 1; /* generic unknown smart array */
3279}
3280
3259static int __devinit hpsa_pci_init(struct ctlr_info *h) 3281static int __devinit hpsa_pci_init(struct ctlr_info *h)
3260{ 3282{
3261 ushort subsystem_vendor_id, subsystem_device_id, command; 3283 ushort command;
3262 u32 board_id, scratchpad = 0; 3284 u32 scratchpad = 0;
3263 u64 cfg_offset; 3285 u64 cfg_offset;
3264 u32 cfg_base_addr; 3286 u32 cfg_base_addr;
3265 u64 cfg_base_addr_index; 3287 u64 cfg_base_addr_index;
3266 u32 trans_offset; 3288 u32 trans_offset;
3267 int i, prod_index, err; 3289 int i, prod_index, err;
3268 3290
3269 subsystem_vendor_id = h->pdev->subsystem_vendor; 3291 prod_index = hpsa_lookup_board_id(h->pdev, &h->board_id);
3270 subsystem_device_id = h->pdev->subsystem_device; 3292 if (prod_index < 0)
3271 board_id = (((u32) (subsystem_device_id << 16) & 0xffff0000) | 3293 return -ENODEV;
3272 subsystem_vendor_id); 3294 h->product_name = products[prod_index].product_name;
3273 3295 h->access = *(products[prod_index].access);
3274 for (i = 0; i < ARRAY_SIZE(products); i++)
3275 if (board_id == products[i].board_id)
3276 break;
3277
3278 prod_index = i;
3279 3296
3280 if (prod_index == ARRAY_SIZE(products)) {
3281 prod_index--;
3282 if (subsystem_vendor_id != PCI_VENDOR_ID_HP ||
3283 !hpsa_allow_any) {
3284 dev_warn(&h->pdev->dev, "unrecognized board ID:"
3285 " 0x%08lx, ignoring.\n",
3286 (unsigned long) board_id);
3287 return -ENODEV;
3288 }
3289 }
3290 /* check to see if controller has been disabled 3297 /* check to see if controller has been disabled
3291 * BEFORE trying to enable it 3298 * BEFORE trying to enable it
3292 */ 3299 */
@@ -3312,7 +3319,7 @@ static int __devinit hpsa_pci_init(struct ctlr_info *h)
3312 /* If the kernel supports MSI/MSI-X we will try to enable that, 3319 /* If the kernel supports MSI/MSI-X we will try to enable that,
3313 * else we use the IO-APIC interrupt assigned to us by system ROM. 3320 * else we use the IO-APIC interrupt assigned to us by system ROM.
3314 */ 3321 */
3315 hpsa_interrupt_mode(h, board_id); 3322 hpsa_interrupt_mode(h, h->board_id);
3316 3323
3317 /* find the memory BAR */ 3324 /* find the memory BAR */
3318 for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) { 3325 for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) {
@@ -3364,7 +3371,6 @@ static int __devinit hpsa_pci_init(struct ctlr_info *h)
3364 cfg_base_addr_index)+cfg_offset+trans_offset, 3371 cfg_base_addr_index)+cfg_offset+trans_offset,
3365 sizeof(*h->transtable)); 3372 sizeof(*h->transtable));
3366 3373
3367 h->board_id = board_id;
3368 h->max_commands = readl(&(h->cfgtable->MaxPerformantModeCommands)); 3374 h->max_commands = readl(&(h->cfgtable->MaxPerformantModeCommands));
3369 h->maxsgentries = readl(&(h->cfgtable->MaxScatterGatherElements)); 3375 h->maxsgentries = readl(&(h->cfgtable->MaxScatterGatherElements));
3370 3376
@@ -3383,8 +3389,6 @@ static int __devinit hpsa_pci_init(struct ctlr_info *h)
3383 h->chainsize = 0; 3389 h->chainsize = 0;
3384 } 3390 }
3385 3391
3386 h->product_name = products[prod_index].product_name;
3387 h->access = *(products[prod_index].access);
3388 /* Allow room for some ioctls */ 3392 /* Allow room for some ioctls */
3389 h->nr_cmds = h->max_commands - 4; 3393 h->nr_cmds = h->max_commands - 4;
3390 3394
@@ -3410,7 +3414,7 @@ static int __devinit hpsa_pci_init(struct ctlr_info *h)
3410 * An ASIC bug may result in a prefetch beyond 3414 * An ASIC bug may result in a prefetch beyond
3411 * physical memory. 3415 * physical memory.
3412 */ 3416 */
3413 if (board_id == 0x3225103C) { 3417 if (h->board_id == 0x3225103C) {
3414 u32 dma_prefetch; 3418 u32 dma_prefetch;
3415 dma_prefetch = readl(h->vaddr + I2O_DMA1_CFG); 3419 dma_prefetch = readl(h->vaddr + I2O_DMA1_CFG);
3416 dma_prefetch |= 0x8000; 3420 dma_prefetch |= 0x8000;