All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matthew Wilcox <matthew@wil.cx>
To: linux-scsi@vger.kernel.org
Cc: Matthew Wilcox <matthew@wil.cx>
Subject: [PATCH 05/22] advansys: Shrink advansys_board_found a little more
Date: Sun,  9 Sep 2007 08:56:30 -0600	[thread overview]
Message-ID: <11893498071452-git-send-email-matthew@wil.cx> (raw)
In-Reply-To: <20070909145358.GG6809@parisc-linux.org>

Move the error reporting into AscInitGetConfig, AdvInitGetConfig and
AscInitSetConfig.

Signed-off-by: Matthew Wilcox <matthew@wil.cx>
---
 drivers/scsi/advansys.c |  230 +++++++++++++++++++++++------------------------
 1 files changed, 112 insertions(+), 118 deletions(-)

diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
index 5649bf4..fe289b1 100644
--- a/drivers/scsi/advansys.c
+++ b/drivers/scsi/advansys.c
@@ -9321,13 +9321,14 @@ static uchar __devinit AscGetIsaDmaSpeed(PortAddr iop_base)
 }
 #endif /* CONFIG_ISA */
 
-static ushort __devinit AscInitGetConfig(ASC_DVC_VAR *asc_dvc)
+static int __devinit AscInitGetConfig(asc_board_t *boardp)
 {
+	ASC_DVC_VAR *asc_dvc = &boardp->dvc_var.asc_dvc_var;
 	unsigned short warn_code = 0;
 
 	asc_dvc->init_state = ASC_INIT_STATE_BEG_GET_CFG;
 	if (asc_dvc->err_code != 0)
-		return (UW_ERR);
+		return asc_dvc->err_code;
 
 	if (AscFindSignature(asc_dvc->iop_base)) {
 		warn_code |= AscInitAscDvcVar(asc_dvc);
@@ -9338,27 +9339,63 @@ static ushort __devinit AscInitGetConfig(ASC_DVC_VAR *asc_dvc)
 	} else {
 		asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
 	}
-	return warn_code;
+
+	switch (warn_code) {
+	case 0:	/* No error */
+		break;
+	case ASC_WARN_IO_PORT_ROTATE:
+		ASC_PRINT1("AscInitGetConfig: board %d: I/O port address "
+			   "modified\n", boardp->id);
+		break;
+	case ASC_WARN_AUTO_CONFIG:
+		ASC_PRINT1("AscInitGetConfig: board %d: I/O port increment "
+			   "switch enabled\n", boardp->id);
+		break;
+	case ASC_WARN_EEPROM_CHKSUM:
+		ASC_PRINT1("AscInitGetConfig: board %d: EEPROM checksum "
+			   "error\n", boardp->id);
+		break;
+	case ASC_WARN_IRQ_MODIFIED:
+		ASC_PRINT1("AscInitGetConfig: board %d: IRQ modified\n",
+			   boardp->id);
+		break;
+	case ASC_WARN_CMD_QNG_CONFLICT:
+		ASC_PRINT1("AscInitGetConfig: board %d: tag queuing enabled "
+			   "w/o disconnects\n", boardp->id);
+		break;
+	default:
+		ASC_PRINT2("AscInitGetConfig: board %d: unknown warning: "
+			   "0x%x\n", boardp->id, warn_code);
+		break;
+	}
+
+	if (asc_dvc->err_code != 0) {
+		ASC_PRINT3("AscInitGetConfig: board %d error: init_state 0x%x, "
+			   "err_code 0x%x\n", boardp->id, asc_dvc->init_state,
+			   asc_dvc->err_code);
+	}
+
+	return asc_dvc->err_code;
 }
 
