diff options
author | Lin Ming <ming.m.lin@intel.com> | 2012-03-27 03:43:25 -0400 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2012-03-30 02:21:18 -0400 |
commit | b24e5098853653554baf6ec975b9e855f3d6e5c0 (patch) | |
tree | be93ad39b826c64907bb48dceea034db5b91fc24 | |
parent | 0090def6c37c8ea29508a435e581f2ef26fea10f (diff) |
ACPI, PCI: Move acpi_dev_run_wake() to ACPI core
acpi_dev_run_wake() is a generic function which can be used by
other subsystem too. Rename it to acpi_pm_device_run_wake, to be
consistent with acpi_pm_device_sleep_wake.
Then move it to ACPI core.
Acked-by: Rafael J. Wysocki <rjw@sisk.pl>
Signed-off-by: Lin Ming <ming.m.lin@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
-rw-r--r-- | drivers/acpi/sleep.c | 35 | ||||
-rw-r--r-- | drivers/pci/pci-acpi.c | 40 | ||||
-rw-r--r-- | include/acpi/acpi_bus.h | 5 |
3 files changed, 43 insertions, 37 deletions
diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c index ca191ff97844..00fa664d5fd8 100644 --- a/drivers/acpi/sleep.c +++ b/drivers/acpi/sleep.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/suspend.h> | 17 | #include <linux/suspend.h> |
18 | #include <linux/reboot.h> | 18 | #include <linux/reboot.h> |
19 | #include <linux/acpi.h> | 19 | #include <linux/acpi.h> |
20 | #include <linux/pm_runtime.h> | ||
20 | 21 | ||
21 | #include <asm/io.h> | 22 | #include <asm/io.h> |
22 | 23 | ||
@@ -730,6 +731,40 @@ int acpi_pm_device_sleep_state(struct device *dev, int *d_min_p) | |||
730 | 731 | ||
731 | #ifdef CONFIG_PM_SLEEP | 732 | #ifdef CONFIG_PM_SLEEP |
732 | /** | 733 | /** |
734 | * acpi_pm_device_run_wake - Enable/disable wake-up for given device. | ||
735 | * @phys_dev: Device to enable/disable the platform to wake-up the system for. | ||
736 | * @enable: Whether enable or disable the wake-up functionality. | ||
737 | * | ||
738 | * Find the ACPI device object corresponding to @pci_dev and try to | ||
739 | * enable/disable the GPE associated with it. | ||
740 | */ | ||
741 | int acpi_pm_device_run_wake(struct device *phys_dev, bool enable) | ||
742 | { | ||
743 | struct acpi_device *dev; | ||
744 | acpi_handle handle; | ||
745 | |||
746 | if (!device_run_wake(phys_dev)) | ||
747 | return -EINVAL; | ||
748 | |||
749 | handle = DEVICE_ACPI_HANDLE(phys_dev); | ||
750 | if (!handle || ACPI_FAILURE(acpi_bus_get_device(handle, &dev))) { | ||
751 | dev_dbg(phys_dev, "ACPI handle has no context in %s!\n", | ||
752 | __func__); | ||
753 | return -ENODEV; | ||
754 | } | ||
755 | |||
756 | if (enable) { | ||
757 | acpi_enable_wakeup_device_power(dev, ACPI_STATE_S0); | ||
758 | acpi_enable_gpe(dev->wakeup.gpe_device, dev->wakeup.gpe_number); | ||
759 | } else { | ||
760 | acpi_disable_gpe(dev->wakeup.gpe_device, dev->wakeup.gpe_number); | ||
761 | acpi_disable_wakeup_device_power(dev); | ||
762 | } | ||
763 | |||
764 | return 0; | ||
765 | } | ||
766 | |||
767 | /** | ||
733 | * acpi_pm_device_sleep_wake - enable or disable the system wake-up | 768 | * acpi_pm_device_sleep_wake - enable or disable the system wake-up |
734 | * capability of given device | 769 | * capability of given device |
735 | * @dev: device to handle | 770 | * @dev: device to handle |
diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c index 060fd22a1103..0f150f271c2a 100644 --- a/drivers/pci/pci-acpi.c +++ b/drivers/pci/pci-acpi.c | |||
@@ -277,40 +277,6 @@ static int acpi_pci_sleep_wake(struct pci_dev *dev, bool enable) | |||
277 | return 0; | 277 | return 0; |
278 | } | 278 | } |
279 | 279 | ||
280 | /** | ||
281 | * acpi_dev_run_wake - Enable/disable wake-up for given device. | ||
282 | * @phys_dev: Device to enable/disable the platform to wake-up the system for. | ||
283 | * @enable: Whether enable or disable the wake-up functionality. | ||
284 | * | ||
285 | * Find the ACPI device object corresponding to @pci_dev and try to | ||
286 | * enable/disable the GPE associated with it. | ||
287 | */ | ||
288 | static int acpi_dev_run_wake(struct device *phys_dev, bool enable) | ||
289 | { | ||
290 | struct acpi_device *dev; | ||
291 | acpi_handle handle; | ||
292 | |||
293 | if (!device_run_wake(phys_dev)) | ||
294 | return -EINVAL; | ||
295 | |||
296 | handle = DEVICE_ACPI_HANDLE(phys_dev); | ||
297 | if (!handle || ACPI_FAILURE(acpi_bus_get_device(handle, &dev))) { | ||
298 | dev_dbg(phys_dev, "ACPI handle has no context in %s!\n", | ||
299 | __func__); | ||
300 | return -ENODEV; | ||
301 | } | ||
302 | |||
303 | if (enable) { | ||
304 | acpi_enable_wakeup_device_power(dev, ACPI_STATE_S0); | ||
305 | acpi_enable_gpe(dev->wakeup.gpe_device, dev->wakeup.gpe_number); | ||
306 | } else { | ||
307 | acpi_disable_gpe(dev->wakeup.gpe_device, dev->wakeup.gpe_number); | ||
308 | acpi_disable_wakeup_device_power(dev); | ||
309 | } | ||
310 | |||
311 | return 0; | ||
312 | } | ||
313 | |||
314 | static void acpi_pci_propagate_run_wake(struct pci_bus *bus, bool enable) | 280 | static void acpi_pci_propagate_run_wake(struct pci_bus *bus, bool enable) |
315 | { | 281 | { |
316 | while (bus->parent) { | 282 | while (bus->parent) { |
@@ -318,14 +284,14 @@ static void acpi_pci_propagate_run_wake(struct pci_bus *bus, bool enable) | |||
318 | 284 | ||
319 | if (bridge->pme_interrupt) | 285 | if (bridge->pme_interrupt) |
320 | return; | 286 | return; |
321 | if (!acpi_dev_run_wake(&bridge->dev, enable)) | 287 | if (!acpi_pm_device_run_wake(&bridge->dev, enable)) |
322 | return; | 288 | return; |
323 | bus = bus->parent; | 289 | bus = bus->parent; |
324 | } | 290 | } |
325 | 291 | ||
326 | /* We have reached the root bus. */ | 292 | /* We have reached the root bus. */ |
327 | if (bus->bridge) | 293 | if (bus->bridge) |
328 | acpi_dev_run_wake(bus->bridge, enable); | 294 | acpi_pm_device_run_wake(bus->bridge, enable); |
329 | } | 295 | } |
330 | 296 | ||
331 | static int acpi_pci_run_wake(struct pci_dev *dev, bool enable) | 297 | static int acpi_pci_run_wake(struct pci_dev *dev, bool enable) |
@@ -333,7 +299,7 @@ static int acpi_pci_run_wake(struct pci_dev *dev, bool enable) | |||
333 | if (dev->pme_interrupt) | 299 | if (dev->pme_interrupt) |
334 | return 0; | 300 | return 0; |
335 | 301 | ||
336 | if (!acpi_dev_run_wake(&dev->dev, enable)) | 302 | if (!acpi_pm_device_run_wake(&dev->dev, enable)) |
337 | return 0; | 303 | return 0; |
338 | 304 | ||
339 | acpi_pci_propagate_run_wake(dev->bus, enable); | 305 | acpi_pci_propagate_run_wake(dev->bus, enable); |
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h index e168fffe1db5..f1c8ca60e824 100644 --- a/include/acpi/acpi_bus.h +++ b/include/acpi/acpi_bus.h | |||
@@ -394,8 +394,13 @@ static inline int acpi_pm_device_sleep_state(struct device *d, int *p) | |||
394 | #endif | 394 | #endif |
395 | 395 | ||
396 | #ifdef CONFIG_PM_SLEEP | 396 | #ifdef CONFIG_PM_SLEEP |
397 | int acpi_pm_device_run_wake(struct device *, bool); | ||
397 | int acpi_pm_device_sleep_wake(struct device *, bool); | 398 | int acpi_pm_device_sleep_wake(struct device *, bool); |
398 | #else | 399 | #else |
400 | static inline int acpi_pm_device_run_wake(struct device *dev, bool enable) | ||
401 | { | ||
402 | return -ENODEV; | ||
403 | } | ||
399 | static inline int acpi_pm_device_sleep_wake(struct device *dev, bool enable) | 404 | static inline int acpi_pm_device_sleep_wake(struct device *dev, bool enable) |
400 | { | 405 | { |
401 | return -ENODEV; | 406 | return -ENODEV; |