mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-06 10:57:46 +00:00
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>
This commit is contained in:
parent
f35cec2555
commit
17653a3e09
1 changed files with 9 additions and 12 deletions
|
@ -596,7 +596,6 @@ static int acpi_dev_pm_get_state(struct device *dev, struct acpi_device *adev,
|
||||||
*/
|
*/
|
||||||
int acpi_pm_device_sleep_state(struct device *dev, int *d_min_p, int d_max_in)
|
int acpi_pm_device_sleep_state(struct device *dev, int *d_min_p, int d_max_in)
|
||||||
{
|
{
|
||||||
acpi_handle handle = ACPI_HANDLE(dev);
|
|
||||||
struct acpi_device *adev;
|
struct acpi_device *adev;
|
||||||
int ret, d_min, d_max;
|
int ret, d_min, d_max;
|
||||||
|
|
||||||
|
@ -611,8 +610,9 @@ int acpi_pm_device_sleep_state(struct device *dev, int *d_min_p, int d_max_in)
|
||||||
d_max_in = ACPI_STATE_D3_HOT;
|
d_max_in = ACPI_STATE_D3_HOT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!handle || acpi_bus_get_device(handle, &adev)) {
|
adev = ACPI_COMPANION(dev);
|
||||||
dev_dbg(dev, "ACPI handle without context in %s!\n", __func__);
|
if (!adev) {
|
||||||
|
dev_dbg(dev, "ACPI companion missing in %s!\n", __func__);
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -700,15 +700,13 @@ static int acpi_device_wakeup(struct acpi_device *adev, u32 target_state,
|
||||||
int acpi_pm_device_run_wake(struct device *phys_dev, bool enable)
|
int acpi_pm_device_run_wake(struct device *phys_dev, bool enable)
|
||||||
{
|
{
|
||||||
struct acpi_device *adev;
|
struct acpi_device *adev;
|
||||||
acpi_handle handle;
|
|
||||||
|
|
||||||
if (!device_run_wake(phys_dev))
|
if (!device_run_wake(phys_dev))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
handle = ACPI_HANDLE(phys_dev);
|
adev = ACPI_COMPANION(phys_dev);
|
||||||
if (!handle || acpi_bus_get_device(handle, &adev)) {
|
if (!adev) {
|
||||||
dev_dbg(phys_dev, "ACPI handle without context in %s!\n",
|
dev_dbg(phys_dev, "ACPI companion missing in %s!\n", __func__);
|
||||||
__func__);
|
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -725,16 +723,15 @@ EXPORT_SYMBOL(acpi_pm_device_run_wake);
|
||||||
*/
|
*/
|
||||||
int acpi_pm_device_sleep_wake(struct device *dev, bool enable)
|
int acpi_pm_device_sleep_wake(struct device *dev, bool enable)
|
||||||
{
|
{
|
||||||
acpi_handle handle;
|
|
||||||
struct acpi_device *adev;
|
struct acpi_device *adev;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
if (!device_can_wakeup(dev))
|
if (!device_can_wakeup(dev))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
handle = ACPI_HANDLE(dev);
|
adev = ACPI_COMPANION(dev);
|
||||||
if (!handle || acpi_bus_get_device(handle, &adev)) {
|
if (!adev) {
|
||||||
dev_dbg(dev, "ACPI handle without context in %s!\n", __func__);
|
dev_dbg(dev, "ACPI companion missing in %s!\n", __func__);
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue