aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/acpica/nspredef.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/acpica/nspredef.c')
-rw-r--r--drivers/acpi/acpica/nspredef.c53
1 files changed, 36 insertions, 17 deletions
diff --git a/drivers/acpi/acpica/nspredef.c b/drivers/acpi/acpica/nspredef.c
index d34fa59548f7..7096bcda0c72 100644
--- a/drivers/acpi/acpica/nspredef.c
+++ b/drivers/acpi/acpica/nspredef.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2010, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -231,6 +231,7 @@ acpi_ns_check_predefined_names(struct acpi_namespace_node *node,
231 * Note: Package may have been newly created by call above. 231 * Note: Package may have been newly created by call above.
232 */ 232 */
233 if ((*return_object_ptr)->common.type == ACPI_TYPE_PACKAGE) { 233 if ((*return_object_ptr)->common.type == ACPI_TYPE_PACKAGE) {
234 data->parent_package = *return_object_ptr;
234 status = acpi_ns_check_package(data, return_object_ptr); 235 status = acpi_ns_check_package(data, return_object_ptr);
235 if (ACPI_FAILURE(status)) { 236 if (ACPI_FAILURE(status)) {
236 goto exit; 237 goto exit;
@@ -710,6 +711,7 @@ acpi_ns_check_package_list(struct acpi_predefined_data *data,
710 for (i = 0; i < count; i++) { 711 for (i = 0; i < count; i++) {
711 sub_package = *elements; 712 sub_package = *elements;
712 sub_elements = sub_package->package.elements; 713 sub_elements = sub_package->package.elements;
714 data->parent_package = sub_package;
713 715
714 /* Each sub-object must be of type Package */ 716 /* Each sub-object must be of type Package */
715 717
@@ -721,6 +723,7 @@ acpi_ns_check_package_list(struct acpi_predefined_data *data,
721 723
722 /* Examine the different types of expected sub-packages */ 724 /* Examine the different types of expected sub-packages */
723 725
726 data->parent_package = sub_package;
724 switch (package->ret_info.type) { 727 switch (package->ret_info.type) {
725 case ACPI_PTYPE2: 728 case ACPI_PTYPE2:
726 case ACPI_PTYPE2_PKG_COUNT: 729 case ACPI_PTYPE2_PKG_COUNT:
@@ -800,7 +803,7 @@ acpi_ns_check_package_list(struct acpi_predefined_data *data,
800 803
801 /* 804 /*
802 * First element is the (Integer) count of elements, including 805 * First element is the (Integer) count of elements, including
803 * the count field. 806 * the count field (the ACPI name is num_elements)
804 */ 807 */
805 status = acpi_ns_check_object_type(data, sub_elements, 808 status = acpi_ns_check_object_type(data, sub_elements,
806 ACPI_RTYPE_INTEGER, 809 ACPI_RTYPE_INTEGER,
@@ -822,6 +825,16 @@ acpi_ns_check_package_list(struct acpi_predefined_data *data,
822 expected_count = package->ret_info.count1; 825 expected_count = package->ret_info.count1;
823 goto package_too_small; 826 goto package_too_small;
824 } 827 }
828 if (expected_count == 0) {
829 /*
830 * Either the num_entries element was originally zero or it was
831 * a NULL element and repaired to an Integer of value zero.
832 * In either case, repair it by setting num_entries to be the
833 * actual size of the subpackage.
834 */
835 expected_count = sub_package->package.count;
836 (*sub_elements)->integer.value = expected_count;
837 }
825 838
826 /* Check the type of each sub-package element */ 839 /* Check the type of each sub-package element */
827 840
@@ -945,10 +958,18 @@ acpi_ns_check_object_type(struct acpi_predefined_data *data,
945 char type_buffer[48]; /* Room for 5 types */ 958 char type_buffer[48]; /* Room for 5 types */
946 959
947 /* 960 /*
948 * If we get a NULL return_object here, it is a NULL package element, 961 * If we get a NULL return_object here, it is a NULL package element.
949 * and this is always an error. 962 * Since all extraneous NULL package elements were removed earlier by a
963 * call to acpi_ns_remove_null_elements, this is an unexpected NULL element.
964 * We will attempt to repair it.
950 */ 965 */
951 if (!return_object) { 966 if (!return_object) {
967 status = acpi_ns_repair_null_element(data, expected_btypes,
968 package_index,
969 return_object_ptr);
970 if (ACPI_SUCCESS(status)) {
971 return (AE_OK); /* Repair was successful */
972 }
952 goto type_error_exit; 973 goto type_error_exit;
953 } 974 }
954 975
@@ -1000,27 +1021,25 @@ acpi_ns_check_object_type(struct acpi_predefined_data *data,
1000 1021
1001 /* Is the object one of the expected types? */ 1022 /* Is the object one of the expected types? */
1002 1023
1003 if (!(return_btype & expected_btypes)) { 1024 if (return_btype & expected_btypes) {
1004 1025
1005 /* Type mismatch -- attempt repair of the returned object */ 1026 /* For reference objects, check that the reference type is correct */
1006 1027
1007 status = acpi_ns_repair_object(data, expected_btypes, 1028 if (return_object->common.type == ACPI_TYPE_LOCAL_REFERENCE) {
1008 package_index, 1029 status = acpi_ns_check_reference(data, return_object);
1009 return_object_ptr);
1010 if (ACPI_SUCCESS(status)) {
1011 return (AE_OK); /* Repair was successful */
1012 } 1030 }
1013 goto type_error_exit; 1031
1032 return (status);
1014 } 1033 }
1015 1034
1016 /* For reference objects, check that the reference type is correct */ 1035 /* Type mismatch -- attempt repair of the returned object */
1017 1036
1018 if (return_object->common.type == ACPI_TYPE_LOCAL_REFERENCE) { 1037 status = acpi_ns_repair_object(data, expected_btypes,
1019 status = acpi_ns_check_reference(data, return_object); 1038 package_index, return_object_ptr);
1039 if (ACPI_SUCCESS(status)) {
1040 return (AE_OK); /* Repair was successful */
1020 } 1041 }
1021 1042
1022 return (status);
1023
1024 type_error_exit: 1043 type_error_exit:
1025 1044
1026 /* Create a string with all expected types for this predefined object */ 1045 /* Create a string with all expected types for this predefined object */