aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/advansys.c
diff options
context:
space:
mode:
authorMatthew Wilcox <matthew@wil.cx>2007-09-09 10:56:30 -0400
committerJames Bottomley <jejb@mulgrave.localdomain>2007-10-12 14:47:41 -0400
commitc2dce2fabc7f0b559e920890d13e7b8ecfc91e13 (patch)
tree16da338974636a920b20c05fc2bb74cc85eafb38 /drivers/scsi/advansys.c
parent629d688d5c3805194b311ad6dcd6f0e90a924ca6 (diff)
[SCSI] advansys: Shrink advansys_board_found a little more
Move the error reporting into AscInitGetConfig, AdvInitGetConfig and AscInitSetConfig. Signed-off-by: Matthew Wilcox <matthew@wil.cx> Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers/scsi/advansys.c')
-rw-r--r--drivers/scsi/advansys.c230
1 files changed, 112 insertions, 118 deletions
diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
index 5649bf4dd94e..fe289b1d7ddb 100644
--- a/drivers/scsi/advansys.c
+++ b/drivers/scsi/advansys.c
@@ -9321,13 +9321,14 @@ static uchar __devinit AscGetIsaDmaSpeed(PortAddr iop_base)
9321} 9321}
9322#endif /* CONFIG_ISA */ 9322#endif /* CONFIG_ISA */
9323 9323
9324static ushort __devinit AscInitGetConfig(ASC_DVC_VAR *asc_dvc) 9324static int __devinit AscInitGetConfig(asc_board_t *boardp)
9325{ 9325{
9326 ASC_DVC_VAR *asc_dvc = &boardp->dvc_var.asc_dvc_var;
9326 unsigned short warn_code = 0; 9327 unsigned short warn_code = 0;
9327 9328
9328 asc_dvc->init_state = ASC_INIT_STATE_BEG_GET_CFG; 9329 asc_dvc->init_state = ASC_INIT_STATE_BEG_GET_CFG;
9329 if (asc_dvc->err_code != 0) 9330 if (asc_dvc->err_code != 0)
9330 return (UW_ERR); 9331 return asc_dvc->err_code;
9331 9332
9332 if (AscFindSignature(asc_dvc->iop_base)) { 9333 if (AscFindSignature(asc_dvc->iop_base)) {
9333 warn_code |= AscInitAscDvcVar(asc_dvc); 9334 warn_code |= AscInitAscDvcVar(asc_dvc);
@@ -9338,27 +9339,63 @@ static ushort __devinit AscInitGetConfig(ASC_DVC_VAR *asc_dvc)
9338 } else { 9339 } else {
9339 asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE; 9340 asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
9340 } 9341 }
9341 return warn_code; 9342
9343 switch (warn_code) {
9344 case 0: /* No error */
9345 break;
9346 case ASC_WARN_IO_PORT_ROTATE:
9347 ASC_PRINT1("AscInitGetConfig: board %d: I/O port address "
9348 "modified\n", boardp->id);
9349 break;
9350 case ASC_WARN_AUTO_CONFIG:
9351 ASC_PRINT1("AscInitGetConfig: board %d: I/O port increment "
9352 "switch enabled\n", boardp->id);
9353 break;
9354 case ASC_WARN_EEPROM_CHKSUM:
9355 ASC_PRINT1("AscInitGetConfig: board %d: EEPROM checksum "
9356 "error\n", boardp->id);
9357 break;
9358 case ASC_WARN_IRQ_MODIFIED:
9359 ASC_PRINT1("AscInitGetConfig: board %d: IRQ modified\n",
9360 boardp->id);
9361 break;
9362 case ASC_WARN_CMD_QNG_CONFLICT:
9363 ASC_PRINT1("AscInitGetConfig: board %d: tag queuing enabled "
9364 "w/o disconnects\n", boardp->id);
9365 break;
9366 default:
9367 ASC_PRINT2("AscInitGetConfig: board %d: unknown warning: "
9368 "0x%x\n", boardp->id, warn_code);
9369 break;
9370 }
9371
9372 if (asc_dvc->err_code != 0) {
9373 ASC_PRINT3("AscInitGetConfig: board %d error: init_state 0x%x, "
9374 "err_code 0x%x\n", boardp->id, asc_dvc->init_state,
9375 asc_dvc->err_code);
9376 }
9377
9378 return asc_dvc->err_code;
9342} 9379}
9343 9380
9344static unsigned short __devinit 9381static int __devinit AscInitSetConfig(struct pci_dev *pdev, asc_board_t *boardp)
9345AscInitSetConfig(struct pci_dev *pdev, ASC_DVC_VAR *asc_dvc)
9346{ 9382{
9383 ASC_DVC_VAR *asc_dvc = &boardp->dvc_var.asc_dvc_var;
9347 PortAddr iop_base = asc_dvc->iop_base; 9384 PortAddr iop_base = asc_dvc->iop_base;
9348 unsigned short cfg_msw; 9385 unsigned short cfg_msw;
9349 unsigned short warn_code = 0; 9386 unsigned short warn_code = 0;
9350 9387
9351 asc_dvc->init_state |= ASC_INIT_STATE_BEG_SET_CFG; 9388 asc_dvc->init_state |= ASC_INIT_STATE_BEG_SET_CFG;
9352 if (asc_dvc->err_code != 0) 9389 if (asc_dvc->err_code != 0)
9353 return UW_ERR; 9390 return asc_dvc->err_code;
9354 if (!AscFindSignature(asc_dvc->iop_base)) { 9391 if (!AscFindSignature(asc_dvc->iop_base)) {
9355 asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE; 9392 asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
9356 return 0; 9393 return asc_dvc->err_code;
9357 } 9394 }
9358 9395
9359 cfg_msw = AscGetChipCfgMsw(iop_base); 9396 cfg_msw = AscGetChipCfgMsw(iop_base);
9360 if ((cfg_msw & ASC_CFG_MSW_CLR_MASK) != 0) { 9397 if ((cfg_msw & ASC_CFG_MSW_CLR_MASK) != 0) {
9361 cfg_msw &= (~(ASC_CFG_MSW_CLR_MASK)); 9398 cfg_msw &= ~ASC_CFG_MSW_CLR_MASK;
9362 warn_code |= ASC_WARN_CFG_MSW_RECOVER; 9399 warn_code |= ASC_WARN_CFG_MSW_RECOVER;
9363 AscSetChipCfgMsw(iop_base, cfg_msw); 9400 AscSetChipCfgMsw(iop_base, cfg_msw);
9364 } 9401 }
@@ -9409,7 +9446,44 @@ AscInitSetConfig(struct pci_dev *pdev, ASC_DVC_VAR *asc_dvc)
9409#endif /* CONFIG_ISA */ 9446#endif /* CONFIG_ISA */
9410 9447
9411 asc_dvc->init_state |= ASC_INIT_STATE_END_SET_CFG; 9448 asc_dvc->init_state |= ASC_INIT_STATE_END_SET_CFG;
9412 return warn_code; 9449
9450 switch (warn_code) {
9451 case 0: /* No error. */
9452 break;
9453 case ASC_WARN_IO_PORT_ROTATE:
9454 ASC_PRINT1("AscInitSetConfig: board %d: I/O port address "
9455 "modified\n", boardp->id);
9456 break;
9457 case ASC_WARN_AUTO_CONFIG:
9458 ASC_PRINT1("AscInitSetConfig: board %d: I/O port increment "
9459 "switch enabled\n", boardp->id);
9460 break;
9461 case ASC_WARN_EEPROM_CHKSUM:
9462 ASC_PRINT1("AscInitSetConfig: board %d: EEPROM checksum "
9463 "error\n", boardp->id);
9464 break;
9465 case ASC_WARN_IRQ_MODIFIED:
9466 ASC_PRINT1("AscInitSetConfig: board %d: IRQ modified\n",
9467 boardp->id);
9468 break;
9469 case ASC_WARN_CMD_QNG_CONFLICT:
9470 ASC_PRINT1("AscInitSetConfig: board %d: tag queuing w/o "
9471 "disconnects\n",
9472 boardp->id);
9473 break;
9474 default:
9475 ASC_PRINT2("AscInitSetConfig: board %d: unknown warning: "
9476 "0x%x\n", boardp->id, warn_code);
9477 break;
9478 }
9479
9480 if (asc_dvc->err_code != 0) {
9481 ASC_PRINT3("AscInitSetConfig: board %d error: init_state 0x%x, "
9482 "err_code 0x%x\n", boardp->id, asc_dvc->init_state,
9483 asc_dvc->err_code);
9484 }
9485
9486 return asc_dvc->err_code;
9413} 9487}
9414 9488
9415static ushort AscInitAsc1000Driver(ASC_DVC_VAR *asc_dvc) 9489static ushort AscInitAsc1000Driver(ASC_DVC_VAR *asc_dvc)
@@ -9596,7 +9670,7 @@ static ushort __devinit AscInitFromEEP(ASC_DVC_VAR *asc_dvc)
9596 cfg_msw = AscGetChipCfgMsw(iop_base); 9670 cfg_msw = AscGetChipCfgMsw(iop_base);
9597 cfg_lsw = AscGetChipCfgLsw(iop_base); 9671 cfg_lsw = AscGetChipCfgLsw(iop_base);
9598 if ((cfg_msw & ASC_CFG_MSW_CLR_MASK) != 0) { 9672 if ((cfg_msw & ASC_CFG_MSW_CLR_MASK) != 0) {
9599 cfg_msw &= (~(ASC_CFG_MSW_CLR_MASK)); 9673 cfg_msw &= ~ASC_CFG_MSW_CLR_MASK;
9600 warn_code |= ASC_WARN_CFG_MSW_RECOVER; 9674 warn_code |= ASC_WARN_CFG_MSW_RECOVER;
9601 AscSetChipCfgMsw(iop_base, cfg_msw); 9675 AscSetChipCfgMsw(iop_base, cfg_msw);
9602 } 9676 }
@@ -12009,6 +12083,7 @@ static ADVEEP_38C1600_CONFIG ADVEEP_38C1600_Config_Field_IsChar __devinitdata =
12009 0 /* 63 reserved */ 12083 0 /* 63 reserved */
12010}; 12084};
12011 12085
12086#ifdef CONFIG_PCI
12012/* 12087/*
12013 * Initialize the ADV_DVC_VAR structure. 12088 * Initialize the ADV_DVC_VAR structure.
12014 * 12089 *
@@ -12018,8 +12093,9 @@ static ADVEEP_38C1600_CONFIG ADVEEP_38C1600_Config_Field_IsChar __devinitdata =
12018 * then 0 is returned. 12093 * then 0 is returned.
12019 */ 12094 */
12020static int __devinit 12095static int __devinit
12021AdvInitGetConfig(struct pci_dev *pdev, ADV_DVC_VAR *asc_dvc) 12096AdvInitGetConfig(struct pci_dev *pdev, asc_board_t *boardp)
12022{ 12097{
12098 ADV_DVC_VAR *asc_dvc = &boardp->dvc_var.adv_dvc_var;
12023 unsigned short warn_code = 0; 12099 unsigned short warn_code = 0;
12024 AdvPortAddr iop_base = asc_dvc->iop_base; 12100 AdvPortAddr iop_base = asc_dvc->iop_base;
12025 u16 cmd; 12101 u16 cmd;
@@ -12087,8 +12163,19 @@ AdvInitGetConfig(struct pci_dev *pdev, ADV_DVC_VAR *asc_dvc)
12087 warn_code |= status; 12163 warn_code |= status;
12088 } 12164 }
12089 12165
12090 return warn_code; 12166 if (warn_code != 0) {
12167 ASC_PRINT2("AdvInitGetConfig: board %d: warning: 0x%x\n",
12168 boardp->id, warn_code);
12169 }
12170
12171 if (asc_dvc->err_code) {
12172 ASC_PRINT2("AdvInitGetConfig: board %d error: err_code 0x%x\n",
12173 boardp->id, asc_dvc->err_code);
12174 }
12175
12176 return asc_dvc->err_code;
12091} 12177}
12178#endif
12092 12179
12093static void AdvBuildCarrierFreelist(struct adv_dvc_var *asc_dvc) 12180static void AdvBuildCarrierFreelist(struct adv_dvc_var *asc_dvc)
12094{ 12181{
@@ -15316,22 +15403,7 @@ advansys_board_found(int iop, struct device *dev, int bus_type)
15316 share_irq = 0; 15403 share_irq = 0;
15317 break; 15404 break;
15318 } 15405 }
15319 } else {
15320 /*
15321 * For Wide boards set PCI information before calling
15322 * AdvInitGetConfig().
15323 */
15324#ifdef CONFIG_PCI
15325 shost->irq = adv_dvc_varp->irq_no = pdev->irq;
15326 shost->unchecked_isa_dma = FALSE;
15327 share_irq = IRQF_SHARED;
15328#endif /* CONFIG_PCI */
15329 }
15330 15406
15331 /*
15332 * Read the board configuration.
15333 */
15334 if (ASC_NARROW_BOARD(boardp)) {
15335 /* 15407 /*
15336 * NOTE: AscInitGetConfig() may change the board's 15408 * NOTE: AscInitGetConfig() may change the board's
15337 * bus_type value. The bus_type value should no 15409 * bus_type value. The bus_type value should no
@@ -15339,60 +15411,20 @@ advansys_board_found(int iop, struct device *dev, int bus_type)
15339 * referenced only use the bit-wise AND operator "&". 15411 * referenced only use the bit-wise AND operator "&".
15340 */ 15412 */
15341 ASC_DBG(2, "advansys_board_found: AscInitGetConfig()\n"); 15413 ASC_DBG(2, "advansys_board_found: AscInitGetConfig()\n");
15342 switch (ret = AscInitGetConfig(asc_dvc_varp)) { 15414 err_code = AscInitGetConfig(boardp);
15343 case 0: /* No error */
15344 break;
15345 case ASC_WARN_IO_PORT_ROTATE:
15346 ASC_PRINT1
15347 ("AscInitGetConfig: board %d: I/O port address modified\n",
15348 boardp->id);
15349 break;
15350 case ASC_WARN_AUTO_CONFIG:
15351 ASC_PRINT1
15352 ("AscInitGetConfig: board %d: I/O port increment switch enabled\n",
15353 boardp->id);
15354 break;
15355 case ASC_WARN_EEPROM_CHKSUM:
15356 ASC_PRINT1
15357 ("AscInitGetConfig: board %d: EEPROM checksum error\n",
15358 boardp->id);
15359 break;
15360 case ASC_WARN_IRQ_MODIFIED:
15361 ASC_PRINT1
15362 ("AscInitGetConfig: board %d: IRQ modified\n",
15363 boardp->id);
15364 break;
15365 case ASC_WARN_CMD_QNG_CONFLICT:
15366 ASC_PRINT1
15367 ("AscInitGetConfig: board %d: tag queuing enabled w/o disconnects\n",
15368 boardp->id);
15369 break;
15370 default:
15371 ASC_PRINT2
15372 ("AscInitGetConfig: board %d: unknown warning: 0x%x\n",
15373 boardp->id, ret);
15374 break;
15375 }
15376 if ((err_code = asc_dvc_varp->err_code) != 0) {
15377 ASC_PRINT3
15378 ("AscInitGetConfig: board %d error: init_state 0x%x, err_code 0x%x\n",
15379 boardp->id,
15380 asc_dvc_varp->init_state, asc_dvc_varp->err_code);
15381 }
15382 } else { 15415 } else {
15416#ifdef CONFIG_PCI
15417 /*
15418 * For Wide boards set PCI information before calling
15419 * AdvInitGetConfig().
15420 */
15421 shost->irq = adv_dvc_varp->irq_no = pdev->irq;
15422 shost->unchecked_isa_dma = FALSE;
15423 share_irq = IRQF_SHARED;
15383 ASC_DBG(2, "advansys_board_found: AdvInitGetConfig()\n"); 15424 ASC_DBG(2, "advansys_board_found: AdvInitGetConfig()\n");
15384 15425
15385 ret = AdvInitGetConfig(pdev, adv_dvc_varp); 15426 err_code = AdvInitGetConfig(pdev, boardp);
15386 if (ret != 0) { 15427#endif /* CONFIG_PCI */
15387 ASC_PRINT2
15388 ("AdvInitGetConfig: board %d: warning: 0x%x\n",
15389 boardp->id, ret);
15390 }
15391 if ((err_code = adv_dvc_varp->err_code) != 0) {
15392 ASC_PRINT2
15393 ("AdvInitGetConfig: board %d error: err_code 0x%x\n",
15394 boardp->id, adv_dvc_varp->err_code);
15395 }
15396 } 15428 }
15397 15429
15398 if (err_code != 0) 15430 if (err_code != 0)
@@ -15439,47 +15471,9 @@ advansys_board_found(int iop, struct device *dev, int bus_type)
15439 * Modify board configuration. 15471 * Modify board configuration.
15440 */ 15472 */
15441 ASC_DBG(2, "advansys_board_found: AscInitSetConfig()\n"); 15473 ASC_DBG(2, "advansys_board_found: AscInitSetConfig()\n");
15442 switch (ret = AscInitSetConfig(pdev, asc_dvc_varp)) { 15474 err_code = AscInitSetConfig(pdev, boardp);
15443 case 0: /* No error. */ 15475 if (err_code)
15444 break;
15445 case ASC_WARN_IO_PORT_ROTATE:
15446 ASC_PRINT1
15447 ("AscInitSetConfig: board %d: I/O port address modified\n",
15448 boardp->id);
15449 break;
15450 case ASC_WARN_AUTO_CONFIG:
15451 ASC_PRINT1
15452 ("AscInitSetConfig: board %d: I/O port increment switch enabled\n",
15453 boardp->id);
15454 break;
15455 case ASC_WARN_EEPROM_CHKSUM:
15456 ASC_PRINT1
15457 ("AscInitSetConfig: board %d: EEPROM checksum error\n",
15458 boardp->id);
15459 break;
15460 case ASC_WARN_IRQ_MODIFIED:
15461 ASC_PRINT1
15462 ("AscInitSetConfig: board %d: IRQ modified\n",
15463 boardp->id);
15464 break;
15465 case ASC_WARN_CMD_QNG_CONFLICT:
15466 ASC_PRINT1
15467 ("AscInitSetConfig: board %d: tag queuing w/o disconnects\n",
15468 boardp->id);
15469 break;
15470 default:
15471 ASC_PRINT2
15472 ("AscInitSetConfig: board %d: unknown warning: 0x%x\n",
15473 boardp->id, ret);
15474 break;
15475 }
15476 if (asc_dvc_varp->err_code != 0) {
15477 ASC_PRINT3
15478 ("AscInitSetConfig: board %d error: init_state 0x%x, err_code 0x%x\n",
15479 boardp->id,
15480 asc_dvc_varp->init_state, asc_dvc_varp->err_code);
15481 goto err_free_proc; 15476 goto err_free_proc;
15482 }
15483 15477
15484 /* 15478 /*
15485 * Finish initializing the 'Scsi_Host' structure. 15479 * Finish initializing the 'Scsi_Host' structure.