diff options
author | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2013-01-17 08:11:06 -0500 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2013-01-17 08:11:06 -0500 |
commit | 993cbe595dda731471a07f4f65575fadedc570dc (patch) | |
tree | 2fb3877c89bf031acdbae666fe4530d88eb5945f /drivers/acpi/scan.c | |
parent | 0b224527323669c66e0a37ae05b04034bfcdce14 (diff) |
ACPI / PM: Take order attribute of wakeup power resources into account
ACPI power resources have an order attribute that should be taken
into account when turning them on and off, but it is not used now.
Modify the power resources management code to preserve the
spec-compliant ordering of wakeup power resources.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/acpi/scan.c')
-rw-r--r-- | drivers/acpi/scan.c | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index d557868c0081..e4ac46a9c664 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c | |||
@@ -479,6 +479,9 @@ static void acpi_free_power_resources_lists(struct acpi_device *device) | |||
479 | { | 479 | { |
480 | int i; | 480 | int i; |
481 | 481 | ||
482 | if (device->wakeup.flags.valid) | ||
483 | acpi_power_resources_list_free(&device->wakeup.resources); | ||
484 | |||
482 | if (!device->flags.power_manageable) | 485 | if (!device->flags.power_manageable) |
483 | return; | 486 | return; |
484 | 487 | ||
@@ -902,6 +905,8 @@ acpi_bus_extract_wakeup_device_power_package(acpi_handle handle, | |||
902 | if (!wakeup) | 905 | if (!wakeup) |
903 | return AE_BAD_PARAMETER; | 906 | return AE_BAD_PARAMETER; |
904 | 907 | ||
908 | INIT_LIST_HEAD(&wakeup->resources); | ||
909 | |||
905 | /* _PRW */ | 910 | /* _PRW */ |
906 | status = acpi_evaluate_object(handle, "_PRW", NULL, &buffer); | 911 | status = acpi_evaluate_object(handle, "_PRW", NULL, &buffer); |
907 | if (ACPI_FAILURE(status)) { | 912 | if (ACPI_FAILURE(status)) { |
@@ -948,19 +953,17 @@ acpi_bus_extract_wakeup_device_power_package(acpi_handle handle, | |||
948 | } | 953 | } |
949 | wakeup->sleep_state = element->integer.value; | 954 | wakeup->sleep_state = element->integer.value; |
950 | 955 | ||
951 | if ((package->package.count - 2) > ACPI_MAX_HANDLES) { | 956 | for (i = 2; i < package->package.count; i++) { |
952 | status = AE_NO_MEMORY; | 957 | acpi_handle rhandle; |
953 | goto out; | 958 | |
954 | } | 959 | element = &(package->package.elements[i]); |
955 | wakeup->resources.count = package->package.count - 2; | ||
956 | for (i = 0; i < wakeup->resources.count; i++) { | ||
957 | element = &(package->package.elements[i + 2]); | ||
958 | if (element->type != ACPI_TYPE_LOCAL_REFERENCE) { | 960 | if (element->type != ACPI_TYPE_LOCAL_REFERENCE) { |
959 | status = AE_BAD_DATA; | 961 | status = AE_BAD_DATA; |
960 | goto out; | 962 | goto out; |
961 | } | 963 | } |
962 | 964 | rhandle = element->reference.handle; | |
963 | wakeup->resources.handles[i] = element->reference.handle; | 965 | acpi_add_power_resource(rhandle); |
966 | acpi_power_resources_list_add(rhandle, &wakeup->resources); | ||
964 | } | 967 | } |
965 | 968 | ||
966 | acpi_setup_gpe_for_wake(handle, wakeup->gpe_device, wakeup->gpe_number); | 969 | acpi_setup_gpe_for_wake(handle, wakeup->gpe_device, wakeup->gpe_number); |
@@ -1018,6 +1021,7 @@ static void acpi_bus_get_wakeup_device_flags(struct acpi_device *device) | |||
1018 | status = acpi_bus_extract_wakeup_device_power_package(device->handle, | 1021 | status = acpi_bus_extract_wakeup_device_power_package(device->handle, |
1019 | &device->wakeup); | 1022 | &device->wakeup); |
1020 | if (ACPI_FAILURE(status)) { | 1023 | if (ACPI_FAILURE(status)) { |
1024 | acpi_power_resources_list_free(&device->wakeup.resources); | ||
1021 | ACPI_EXCEPTION((AE_INFO, status, "Extracting _PRW package")); | 1025 | ACPI_EXCEPTION((AE_INFO, status, "Extracting _PRW package")); |
1022 | return; | 1026 | return; |
1023 | } | 1027 | } |
@@ -1491,9 +1495,11 @@ static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl_not_used, | |||
1491 | acpi_handle temp; | 1495 | acpi_handle temp; |
1492 | 1496 | ||
1493 | status = acpi_get_handle(handle, "_PRW", &temp); | 1497 | status = acpi_get_handle(handle, "_PRW", &temp); |
1494 | if (ACPI_SUCCESS(status)) | 1498 | if (ACPI_SUCCESS(status)) { |
1495 | acpi_bus_extract_wakeup_device_power_package(handle, | 1499 | acpi_bus_extract_wakeup_device_power_package(handle, |
1496 | &wakeup); | 1500 | &wakeup); |
1501 | acpi_power_resources_list_free(&wakeup.resources); | ||
1502 | } | ||
1497 | return AE_CTRL_DEPTH; | 1503 | return AE_CTRL_DEPTH; |
1498 | } | 1504 | } |
1499 | 1505 | ||