diff options
author | Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com> | 2006-12-17 20:30:00 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2007-02-07 18:50:03 -0500 |
commit | 38cc13022ed3cea949722d5a6f49025da82c9fd0 (patch) | |
tree | 5d6051a294f70dca2fdb86b1966cb3a5945fdfb8 /drivers/pci/pci.c | |
parent | 9fb625c3cc3731097a142ecae79a0369fb854c2d (diff) |
PCI : add extremely specialized __pci_reenable_device for default resume
Original patch was posted as "PCI : Move pci_fixup_device and is_enabled".
This 3 of 3 patches does:
- add __pci_reenable_device
(recover former change of 1st patch)
Signed-off-by: Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>
Signed-off-by: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
Cc: Inaky Perez-Gonzalez <inaky@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
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 | ||