diff options
author | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2014-07-22 19:01:41 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2014-07-22 19:01:41 -0400 |
commit | 17653a3e098dc20ae1db7459344a81c386625696 (patch) | |
tree | 63c7cd4e92102ac257a9274705c672725c10b3fc /drivers/acpi | |
parent | f35cec255557d1037ff0d772edfd6e7b1e92cdc0 (diff) |
ACPI / PM: Use ACPI_COMPANION() instead of ACPI_HANDLE()
The ACPI_HANDLE() macro evaluates ACPI_COMPANION() internally to
return the handle of the device's ACPI companion, so it is much
more straightforward and efficient to use ACPI_COMPANION()
directly to obtain the device's ACPI companion object instead of
using ACPI_HANDLE() and acpi_bus_get_device() on the returned
handle for the same thing.
Do that in three places in the ACPI device PM code.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/acpi')
-rw-r--r-- | drivers/acpi/device_pm.c | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c index ad2810900799..67075f800e34 100644 --- a/drivers/acpi/device_pm.c +++ b/drivers/acpi/device_pm.c | |||
@@ -596,7 +596,6 @@ static int acpi_dev_pm_get_state(struct device *dev, struct acpi_device *adev, | |||
596 | */ | 596 | */ |
597 | int acpi_pm_device_sleep_state(struct device *dev, int *d_min_p, int d_max_in) | 597 | int acpi_pm_device_sleep_state(struct device *dev, int *d_min_p, int d_max_in) |
598 | { | 598 | { |
599 | acpi_handle handle = ACPI_HANDLE(dev); | ||
600 | struct acpi_device *adev; | 599 | struct acpi_device *adev; |
601 | int ret, d_min, d_max; | 600 | int ret, d_min, d_max; |
602 | 601 | ||
@@ -611,8 +610,9 @@ int acpi_pm_device_sleep_state(struct device *dev, int *d_min_p, int d_max_in) | |||
611 | d_max_in = ACPI_STATE_D3_HOT; | 610 | d_max_in = ACPI_STATE_D3_HOT; |
612 | } | 611 | } |
613 | 612 | ||
614 | if (!handle || acpi_bus_get_device(handle, &adev)) { | 613 | adev = ACPI_COMPANION(dev); |
615 | dev_dbg(dev, "ACPI handle without context in %s!\n", __func__); | 614 | if (!adev) { |
615 | dev_dbg(dev, "ACPI companion missing in %s!\n", __func__); | ||
616 | return -ENODEV; | 616 | return -ENODEV; |
617 | } | 617 | } |
618 | 618 | ||
@@ -700,15 +700,13 @@ static int acpi_device_wakeup(struct acpi_device *adev, u32 target_state, | |||
700 | int acpi_pm_device_run_wake(struct device *phys_dev, bool enable) | 700 | int acpi_pm_device_run_wake(struct device *phys_dev, bool enable) |
701 | { | 701 | { |
702 | struct acpi_device *adev; | 702 | struct acpi_device *adev; |
703 | acpi_handle handle; | ||
704 | 703 | ||
705 | if (!device_run_wake(phys_dev)) | 704 | if (!device_run_wake(phys_dev)) |
706 | return -EINVAL; | 705 | return -EINVAL; |
707 | 706 | ||
708 | handle = ACPI_HANDLE(phys_dev); | 707 | adev = ACPI_COMPANION(phys_dev); |
709 | if (!handle || acpi_bus_get_device(handle, &adev)) { | 708 | if (!adev) { |
710 | dev_dbg(phys_dev, "ACPI handle without context in %s!\n", | 709 | dev_dbg(phys_dev, "ACPI companion missing in %s!\n", __func__); |
711 | __func__); | ||
712 | return -ENODEV; | 710 | return -ENODEV; |
713 | } | 711 | } |
714 | 712 | ||
@@ -725,16 +723,15 @@ EXPORT_SYMBOL(acpi_pm_device_run_wake); | |||
725 | */ | 723 | */ |
726 | int acpi_pm_device_sleep_wake(struct device *dev, bool enable) | 724 | int acpi_pm_device_sleep_wake(struct device *dev, bool enable) |
727 | { | 725 | { |
728 | acpi_handle handle; | ||
729 | struct acpi_device *adev; | 726 | struct acpi_device *adev; |
730 | int error; | 727 | int error; |
731 | 728 | ||
732 | if (!device_can_wakeup(dev)) | 729 | if (!device_can_wakeup(dev)) |
733 | return -EINVAL; | 730 | return -EINVAL; |
734 | 731 | ||
735 | handle = ACPI_HANDLE(dev); | 732 | adev = ACPI_COMPANION(dev); |
736 | if (!handle || acpi_bus_get_device(handle, &adev)) { | 733 | if (!adev) { |
737 | dev_dbg(dev, "ACPI handle without context in %s!\n", __func__); | 734 | dev_dbg(dev, "ACPI companion missing in %s!\n", __func__); |
738 | return -ENODEV; | 735 | return -ENODEV; |
739 | } | 736 | } |
740 | 737 | ||