public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Stephen M. Cameron" <scameron@beardog.cce.hp.com>
To: axboe@kernel.dk
Cc: akpm@linux-foundation.org, mikem@beardog.cce.hp.com,
	linux-kernel@vger.kernel.org, brace@beardog.cce.hp.com
Subject: [PATCH 03/26] cciss: factor out cciss_lookup_board_id
Date: Mon, 19 Jul 2010 13:44:55 -0500	[thread overview]
Message-ID: <20100719184455.7908.24283.stgit@beardog.cce.hp.com> (raw)
In-Reply-To: <20100719184141.7908.26971.stgit@beardog.cce.hp.com>

From: Stephen M. Cameron <scameron@beardog.cce.hp.com>

cciss: factor out cciss_lookup_board_id

Signed-off-by: Stephen M. Cameron <scameron@beardog.cce.hp.com>
---
 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 b79ce8e..d4167c2 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -3980,35 +3980,43 @@ default_int_mode:
 	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;
-	__u32 board_id, scratchpad = 0;
-	__u64 cfg_offset;
-	__u32 cfg_base_addr;
-	__u64 cfg_base_addr_index;
-	int i, prod_index, err;
-	__u32 trans_offset;
+	int i;
+	u32 subsystem_vendor_id, subsystem_device_id;
 
-	subsystem_vendor_id = c->pdev->subsystem_vendor;
-	subsystem_device_id = c->pdev->subsystem_device;
-	board_id = (((__u32) (subsystem_device_id << 16) & 0xffff0000) |
-		    subsystem_vendor_id);
+	subsystem_vendor_id = pdev->subsystem_vendor;
+	subsystem_device_id = pdev->subsystem_device;
+	*board_id = ((subsystem_device_id << 16) & 0xffff0000) |
+			subsystem_vendor_id;
 
 	for (i = 0; i < ARRAY_SIZE(products); i++) {
 		/* Stand aside for hpsa driver on request */
 		if (cciss_allow_hpsa && products[i].board_id == HPSA_BOUNDARY)
 			return -ENODEV;
-		if (board_id == products[i].board_id)
-			break;
+		if (*board_id == products[i].board_id)
+			return i;
 	}
