The patch titled pci pm: make more PCI PM core functionality available to drivers has been added to the -mm tree. Its filename is pci-pm-make-more-pci-pm-core-functionality-available-to-drivers.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/SubmitChecklist when testing your code *** See http://www.zip.com.au/~akpm/linux/patches/stuff/added-to-mm.txt to find out what to do about this The current -mm tree may be found at http://userweb.kernel.org/~akpm/mmotm/ ------------------------------------------------------ Subject: pci pm: make more PCI PM core functionality available to drivers From: Rafael J. Wysocki <rjw@xxxxxxx> Make more PCI PM core functionality available to drivers * Export pci_pme_capable() so that it can be called directly by drivers (for example, tg3 needs that). * Move the state choosing part of pci_prepare_to_sleep() to a separate function, pci_target_state(), that can be called directly by drivers (for example, tg3 needs that). Signed-off-by: Rafael J. Wysocki <rjw@xxxxxxx> Cc: Stephen Hemminger <shemminger@xxxxxxxxxxxxxxxxxxxx> Cc: Jeff Garzik <jeff@xxxxxxxxxx> Cc: Jesse Barnes <jbarnes@xxxxxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- drivers/pci/pci.c | 35 +++++++++++++++++++++++++---------- include/linux/pci.h | 2 ++ 2 files changed, 27 insertions(+), 10 deletions(-) diff -puN drivers/pci/pci.c~pci-pm-make-more-pci-pm-core-functionality-available-to-drivers drivers/pci/pci.c --- a/drivers/pci/pci.c~pci-pm-make-more-pci-pm-core-functionality-available-to-drivers +++ a/drivers/pci/pci.c @@ -1040,7 +1040,7 @@ int pci_set_pcie_reset_state(struct pci_ * @dev: PCI device to handle. * @state: PCI state from which device will issue PME#. */ -static bool pci_pme_capable(struct pci_dev *dev, pci_power_t state) +bool pci_pme_capable(struct pci_dev *dev, pci_power_t state) { if (!dev->pm_cap) return false; @@ -1123,18 +1123,11 @@ int pci_enable_wake(struct pci_dev *dev, } /** - * pci_prepare_to_sleep - prepare PCI device for system-wide transition into - * a sleep state - * @dev: Device to handle. * - * Choose the power state appropriate for the device depending on whether - * it can wake up the system and/or is power manageable by the platform - * (PCI_D3hot is the default) and put the device into that state. */ -int pci_prepare_to_sleep(struct pci_dev *dev) +pci_power_t pci_target_state(struct pci_dev *dev) { pci_power_t target_state = PCI_D3hot; - int error; if (platform_pci_power_manageable(dev)) { /* @@ -1161,7 +1154,7 @@ int pci_prepare_to_sleep(struct pci_dev * to generate PME#. */ if (!dev->pm_cap) - return -EIO; + return PCI_POWER_ERROR; if (dev->pme_support) { while (target_state @@ -1170,6 +1163,26 @@ int pci_prepare_to_sleep(struct pci_dev } } + return target_state; +} + +/** + * pci_prepare_to_sleep - prepare PCI device for system-wide transition into + * a sleep state + * @dev: Device to handle. + * + * Choose the power state appropriate for the device depending on whether + * it can wake up the system and/or is power manageable by the platform + * (PCI_D3hot is the default) and put the device into that state. + */ +int pci_prepare_to_sleep(struct pci_dev *dev) +{ + pci_power_t target_state = pci_target_state(dev); + int error; + + if (target_state == PCI_POWER_ERROR) + return -EIO; + pci_enable_wake(dev, target_state, true); error = pci_set_power_state(dev, target_state); @@ -1920,7 +1933,9 @@ EXPORT_SYMBOL(pci_select_bars); EXPORT_SYMBOL(pci_set_power_state); EXPORT_SYMBOL(pci_save_state); EXPORT_SYMBOL(pci_restore_state); +EXPORT_SYMBOL(pci_pme_capable); EXPORT_SYMBOL(pci_enable_wake); +EXPORT_SYMBOL(pci_target_state); EXPORT_SYMBOL(pci_prepare_to_sleep); EXPORT_SYMBOL(pci_back_from_sleep); EXPORT_SYMBOL_GPL(pci_set_pcie_reset_state); diff -puN include/linux/pci.h~pci-pm-make-more-pci-pm-core-functionality-available-to-drivers include/linux/pci.h --- a/include/linux/pci.h~pci-pm-make-more-pci-pm-core-functionality-available-to-drivers +++ a/include/linux/pci.h @@ -638,7 +638,9 @@ int pci_save_state(struct pci_dev *dev); int pci_restore_state(struct pci_dev *dev); int pci_set_power_state(struct pci_dev *dev, pci_power_t state); pci_power_t pci_choose_state(struct pci_dev *dev, pm_message_t state); +bool pci_pme_capable(struct pci_dev *dev, pci_power_t state); int pci_enable_wake(struct pci_dev *dev, pci_power_t state, int enable); +pci_power_t pci_target_state(struct pci_dev *dev); int pci_prepare_to_sleep(struct pci_dev *dev); int pci_back_from_sleep(struct pci_dev *dev); _ Patches currently in -mm which might be from rjw@xxxxxxx are origin.patch linux-next.patch skge-adapt-skge-to-use-reworked-pci-pm.patch pci-pm-make-more-pci-pm-core-functionality-available-to-drivers.patch swsusp-provide-users-with-a-hint-about-the-no_console_suspend-option.patch swsusp-provide-users-with-a-hint-about-the-no_console_suspend-option-fix.patch pm-boot-time-suspend-selftest.patch pm-boot-time-suspend-selftest-vs-linux-next.patch pm-boot-time-suspend-selftest-update.patch remove-include-linux-pm_legacyh.patch pm-remove-definition-of-struct-pm_dev.patch pm-remove-remaining-obsolete-definitions-from-pmh.patch pm-remove-obsolete-piece-of-pm-documentation-rev-2.patch pm-drop-unnecessary-includes-from-pmh.patch pm-add-new-pm_event-codes-for-runtime-power-transitions.patch pm-hibernation-simplify-memory-bitmap.patch pm-serio-speed-up-resume.patch pm-introduce-new-interfaces-schedule_work_on-and-queue_work_on.patch pm-introduce-new-interfaces-schedule_work_on-and-queue_work_on-cleanup.patch pm-schedule-sysrq-poweroff-on-boot-cpu.patch pm-schedule-sysrq-poweroff-on-boot-cpu-fix.patch pm-acpi-hibernation-utilize-hardware-signature.patch pm-acpi-hibernation-utilize-hardware-signaturepatch-causes-build-error.patch pm-acpi-pm-add-dmi-quirk-list-for-acpi-10-suspend-ordering.patch pm-fix-try_to_freeze_taskss-use-of-do_div.patch drivers-power-fix-platform-driver-hotplug-coldplug.patch mfd-fix-platform-driver-hotplug-coldplug.patch parport-fix-platform-driver-hotplug-coldplug.patch kexec-jump.patch kexec-jump-save-restore-device-state.patch shrink_slab-handle-bad-shrinkers.patch tg3-adapt-tg3-to-use-reworked-pci-pm-code.patch sky2-adapt-sky2-to-use-reworked-pci-pm.patch -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html