aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block
diff options
context:
space:
mode:
authorStephen M. Cameron <scameron@beardog.cce.hp.com>2010-07-19 14:45:10 -0400
committerJens Axboe <jaxboe@fusionio.com>2010-08-07 12:52:10 -0400
commitd474830da6218c0b7f81eab03aff7d8c539bdb57 (patch)
tree0ca26c1ab067fec7ca9b57e0255373710fe32126 /drivers/block
parentdac5488a9ed6b6e59749e161209a6678980803f1 (diff)
cciss: factor out cciss_find_memory_BAR()
cciss: factor out cciss_find_memory_BAR() Signed-off-by: Stephen M. Cameron <scameron@beardog.cce.hp.com> Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
Diffstat (limited to 'drivers/block')
-rw-r--r--drivers/block/cciss.c37
1 files changed, 19 insertions, 18 deletions
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index bb22a80d448f..9c9c79c0aa98 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -4009,6 +4009,23 @@ static inline bool cciss_board_disabled(ctlr_info_t *h)
4009 return ((command & PCI_COMMAND_MEMORY) == 0); 4009 return ((command & PCI_COMMAND_MEMORY) == 0);
4010} 4010}
4011 4011
4012static int __devinit cciss_pci_find_memory_BAR(struct pci_dev *pdev,
4013 unsigned long *memory_bar)
4014{
4015 int i;
4016
4017 for (i = 0; i < DEVICE_COUNT_RESOURCE; i++)
4018 if (pci_resource_flags(pdev, i) & IORESOURCE_MEM) {
4019 /* addressing mode bits already removed */
4020 *memory_bar = pci_resource_start(pdev, i);
4021 dev_dbg(&pdev->dev, "memory BAR = %lx\n",
4022 *memory_bar);
4023 return 0;
4024 }
4025 dev_warn(&pdev->dev, "no memory BAR found\n");
4026 return -ENODEV;
4027}
4028
4012static int __devinit cciss_pci_init(ctlr_info_t *c) 4029static int __devinit cciss_pci_init(ctlr_info_t *c)
4013{ 4030{
4014 __u32 scratchpad = 0; 4031 __u32 scratchpad = 0;
@@ -4052,25 +4069,9 @@ static int __devinit cciss_pci_init(ctlr_info_t *c)
4052 * else we use the IO-APIC interrupt assigned to us by system ROM. 4069 * else we use the IO-APIC interrupt assigned to us by system ROM.
4053 */ 4070 */
4054 cciss_interrupt_mode(c); 4071 cciss_interrupt_mode(c);
4055 4072 err = cciss_pci_find_memory_BAR(c->pdev, &c->paddr);
4056 /* find the memory BAR */ 4073 if (err)
4057 for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) {
4058 if (pci_resource_flags(c->pdev, i) & IORESOURCE_MEM)
4059 break;
4060 }
4061 if (i == DEVICE_COUNT_RESOURCE) {
4062 printk(KERN_WARNING "cciss: No memory BAR found\n");
4063 err = -ENODEV;
4064 goto err_out_free_res; 4074 goto err_out_free_res;
4065 }
4066
4067 c->paddr = pci_resource_start(c->pdev, i); /* addressing mode bits
4068 * already removed
4069 */
4070
4071#ifdef CCISS_DEBUG
4072 printk("address 0 = %lx\n", c->paddr);
4073#endif /* CCISS_DEBUG */
4074 c->vaddr = remap_pci_mem(c->paddr, 0x250); 4075 c->vaddr = remap_pci_mem(c->paddr, 0x250);
4075 4076
4076 /* Wait for the board to become ready. (PCI hotplug needs this.) 4077 /* Wait for the board to become ready. (PCI hotplug needs this.)