diff options
author | Stephen M. Cameron <scameron@beardog.cce.hp.com> | 2010-07-19 14:45:15 -0400 |
---|---|---|
committer | Jens Axboe <jaxboe@fusionio.com> | 2010-08-07 12:52:11 -0400 |
commit | e99ba1362723df14bbe36da6eeaadf81d95782e6 (patch) | |
tree | 5bf701fa79a250f1fde71b1b22cf6e35b21e9c59 /drivers/block/cciss.c | |
parent | d474830da6218c0b7f81eab03aff7d8c539bdb57 (diff) |
cciss: factor out cciss_wait_for_board_ready()
cciss: factor out cciss_wait_for_board_ready()
Signed-off-by: Stephen M. Cameron <scameron@beardog.cce.hp.com>
Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
Diffstat (limited to 'drivers/block/cciss.c')
-rw-r--r-- | drivers/block/cciss.c | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c index 9c9c79c0aa98..286c81d70818 100644 --- a/drivers/block/cciss.c +++ b/drivers/block/cciss.c | |||
@@ -4026,9 +4026,23 @@ static int __devinit cciss_pci_find_memory_BAR(struct pci_dev *pdev, | |||
4026 | return -ENODEV; | 4026 | return -ENODEV; |
4027 | } | 4027 | } |
4028 | 4028 | ||
4029 | static int __devinit cciss_wait_for_board_ready(ctlr_info_t *h) | ||
4030 | { | ||
4031 | int i; | ||
4032 | u32 scratchpad; | ||
4033 | |||
4034 | for (i = 0; i < CCISS_BOARD_READY_ITERATIONS; i++) { | ||
4035 | scratchpad = readl(h->vaddr + SA5_SCRATCHPAD_OFFSET); | ||
4036 | if (scratchpad == CCISS_FIRMWARE_READY) | ||
4037 | return 0; | ||
4038 | msleep(CCISS_BOARD_READY_POLL_INTERVAL_MSECS); | ||
4039 | } | ||
4040 | dev_warn(&h->pdev->dev, "board not ready, timed out.\n"); | ||
4041 | return -ENODEV; | ||
4042 | } | ||
4043 | |||
4029 | static int __devinit cciss_pci_init(ctlr_info_t *c) | 4044 | static int __devinit cciss_pci_init(ctlr_info_t *c) |
4030 | { | 4045 | { |
4031 | __u32 scratchpad = 0; | ||
4032 | __u64 cfg_offset; | 4046 | __u64 cfg_offset; |
4033 | __u32 cfg_base_addr; | 4047 | __u32 cfg_base_addr; |
4034 | __u64 cfg_base_addr_index; | 4048 | __u64 cfg_base_addr_index; |
@@ -4073,21 +4087,9 @@ static int __devinit cciss_pci_init(ctlr_info_t *c) | |||
4073 | if (err) | 4087 | if (err) |
4074 | goto err_out_free_res; | 4088 | goto err_out_free_res; |
4075 | c->vaddr = remap_pci_mem(c->paddr, 0x250); | 4089 | c->vaddr = remap_pci_mem(c->paddr, 0x250); |
4076 | 4090 | err = cciss_wait_for_board_ready(c); | |
4077 | /* Wait for the board to become ready. (PCI hotplug needs this.) | 4091 | if (err) |
4078 | * We poll for up to 120 secs, once per 100ms. */ | ||
4079 | for (i = 0; i < 1200; i++) { | ||
4080 | scratchpad = readl(c->vaddr + SA5_SCRATCHPAD_OFFSET); | ||
4081 | if (scratchpad == CCISS_FIRMWARE_READY) | ||
4082 | break; | ||
4083 | set_current_state(TASK_INTERRUPTIBLE); | ||
4084 | schedule_timeout(msecs_to_jiffies(100)); /* wait 100ms */ | ||
4085 | } | ||
4086 | if (scratchpad != CCISS_FIRMWARE_READY) { | ||
4087 | printk(KERN_WARNING "cciss: Board not ready. Timed out.\n"); | ||
4088 | err = -ENODEV; | ||
4089 | goto err_out_free_res; | 4092 | goto err_out_free_res; |
4090 | } | ||
4091 | 4093 | ||
4092 | /* get the address index number */ | 4094 | /* get the address index number */ |
4093 | cfg_base_addr = readl(c->vaddr + SA5_CTCFG_OFFSET); | 4095 | cfg_base_addr = readl(c->vaddr + SA5_CTCFG_OFFSET); |