aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen M. Cameron <scameron@beardog.cce.hp.com>2010-07-19 14:45:21 -0400
committerJens Axboe <jaxboe@fusionio.com>2010-08-07 12:52:11 -0400
commit4809d0988f10e305511d1a3e223880fa4b21f90e (patch)
treeffabdf7aaf8871327ab7af234a7a31822c5ca3c0
parente99ba1362723df14bbe36da6eeaadf81d95782e6 (diff)
cciss: factor out cciss_find_cfgtables
cciss: factor out cciss_find_cfgtables Signed-off-by: Stephen M. Cameron <scameron@beardog.cce.hp.com> Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
-rw-r--r--drivers/block/cciss.c68
1 files changed, 34 insertions, 34 deletions
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index 286c81d70818..c297d31d0c97 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)
4041 return -ENODEV; 4041 return -ENODEV;
4042} 4042}
4043 4043
4044static int __devinit cciss_find_cfgtables(ctlr_info_t *h)
4045{
4046 u64 cfg_offset;
4047 u32 cfg_base_addr;
4048 u64 cfg_base_addr_index;
4049 u32 trans_offset;
4050
4051 /* get the address index number */
4052 cfg_base_addr = readl(h->vaddr + SA5_CTCFG_OFFSET);
4053 cfg_base_addr &= (u32) 0x0000ffff;
4054 cfg_base_addr_index = find_PCI_BAR_index(h->pdev, cfg_base_addr);
4055 if (cfg_base_addr_index == -1) {
4056 dev_warn(&h->pdev->dev, "cannot find cfg_base_addr_index\n");
4057 return -ENODEV;
4058 }
4059 cfg_offset = readl(h->vaddr + SA5_CTMEM_OFFSET);
4060 h->cfgtable = remap_pci_mem(pci_resource_start(h->pdev,
4061 cfg_base_addr_index) + cfg_offset,
4062 sizeof(h->cfgtable));
4063 if (!h->cfgtable)
4064 return -ENOMEM;
4065 /* Find performant mode table. */
4066 trans_offset = readl(&(h->cfgtable->TransMethodOffset));
4067 h->transtable = remap_pci_mem(pci_resource_start(h->pdev,
4068 cfg_base_addr_index)+cfg_offset+trans_offset,
4069 sizeof(*h->transtable));
4070 if (!h->transtable)
4071 return -ENOMEM;
4072 return 0;
4073}
4074
4044static int __devinit cciss_pci_init(ctlr_info_t *c) 4075static int __devinit cciss_pci_init(ctlr_info_t *c)
4045{ 4076{
4046 __u64 cfg_offset; 4077 int prod_index, err;
4047 __u32 cfg_base_addr;
4048 __u64 cfg_base_addr_index;
4049 __u32 trans_offset;
4050 int i, prod_index, err;
4051 4078
4052 prod_index = cciss_lookup_board_id(c->pdev, &c->board_id); 4079 prod_index = cciss_lookup_board_id(c->pdev, &c->board_id);
4053 if (prod_index < 0) 4080 if (prod_index < 0)
@@ -4090,36 +4117,9 @@ static int __devinit cciss_pci_init(ctlr_info_t *c)
4090 err = cciss_wait_for_board_ready(c); 4117 err = cciss_wait_for_board_ready(c);
4091 if (err) 4118 if (err)
4092 goto err_out_free_res; 4119 goto err_out_free_res;
4093 4120 err = cciss_find_cfgtables(c);
4094 /* get the address index number */ 4121 if (err)
4095 cfg_base_addr = readl(c->vaddr + SA5_CTCFG_OFFSET);
4096 cfg_base_addr &= (__u32) 0x0000ffff;
4097#ifdef CCISS_DEBUG
4098 printk("cfg base address = %x\n", cfg_base_addr);
4099#endif /* CCISS_DEBUG */
4100 cfg_base_addr_index = find_PCI_BAR_index(c->pdev, cfg_base_addr);
4101#ifdef CCISS_DEBUG
4102 printk("cfg base address index = %llx\n",
4103 (unsigned long long)cfg_base_addr_index);
4104#endif /* CCISS_DEBUG */
4105 if (cfg_base_addr_index == -1) {
4106 printk(KERN_WARNING "cciss: Cannot find cfg_base_addr_index\n");
4107 err = -ENODEV;
4108 goto err_out_free_res; 4122 goto err_out_free_res;
4109 }
4110
4111 cfg_offset = readl(c->vaddr + SA5_CTMEM_OFFSET);
4112#ifdef CCISS_DEBUG
4113 printk("cfg offset = %llx\n", (unsigned long long)cfg_offset);
4114#endif /* CCISS_DEBUG */
4115 c->cfgtable = remap_pci_mem(pci_resource_start(c->pdev,
4116 cfg_base_addr_index) +
4117 cfg_offset, sizeof(CfgTable_struct));
4118 /* Find performant mode table. */
4119 trans_offset = readl(&(c->cfgtable->TransMethodOffset));
4120 c->transtable = remap_pci_mem(pci_resource_start(c->pdev,
4121 cfg_base_addr_index) + cfg_offset+trans_offset,
4122 sizeof(*c->transtable));
4123#ifdef CCISS_DEBUG 4123#ifdef CCISS_DEBUG
4124 print_cfg_table(c->cfgtable); 4124 print_cfg_table(c->cfgtable);
4125#endif /* CCISS_DEBUG */ 4125#endif /* CCISS_DEBUG */