-static unsigned short __devinit
-AscInitSetConfig(struct pci_dev *pdev, ASC_DVC_VAR *asc_dvc)
+static int __devinit AscInitSetConfig(struct pci_dev *pdev, asc_board_t *boardp)
 {
+	ASC_DVC_VAR *asc_dvc = &boardp->dvc_var.asc_dvc_var;
 	PortAddr iop_base = asc_dvc->iop_base;
 	unsigned short cfg_msw;
 	unsigned short warn_code = 0;
 
 	asc_dvc->init_state |= ASC_INIT_STATE_BEG_SET_CFG;
 	if (asc_dvc->err_code != 0)
-		return UW_ERR;
+		return asc_dvc->err_code;
 	if (!AscFindSignature(asc_dvc->iop_base)) {
 		asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
-		return 0;
+		return asc_dvc->err_code;
 	}
 
 	cfg_msw = AscGetChipCfgMsw(iop_base);
 	if ((cfg_msw & ASC_CFG_MSW_CLR_MASK) != 0) {
-		cfg_msw &= (~(ASC_CFG_MSW_CLR_MASK));
+		cfg_msw &= ~ASC_CFG_MSW_CLR_MASK;
 		warn_code |= ASC_WARN_CFG_MSW_RECOVER;
 		AscSetChipCfgMsw(iop_base, cfg_msw);
 	}
@@ -9409,7 +9446,44 @@ AscInitSetConfig(struct pci_dev *pdev, ASC_DVC_VAR *asc_dvc)
 #endif /* CONFIG_ISA */
 
 	asc_dvc->init_state |= ASC_INIT_STATE_END_SET_CFG;
-	return warn_code;
+
+	switch (warn_code) {
+	case 0:	/* No error. */
+		break;
+	case ASC_WARN_IO_PORT_ROTATE:
+		ASC_PRINT1("AscInitSetConfig: board %d: I/O port address "
+			   "modified\n", boardp->id);
+		break;
+	case ASC_WARN_AUTO_CONFIG:
+		ASC_PRINT1("AscInitSetConfig: board %d: I/O port increment "
+			   "switch enabled\n", boardp->id);
+		break;
+	case ASC_WARN_EEPROM_CHKSUM:
+		ASC_PRINT1("AscInitSetConfig: board %d: EEPROM checksum "
+			   "error\n", boardp->id);
+		break;
+	case ASC_WARN_IRQ_MODIFIED:
+		ASC_PRINT1("AscInitSetConfig: board %d: IRQ modified\n",
+			   boardp->id);
+		break;
+	case ASC_WARN_CMD_QNG_CONFLICT:
+		ASC_PRINT1("AscInitSetConfig: board %d: tag queuing w/o "
+			   "disconnects\n",
+		     boardp->id);
+		break;
+	default:
+		ASC_PRINT2("AscInitSetConfig: board %d: unknown warning: "
+			   "0x%x\n", boardp->id, warn_code);
+		break;
+	}
+
+	if (asc_dvc->err_code != 0) {
+		ASC_PRINT3("AscInitSetConfig: board %d error: init_state 0x%x, "
+			   "err_code 0x%x\n", boardp->id, asc_dvc->init_state,
+			   asc_dvc->err_code);
+	}
+
+	return asc_dvc->err_code;
 }
 
 static ushort AscInitAsc1000Driver(ASC_DVC_VAR *asc_dvc)
@@ -9596,7 +9670,7 @@ static ushort __devinit AscInitFromEEP(ASC_DVC_VAR *asc_dvc)
 	cfg_msw = AscGetChipCfgMsw(iop_base);
 	cfg_lsw = AscGetChipCfgLsw(iop_base);
 	if ((cfg_msw & ASC_CFG_MSW_CLR_MASK) != 0) {
-		cfg_msw &= (~(ASC_CFG_MSW_CLR_MASK));
+		cfg_msw &= ~ASC_CFG_MSW_CLR_MASK;
 		warn_code |= ASC_WARN_CFG_MSW_RECOVER;
 		AscSetChipCfgMsw(iop_base, cfg_msw);
 	}
@@ -12009,6 +12083,7 @@ static ADVEEP_38C1600_CONFIG ADVEEP_38C1600_Config_Field_IsChar __devinitdata =
 	0			/* 63 reserved */
 };
 
+#ifdef CONFIG_PCI
 /*
  * Initialize the ADV_DVC_VAR structure.
  *
@@ -12018,8 +12093,9 @@ static ADVEEP_38C1600_CONFIG ADVEEP_38C1600_Config_Field_IsChar __devinitdata =
  * then 0 is returned.
  */
 static int __devinit
-AdvInitGetConfig(struct pci_dev *pdev, ADV_DVC_VAR *asc_dvc)
+AdvInitGetConfig(struct pci_dev *pdev, asc_board_t *boardp)
 {
+	ADV_DVC_VAR *asc_dvc = &boardp->dvc_var.adv_dvc_var;
 	unsigned short warn_code = 0;
 	AdvPortAddr iop_base = asc_dvc->iop_base;
 	u16 cmd;
@@ -12087,8 +12163,19 @@ AdvInitGetConfig(struct pci_dev *pdev, ADV_DVC_VAR *asc_dvc)
 		warn_code |= status;
 	}
 
-	return warn_code;
+	if (warn_code != 0) {
+		ASC_PRINT2("AdvInitGetConfig: board %d: warning: 0x%x\n",
+			   boardp->id, warn_code);
+	}
+
+	if (asc_dvc->err_code) {
+		ASC_PRINT2("AdvInitGetConfig: board %d error: err_code 0x%x\n",
+		     boardp->id, asc_dvc->err_code);
+	}
+
+	return asc_dvc->err_code;
 }
+#endif
 
 static void AdvBuildCarrierFreelist(struct adv_dvc_var *asc_dvc)
 {
@@ -15316,22 +15403,7 @@ advansys_board_found(int iop, struct device *dev, int bus_type)
 			share_irq = 0;
 			break;
 		}
-	} else {
-		/*
-		 * For Wide boards set PCI information before calling
-		 * AdvInitGetConfig().
-		 */
-#ifdef CONFIG_PCI
-		shost->irq = adv_dvc_varp->irq_no = pdev->irq;
-		shost->unchecked_isa_dma = FALSE;
-		share_irq = IRQF_SHARED;
-#endif /* CONFIG_PCI */
-	}
 
-	/*
-	 * Read the board configuration.
-	 */
-	if (ASC_NARROW_BOARD(boardp)) {
 		/*
 		 * NOTE: AscInitGetConfig() may change the board's
 		 * bus_type value. The bus_type value should no
@@ -15339,60 +15411,20 @@ advansys_board_found(int iop, struct device *dev, int bus_type)
 		 * referenced only use the bit-wise AND operator "&".
 		 */
 		ASC_DBG(2, "advansys_board_found: AscInitGetConfig()\n");
-		switch (ret = AscInitGetConfig(asc_dvc_varp)) {
-		case 0:	/* No error */
-			break;
-		case ASC_WARN_IO_PORT_ROTATE:
-			ASC_PRINT1
-			    ("AscInitGetConfig: board %d: I/O port address modified\n",
-			     boardp->id);
-			break;
-		case ASC_WARN_AUTO_CONFIG:
-			ASC_PRINT1
-			    ("AscInitGetConfig: board %d: I/O port increment switch enabled\n",
-			     boardp->id);
-			break;
-		case ASC_WARN_EEPROM_CHKSUM:
-			ASC_PRINT1
-			    ("AscInitGetConfig: board %d: EEPROM checksum error\n",
-			     boardp->id);
-			break;
-		case ASC_WARN_IRQ_MODIFIED:
-			ASC_PRINT1
-			    ("AscInitGetConfig: board %d: IRQ modified\n",
-			     boardp->id);
-			break;
-		case ASC_WARN_CMD_QNG_CONFLICT:
-			ASC_PRINT1
-			    ("AscInitGetConfig: board %d: tag queuing enabled w/o disconnects\n",
-			     boardp->id);
-			break;
-		default:
-			ASC_PRINT2
-			    ("AscInitGetConfig: board %d: unknown warning: 0x%x\n",
-			     boardp->id, ret);
-			break;
-		}
-		if ((err_code = asc_dvc_varp->err_code) != 0) {
-			ASC_PRINT3
-			    ("AscInitGetConfig: board %d error: init_state 0x%x, err_code 0x%x\n",
-			     boardp->id,
-			     asc_dvc_varp->init_state, asc_dvc_varp->err_code);
-		}
+		err_code = AscInitGetConfig(boardp);
 	} else {
+#ifdef CONFIG_PCI
+		/*
+		 * For Wide boards set PCI information before calling
+		 * AdvInitGetConfig().
+		 */
+		shost->irq = adv_dvc_varp->irq_no = pdev->irq;
+		shost->unchecked_isa_dma = FALSE;
+		share_irq = IRQF_SHARED;
 		ASC_DBG(2, "advansys_board_found: AdvInitGetConfig()\n");
 
-		ret = AdvInitGetConfig(pdev, adv_dvc_varp);
-		if (ret != 0) {
-			ASC_PRINT2
-			    ("AdvInitGetConfig: board %d: warning: 0x%x\n",
-			     boardp->id, ret);
-		}
-		if ((err_code = adv_dvc_varp->err_code) != 0) {
-			ASC_PRINT2
-			    ("AdvInitGetConfig: board %d error: err_code 0x%x\n",
-			     boardp->id, adv_dvc_varp->err_code);
-		}
+		err_code = AdvInitGetConfig(pdev, boardp);
+#endif /* CONFIG_PCI */
 	}
 
 	if (err_code != 0)
@@ -15439,47 +15471,9 @@ advansys_board_found(int iop, struct device *dev, int bus_type)
 		 * Modify board configuration.
 		 */
 		ASC_DBG(2, "advansys_board_found: AscInitSetConfig()\n");
-		switch (ret = AscInitSetConfig(pdev, asc_dvc_varp)) {
-		case 0:	/* No error. */
-			break;
-		case ASC_WARN_IO_PORT_ROTATE:
-			ASC_PRINT1
-			    ("AscInitSetConfig: board %d: I/O port address modified\n",
-			     boardp->id);
-			break;
-		case ASC_WARN_AUTO_CONFIG:
-			ASC_PRINT1
-			    ("AscInitSetConfig: board %d: I/O port increment switch enabled\n",
-			     boardp->id);
-			break;
-		case ASC_WARN_EEPROM_CHKSUM:
-			ASC_PRINT1
-			    ("AscInitSetConfig: board %d: EEPROM checksum error\n",
-			     boardp->id);
-			break;
-		case ASC_WARN_IRQ_MODIFIED:
-			ASC_PRINT1
-			    ("AscInitSetConfig: board %d: IRQ modified\n",
-			     boardp->id);
-			break;
-		case ASC_WARN_CMD_QNG_CONFLICT:
-			ASC_PRINT1
-			    ("AscInitSetConfig: board %d: tag queuing w/o disconnects\n",
-			     boardp->id);
-			break;
-		default:
-			ASC_PRINT2
-			    ("AscInitSetConfig: board %d: unknown warning: 0x%x\n",
-			     boardp->id, ret);
-			break;
-		}
-		if (asc_dvc_varp->err_code != 0) {
-			ASC_PRINT3
-			    ("AscInitSetConfig: board %d error: init_state 0x%x, err_code 0x%x\n",
-			     boardp->id,
-			     asc_dvc_varp->init_state, asc_dvc_varp->err_code);
+		err_code = AscInitSetConfig(pdev, boardp);
+		if (err_code)
 			goto err_free_proc;
-		}
 
 		/*
 		 * Finish initializing the 'Scsi_Host' structure.
-- 
1.5.2.4


  parent reply	other threads:[~2007-09-09 14:56 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-09 14:53 [0/22] Advansys updates 2007-09-09 Matthew Wilcox
2007-09-09 14:56 ` [PATCH 01/22] advansys: Fix VLB driver name Matthew Wilcox
2007-09-09 14:56 ` [PATCH 02/22] advansys: Create AdvBuildCarrierFreelist Matthew Wilcox
2007-09-09 14:56 ` [PATCH 03/22] advansys: Create AdvLoadMicrocode Matthew Wilcox
2007-09-09 14:56 ` [PATCH 04/22] advansys: Reformat microcode Matthew Wilcox
2007-09-09 14:56 ` Matthew Wilcox [this message]
2007-09-09 14:56 ` [PATCH 06/22] advansys: Remove `waiting' queue Matthew Wilcox
2007-09-09 14:56 ` [PATCH 07/22] advansys: Remove a check for an impossible condition Matthew Wilcox
2007-09-09 14:56 ` [PATCH 08/22] advansys: Remove `done' queue Matthew Wilcox
2007-09-09 14:56 ` [PATCH 09/22] advansys: Remove `active' queue and all remaining internal queueing code Matthew Wilcox
2007-09-09 14:56 ` [PATCH 10/22] advansys: Enable interrupts earlier in queuecommand Matthew Wilcox
2007-09-09 14:56 ` [PATCH 11/22] advansys: Support 16-byte commands properly Matthew Wilcox
2007-09-09 14:56 ` [PATCH 12/22] advansys: Remove a check for an impossible condition Matthew Wilcox
2007-09-09 14:56 ` [PATCH 13/22] advansys: Remove some custom wrappers Matthew Wilcox
2007-09-09 14:56 ` [PATCH 14/22] advansys: Comment/indentation/macro cleanup Matthew Wilcox
2007-09-09 14:56 ` [PATCH 15/22] advansys: Use DRV_NAME Matthew Wilcox
2007-09-09 14:56 ` [PATCH 16/22] advansys: Eliminate prototypes Matthew Wilcox
2007-09-09 15:29   ` Jeff Garzik
2007-09-09 17:48     ` Matthew Wilcox
2007-09-15 14:39   ` James Bottomley
2007-09-16 15:31     ` Matthew Wilcox
2007-09-16 22:41       ` FUJITA Tomonori
2007-09-16 23:03         ` Matthew Wilcox
2007-09-16 23:17           ` FUJITA Tomonori
2007-09-17 12:21             ` Matthew Wilcox
2007-09-16 15:37     ` [PATCH 01/17] " Matthew Wilcox
2007-09-16 15:37     ` [PATCH 02/17] advansys: Remove array of scsi targets Matthew Wilcox
2007-09-16 15:37     ` [PATCH 03/17] advansys: Restructure asc_execute_scsi_cmnd() Matthew Wilcox
2007-09-16 15:37     ` [PATCH 04/17] advansys: Fix simultaneous calls to ->queuecommand Matthew Wilcox
2007-09-16 15:37     ` [PATCH 05/17] advansys: Improve reset handler Matthew Wilcox
2007-09-16 15:37     ` [PATCH 06/17] advansys: Remove ASC_SELECT_QUEUE_DEPTHS Matthew Wilcox
2007-09-16 15:37     ` [PATCH 07/17] advansys: Remove ASC_WIDE_BOARD predicate Matthew Wilcox
2007-09-16 15:37     ` [PATCH 08/17] advansys: Sort out irq number mess Matthew Wilcox
2007-09-16 15:37     ` [PATCH 09/17] advansys: Merge ASC_IERR definitions Matthew Wilcox
2007-09-16 15:37     ` [PATCH 10/17] advansys: Remove asc_board_t typedef and ASC_BOARDP macro Matthew Wilcox
2007-09-16 16:14       ` Matthew Wilcox
2007-09-16 15:37     ` [PATCH 11/17] advansys: Remove library version & serial numbers Matthew Wilcox
2007-09-16 15:37     ` [PATCH 12/17] advansys: Sort out debug macros Matthew Wilcox
2007-09-16 15:37     ` [PATCH 13/17] advansys: Remove private lock Matthew Wilcox
2007-09-16 15:37     ` [PATCH 14/17] advansys: Get rid of board index number Matthew Wilcox
2007-09-16 15:37     ` [PATCH 15/17] advansys: Make sdtr_period_tbl a pointer Matthew Wilcox
2007-09-16 15:37     ` [PATCH 16/17] advansys: Move a couple of fields from struct board to struct adv_dvc Matthew Wilcox
2007-09-16 15:37     ` [PATCH 17/17] advansys: Remove DvcGetPhyAddr Matthew Wilcox
2007-09-16 20:39     ` [PATCH 10/17] advansys: Remove asc_board_t typedef and ASC_BOARDP macro Matthew Wilcox
2007-09-09 14:56 ` [PATCH 17/22] advansys: Remove array of scsi targets Matthew Wilcox
2007-09-09 14:56 ` [PATCH 18/22] advansys: Restructure asc_execute_scsi_cmnd() Matthew Wilcox
2007-09-09 14:56 ` [PATCH 19/22] advansys: Fix simultaneous calls to ->queuecommand Matthew Wilcox
2007-09-09 14:56 ` [PATCH 20/22] advansys: Improve reset handler Matthew Wilcox
2007-09-09 14:56 ` [PATCH 21/22] advansys: Remove ASC_SELECT_QUEUE_DEPTHS Matthew Wilcox
2007-09-09 14:56 ` [PATCH 22/22] advansys: Remove ASC_WIDE_BOARD predicate Matthew Wilcox
2007-09-10 20:00 ` [0/22] Advansys updates 2007-09-09 FUJITA Tomonori
2007-09-11 18:18   ` Matthew Wilcox

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=11893498071452-git-send-email-matthew@wil.cx \
    --to=matthew@wil.cx \
    --cc=linux-scsi@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.