Commit 85bdbabb authored by Stephen M. Cameron's avatar Stephen M. Cameron Committed by James Bottomley

[SCSI] hpsa: factor out hpsa_board_disabled

Signed-off-by: default avatarStephen M. Cameron <scameron@beardog.cce.hp.com>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@suse.de>
parent e5c880d1
...@@ -3278,9 +3278,16 @@ static int __devinit hpsa_lookup_board_id(struct pci_dev *pdev, u32 *board_id) ...@@ -3278,9 +3278,16 @@ static int __devinit hpsa_lookup_board_id(struct pci_dev *pdev, u32 *board_id)
return ARRAY_SIZE(products) - 1; /* generic unknown smart array */ return ARRAY_SIZE(products) - 1; /* generic unknown smart array */
} }
static inline bool hpsa_board_disabled(struct pci_dev *pdev)
{
u16 command;
(void) pci_read_config_word(pdev, PCI_COMMAND, &command);
return ((command & PCI_COMMAND_MEMORY) == 0);
}
static int __devinit hpsa_pci_init(struct ctlr_info *h) static int __devinit hpsa_pci_init(struct ctlr_info *h)
{ {
ushort command;
u32 scratchpad = 0; u32 scratchpad = 0;
u64 cfg_offset; u64 cfg_offset;
u32 cfg_base_addr; u32 cfg_base_addr;
...@@ -3294,15 +3301,10 @@ static int __devinit hpsa_pci_init(struct ctlr_info *h) ...@@ -3294,15 +3301,10 @@ static int __devinit hpsa_pci_init(struct ctlr_info *h)
h->product_name = products[prod_index].product_name; h->product_name = products[prod_index].product_name;
h->access = *(products[prod_index].access); h->access = *(products[prod_index].access);
/* check to see if controller has been disabled if (hpsa_board_disabled(h->pdev)) {
* BEFORE trying to enable it
*/
(void)pci_read_config_word(h->pdev, PCI_COMMAND, &command);
if (!(command & 0x02)) {
dev_warn(&h->pdev->dev, "controller appears to be disabled\n"); dev_warn(&h->pdev->dev, "controller appears to be disabled\n");
return -ENODEV; return -ENODEV;
} }
err = pci_enable_device(h->pdev); err = pci_enable_device(h->pdev);
if (err) { if (err) {
dev_warn(&h->pdev->dev, "unable to enable PCI device\n"); dev_warn(&h->pdev->dev, "unable to enable PCI device\n");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment