diff options
Diffstat (limited to 'drivers/pci/pci.c')
-rw-r--r-- | drivers/pci/pci.c | 41 |
1 files changed, 32 insertions, 9 deletions
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 212acd2e1a84..287b685aaa5c 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c | |||
@@ -676,6 +676,36 @@ pci_restore_state(struct pci_dev *dev) | |||
676 | return 0; | 676 | return 0; |
677 | } | 677 | } |
678 | 678 | ||
679 | static int do_pci_enable_device(struct pci_dev *dev, int bars) | ||
680 | { | ||
681 | int err; | ||
682 | |||
683 | err = pci_set_power_state(dev, PCI_D0); | ||
684 | if (err < 0 && err != -EIO) | ||
685 | return err; | ||
686 | err = pcibios_enable_device(dev, bars); | ||
687 | if (err < 0) | ||
688 | return err; | ||
689 | pci_fixup_device(pci_fixup_enable, dev); | ||
690 | |||
691 | return 0; | ||
692 | } | ||
693 | |||
694 | /** | ||
695 | * __pci_reenable_device - Resume abandoned device | ||
696 | * @dev: PCI device to be resumed | ||
697 | * | ||
698 | * Note this function is a backend of pci_default_resume and is not supposed | ||
699 | * to be called by normal code, write proper resume handler and use it instead. | ||
700 | */ | ||
701 | int | ||
702 | __pci_reenable_device(struct pci_dev *dev) | ||
703 | { | ||
704 | if (atomic_read(&dev->enable_cnt)) | ||
705 | return do_pci_enable_device(dev, (1 << PCI_NUM_RESOURCES) - 1); | ||
706 | return 0; | ||
707 | } | ||
708 | |||
679 | /** | 709 | /** |
680 | * pci_enable_device_bars - Initialize some of a device for use | 710 | * pci_enable_device_bars - Initialize some of a device for use |
681 | * @dev: PCI device to be initialized | 711 | * @dev: PCI device to be initialized |
@@ -693,16 +723,9 @@ pci_enable_device_bars(struct pci_dev *dev, int bars) | |||
693 | if (atomic_add_return(1, &dev->enable_cnt) > 1) | 723 | if (atomic_add_return(1, &dev->enable_cnt) > 1) |
694 | return 0; /* already enabled */ | 724 | return 0; /* already enabled */ |
695 | 725 | ||
696 | err = pci_set_power_state(dev, PCI_D0); | 726 | err = do_pci_enable_device(dev, bars); |
697 | if (err < 0 && err != -EIO) | ||
698 | goto err_out; | ||
699 | err = pcibios_enable_device(dev, bars); | ||
700 | if (err < 0) | 727 | if (err < 0) |
701 | goto err_out; | 728 | atomic_dec(&dev->enable_cnt); |
702 | pci_fixup_device(pci_fixup_enable, dev); | ||
703 | |||
704 | err_out: | ||
705 | atomic_dec(&dev->enable_cnt); | ||
706 | return err; | 729 | return err; |
707 | } | 730 | } |
708 | 731 | ||