Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 336612
b: refs/heads/master
c: b88ce2a
h: refs/heads/master
v: v3
  • Loading branch information
Rafael J. Wysocki committed Nov 26, 2012
1 parent 6baa1e6 commit 869b5ac
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 9 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 1399dfcdfe89898ccd791216f9679ba734aea910
refs/heads/master: b88ce2a41562d1a9554f209e0f31a32d9f473794
28 changes: 24 additions & 4 deletions trunk/drivers/acpi/device_pm.c
Original file line number Diff line number Diff line change
Expand Up @@ -599,18 +599,20 @@ static struct dev_pm_domain acpi_general_pm_domain = {
/**
* acpi_dev_pm_attach - Prepare device for ACPI power management.
* @dev: Device to prepare.
* @power_on: Whether or not to power on the device.
*
* If @dev has a valid ACPI handle that has a valid struct acpi_device object
* attached to it, install a wakeup notification handler for the device and
* add it to the general ACPI PM domain.
* add it to the general ACPI PM domain. If @power_on is set, the device will
* be put into the ACPI D0 state before the function returns.
*
* This assumes that the @dev's bus type uses generic power management callbacks
* (or doesn't use any power management callbacks at all).
*
* Callers must ensure proper synchronization of this function with power
* management callbacks.
*/
int acpi_dev_pm_attach(struct device *dev)
int acpi_dev_pm_attach(struct device *dev, bool power_on)
{
struct acpi_device *adev = acpi_dev_pm_get_node(dev);

Expand All @@ -622,27 +624,45 @@ int acpi_dev_pm_attach(struct device *dev)

acpi_add_pm_notifier(adev, acpi_wakeup_device, dev);
dev->pm_domain = &acpi_general_pm_domain;
if (power_on) {
acpi_dev_pm_full_power(adev);
__acpi_device_run_wake(adev, false);
}
return 0;
}
EXPORT_SYMBOL_GPL(acpi_dev_pm_attach);

/**
* acpi_dev_pm_detach - Remove ACPI power management from the device.
* @dev: Device to take care of.
* @power_off: Whether or not to try to remove power from the device.
*
* Remove the device from the general ACPI PM domain and remove its wakeup
* notifier.
* notifier. If @power_off is set, additionally remove power from the device if
* possible.
*
* Callers must ensure proper synchronization of this function with power
* management callbacks.
*/
void acpi_dev_pm_detach(struct device *dev)
void acpi_dev_pm_detach(struct device *dev, bool power_off)
{
struct acpi_device *adev = acpi_dev_pm_get_node(dev);

if (adev && dev->pm_domain == &acpi_general_pm_domain) {
dev->pm_domain = NULL;
acpi_remove_pm_notifier(adev, acpi_wakeup_device);
if (power_off) {
/*
* If the device's PM QoS resume latency limit or flags
* have been exposed to user space, they have to be
* hidden at this point, so that they don't affect the
* choice of the low-power state to put the device into.
*/
dev_pm_qos_hide_latency_limit(dev);
dev_pm_qos_hide_flags(dev);
__acpi_device_run_wake(adev, false);
acpi_dev_pm_low_power(dev, adev, ACPI_STATE_S0);
}
}
}
EXPORT_SYMBOL_GPL(acpi_dev_pm_detach);
11 changes: 7 additions & 4 deletions trunk/include/linux/acpi.h
Original file line number Diff line number Diff line change
Expand Up @@ -458,11 +458,14 @@ static inline int acpi_subsys_resume_early(struct device *dev) { return 0; }
#endif

#if defined(CONFIG_ACPI) && defined(CONFIG_PM)
int acpi_dev_pm_attach(struct device *dev);
int acpi_dev_pm_detach(struct device *dev);
int acpi_dev_pm_attach(struct device *dev, bool power_on);
int acpi_dev_pm_detach(struct device *dev, bool power_off);
#else
static inline int acpi_dev_pm_attach(struct device *dev) { return -ENODEV; }
static inline void acpi_dev_pm_detach(struct device *dev) {}
static inline int acpi_dev_pm_attach(struct device *dev, bool power_on)
{
return -ENODEV;
}
static inline void acpi_dev_pm_detach(struct device *dev, bool power_off) {}
#endif

#endif /*_LINUX_ACPI_H*/

0 comments on commit 869b5ac

Please sign in to comment.