[PATCH 08/26] cciss: factor out cciss_find_cfgtables

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Stephen M. Cameron
Date: Monday, July 19, 2010 - 11:45 am

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

cciss: factor out cciss_find_cfgtables

Signed-off-by: Stephen M. Cameron <scameron@beardog.cce.hp.com>
---
 drivers/block/cciss.c |   68 +++++++++++++++++++++++++------------------------
 1 files changed, 34 insertions(+), 34 deletions(-)

diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index 286c81d..c297d31 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -4041,13 +4041,40 @@ static int __devinit cciss_wait_for_board_ready(ctlr_info_t *h)
 	return -ENODEV;
 }
 
+static int __devinit cciss_find_cfgtables(ctlr_info_t *h)
+{
+	u64 cfg_offset;
+	u32 cfg_base_addr;
+	u64 cfg_base_addr_index;
+	u32 trans_offset;
+
+	/* get the address index number */
+	cfg_base_addr = readl(h->vaddr + SA5_CTCFG_OFFSET);
+	cfg_base_addr &= (u32) 0x0000ffff;
+	cfg_base_addr_index = find_PCI_BAR_index(h->pdev, cfg_base_addr);
+	if (cfg_base_addr_index == -1) {
+		dev_warn(&h->pdev->dev, "cannot find cfg_base_addr_index\n");
+		return -ENODEV;
+	}
+	cfg_offset = readl(h->vaddr + SA5_CTMEM_OFFSET);
+	h->cfgtable = remap_pci_mem(pci_resource_start(h->pdev,
+			       cfg_base_addr_index) + cfg_offset,
+				sizeof(h->cfgtable));
+	if (!h->cfgtable)
+		return -ENOMEM;
+	/* Find performant mode table. */
+	trans_offset = readl(&(h->cfgtable->TransMethodOffset));
+	h->transtable = remap_pci_mem(pci_resource_start(h->pdev,
+				cfg_base_addr_index)+cfg_offset+trans_offset,
+				sizeof(*h->transtable));
+	if (!h->transtable)
+		return -ENOMEM;
+	return 0;
+}
+
 static int __devinit cciss_pci_init(ctlr_info_t *c)
 {
-	__u64 cfg_offset;
-	__u32 cfg_base_addr;
-	__u64 cfg_base_addr_index;
-	__u32 trans_offset;
-	int i, prod_index, err;
+	int prod_index, err;
 
 	prod_index = cciss_lookup_board_id(c->pdev, &c->board_id);
 	if (prod_index < 0)
@@ -4090,36 +4117,9 @@ static int __devinit cciss_pci_init(ctlr_info_t *c)
 	err = cciss_wait_for_board_ready(c);
 	if (err)
 		goto err_out_free_res;
-
-	/* get the address index number */
-	cfg_base_addr = readl(c->vaddr + SA5_CTCFG_OFFSET);
-	cfg_base_addr &= (__u32) 0x0000ffff;
-#ifdef CCISS_DEBUG
-	printk("cfg base address = %x\n", cfg_base_addr);
-#endif				/* CCISS_DEBUG */
-	cfg_base_addr_index = find_PCI_BAR_index(c->pdev, cfg_base_addr);
-#ifdef CCISS_DEBUG
-	printk("cfg base address index = %llx\n",
-		(unsigned long long)cfg_base_addr_index);
-#endif				/* CCISS_DEBUG */
-	if (cfg_base_addr_index == -1) {
-		printk(KERN_WARNING "cciss: Cannot find cfg_base_addr_index\n");
-		err = -ENODEV;
+	err = cciss_find_cfgtables(c);
+	if (err)
 		goto err_out_free_res;
-	}
-
-	cfg_offset = readl(c->vaddr + SA5_CTMEM_OFFSET);
-#ifdef CCISS_DEBUG
-	printk("cfg offset = %llx\n", (unsigned long long)cfg_offset);
-#endif				/* CCISS_DEBUG */
-	c->cfgtable = remap_pci_mem(pci_resource_start(c->pdev,
-						       cfg_base_addr_index) +
-				    cfg_offset, sizeof(CfgTable_struct));
-	/* Find performant mode table. */
-	trans_offset = readl(&(c->cfgtable->TransMethodOffset));
-	c->transtable = remap_pci_mem(pci_resource_start(c->pdev,
-		cfg_base_addr_index) + cfg_offset+trans_offset,
-		sizeof(*c->transtable));
 #ifdef CCISS_DEBUG
 	print_cfg_table(c->cfgtable);
 #endif				/* CCISS_DEBUG */

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 00/26] cciss updates July 19, 2010 , Stephen M. Cameron, (Mon Jul 19, 11:44 am)
[PATCH 01/26] cciss: Set the performant mode bit in the sc ..., Stephen M. Cameron, (Mon Jul 19, 11:44 am)
[PATCH 02/26] cciss: save pdev pointer in per hba structur ..., Stephen M. Cameron, (Mon Jul 19, 11:44 am)
[PATCH 03/26] cciss: factor out cciss_lookup_board_id, Stephen M. Cameron, (Mon Jul 19, 11:44 am)
[PATCH 04/26] cciss: factor out cciss_board_disabled, Stephen M. Cameron, (Mon Jul 19, 11:45 am)
[PATCH 05/26] cciss: remove board_id parameter from cciss_ ..., Stephen M. Cameron, (Mon Jul 19, 11:45 am)
[PATCH 06/26] cciss: factor out cciss_find_memory_BAR(), Stephen M. Cameron, (Mon Jul 19, 11:45 am)
[PATCH 07/26] cciss: factor out cciss_wait_for_board_ready(), Stephen M. Cameron, (Mon Jul 19, 11:45 am)
[PATCH 08/26] cciss: factor out cciss_find_cfgtables, Stephen M. Cameron, (Mon Jul 19, 11:45 am)
[PATCH 09/26] cciss: fix leak of ioremapped memory, Stephen M. Cameron, (Mon Jul 19, 11:45 am)
[PATCH 10/26] cciss: factor out cciss_find_board_params, Stephen M. Cameron, (Mon Jul 19, 11:45 am)
[PATCH 11/26] cciss: factor out CISS_signature_present(), Stephen M. Cameron, (Mon Jul 19, 11:45 am)
[PATCH 12/26] cciss: factor out cciss_enable_scsi_prefetch(), Stephen M. Cameron, (Mon Jul 19, 11:45 am)
[PATCH 13/26] cciss: factor out cciss_p600_dma_prefetch_qu ..., Stephen M. Cameron, (Mon Jul 19, 11:45 am)
[PATCH 14/26] cciss: cleanup some debug ifdefs, Stephen M. Cameron, (Mon Jul 19, 11:45 am)
[PATCH 15/26] cciss: make cciss_put_controller_into_perfor ..., Stephen M. Cameron, (Mon Jul 19, 11:45 am)
[PATCH 16/26] cciss: factor out cciss_wait_for_mode_change ..., Stephen M. Cameron, (Mon Jul 19, 11:46 am)
[PATCH 17/26] cciss: factor out cciss_enter_performant_mode, Stephen M. Cameron, (Mon Jul 19, 11:46 am)
[PATCH 18/26] cciss: factor out cciss_find_cfg_addrs., Stephen M. Cameron, (Mon Jul 19, 11:46 am)
[PATCH 19/26] cciss: factor out cciss_reset_devices(), Stephen M. Cameron, (Mon Jul 19, 11:46 am)
[PATCH 20/26] cciss: fix hard reset code., Stephen M. Cameron, (Mon Jul 19, 11:46 am)
[PATCH 21/26] cciss: sanitize max commands, Stephen M. Cameron, (Mon Jul 19, 11:46 am)
[PATCH 22/26] cciss: forbid hard reset of 640x boards, Stephen M. Cameron, (Mon Jul 19, 11:46 am)
[PATCH 23/26] cciss: use consistent variable names, Stephen M. Cameron, (Mon Jul 19, 11:46 am)
[PATCH 24/26] cciss: separate cmd_alloc() and cmd_special_ ..., Stephen M. Cameron, (Mon Jul 19, 11:46 am)
[PATCH 25/26] cciss: change printks to dev_warn, etc., Stephen M. Cameron, (Mon Jul 19, 11:46 am)
[PATCH 26/26] cciss: cleanup interrupt_not_for_us, Stephen M. Cameron, (Mon Jul 19, 11:46 am)
Re: [PATCH 00/26] cciss updates July 19, 2010, Jens Axboe, (Tue Jul 20, 7:05 pm)