-	prod_index = i;
-	if (prod_index == ARRAY_SIZE(products)) {
-		dev_warn(&c->pdev->dev,
-			"unrecognized board ID: 0x%08lx, ignoring.\n",
-			(unsigned long) board_id);
+	dev_warn(&pdev->dev, "unrecognized board ID: 0x%08x, ignoring.\n",
+		*board_id);
+	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 */
 	/* BEFORE trying to enable it */
@@ -4035,13 +4043,13 @@ static int __devinit cciss_pci_init(ctlr_info_t *c)
 #ifdef CCISS_DEBUG
 	printk(KERN_INFO "command = %x\n", command);
 	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 */
 
 /* 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.
  */
-	cciss_interrupt_mode(c, board_id);
+	cciss_interrupt_mode(c, c->board_id);
 
 	/* find the memory BAR */
 	for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) {
@@ -4107,11 +4115,9 @@ static int __devinit cciss_pci_init(ctlr_info_t *c)
 	c->transtable = remap_pci_mem(pci_resource_start(c->pdev,
 		cfg_base_addr_index) + cfg_offset+trans_offset,
 		sizeof(*c->transtable));
-	c->board_id = board_id;
-
-	#ifdef CCISS_DEBUG
-		print_cfg_table(c->cfgtable);
-	#endif				/* CCISS_DEBUG */
+#ifdef CCISS_DEBUG
+	print_cfg_table(c->cfgtable);
+#endif				/* CCISS_DEBUG */
 
 	/* Some controllers support Zero Memory Raid (ZMR).
 	 * When configured in ZMR mode the number of supported
@@ -4139,8 +4145,6 @@ static int __devinit cciss_pci_init(ctlr_info_t *c)
 		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;
 	if ((readb(&c->cfgtable->Signature[0]) != 'C') ||
 	    (readb(&c->cfgtable->Signature[1]) != 'I') ||
@@ -4165,8 +4169,8 @@ static int __devinit cciss_pci_init(ctlr_info_t *c)
 	 * We've disabled prefetch for some time now. Testing with XEN
 	 * kernels revealed a bug in the refetch if dom0 resides on a P600.
 	 */
-	if(board_id == 0x3225103C) {
-			__u32 dma_prefetch;
+	if (c->board_id == 0x3225103C) {
+		__u32 dma_prefetch;
 		__u32 dma_refetch;
 		dma_prefetch = readl(c->vaddr + I2O_DMA1_CFG);
 		dma_prefetch |= 0x8000;


  parent reply	other threads:[~2010-07-19 18:45 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-19 18:44 [PATCH 00/26] cciss updates July 19, 2010 Stephen M. Cameron
2010-07-19 18:44 ` [PATCH 01/26] cciss: Set the performant mode bit in the scsi half of the driver Stephen M. Cameron
2010-07-19 18:44 ` [PATCH 02/26] cciss: save pdev pointer in per hba structure early to avoid passing it around so much Stephen M. Cameron
2010-07-19 18:44 ` Stephen M. Cameron [this message]
2010-07-19 18:45 ` [PATCH 04/26] cciss: factor out cciss_board_disabled Stephen M. Cameron
2010-07-19 18:45 ` [PATCH 05/26] cciss: remove board_id parameter from cciss_interrupt_mode() Stephen M. Cameron
2010-07-19 18:45 ` [PATCH 06/26] cciss: factor out cciss_find_memory_BAR() Stephen M. Cameron
2010-07-19 18:45 ` [PATCH 07/26] cciss: factor out cciss_wait_for_board_ready() Stephen M. Cameron
2010-07-19 18:45 ` [PATCH 08/26] cciss: factor out cciss_find_cfgtables Stephen M. Cameron
2010-07-19 18:45 ` [PATCH 09/26] cciss: fix leak of ioremapped memory Stephen M. Cameron
2010-07-19 18:45 ` [PATCH 10/26] cciss: factor out cciss_find_board_params Stephen M. Cameron
2010-07-19 18:45 ` [PATCH 11/26] cciss: factor out CISS_signature_present() Stephen M. Cameron
2010-07-19 18:45 ` [PATCH 12/26] cciss: factor out cciss_enable_scsi_prefetch() Stephen M. Cameron
2010-07-19 18:45 ` [PATCH 13/26] cciss: factor out cciss_p600_dma_prefetch_quirk() Stephen M. Cameron
2010-07-19 18:45 ` [PATCH 14/26] cciss: cleanup some debug ifdefs Stephen M. Cameron
2010-07-19 18:45 ` [PATCH 15/26] cciss: make cciss_put_controller_into_performant_mode as __devinit Stephen M. Cameron
2010-07-19 18:46 ` [PATCH 16/26] cciss: factor out cciss_wait_for_mode_change_ack() Stephen M. Cameron
2010-07-19 18:46 ` [PATCH 17/26] cciss: factor out cciss_enter_performant_mode Stephen M. Cameron
2010-07-19 18:46 ` [PATCH 18/26] cciss: factor out cciss_find_cfg_addrs Stephen M. Cameron
2010-07-19 18:46 ` [PATCH 19/26] cciss: factor out cciss_reset_devices() Stephen M. Cameron
2010-07-19 18:46 ` [PATCH 20/26] cciss: fix hard reset code Stephen M. Cameron
2010-07-19 18:46 ` [PATCH 21/26] cciss: sanitize max commands Stephen M. Cameron
2010-07-19 18:46 ` [PATCH 22/26] cciss: forbid hard reset of 640x boards Stephen M. Cameron
2010-07-19 18:46 ` [PATCH 23/26] cciss: use consistent variable names Stephen M. Cameron
2010-07-19 18:46 ` [PATCH 24/26] cciss: separate cmd_alloc() and cmd_special_alloc() Stephen M. Cameron
2010-07-19 18:46 ` [PATCH 25/26] cciss: change printks to dev_warn, etc Stephen M. Cameron
2010-07-19 18:46 ` [PATCH 26/26] cciss: cleanup interrupt_not_for_us Stephen M. Cameron
2010-07-21  2:05 ` [PATCH 00/26] cciss updates July 19, 2010 Jens Axboe

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=20100719184455.7908.24283.stgit@beardog.cce.hp.com \
    --to=scameron@beardog.cce.hp.com \
    --cc=akpm@linux-foundation.org \
    --cc=axboe@kernel.dk \
    --cc=brace@beardog.cce.hp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mikem@beardog.cce.hp.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox