diff options
author | Bob Moore <robert.moore@intel.com> | 2009-07-23 22:56:43 -0400 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2009-08-28 19:40:38 -0400 |
commit | b2deadd53c3630786e73746fb0ad8450f4e015bf (patch) | |
tree | 0115fe383ce81739ddb40a7392a3c9298811bc02 /drivers/acpi/acpica/nspredef.c | |
parent | 3ce804ed83827a7fd27190836f9421b29ac64512 (diff) |
ACPICA: Move predefined repair code to new file, no functional change
New file is nsrepair.c. This is in preparation for additional
errror correcting code.
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Lin Ming <ming.m.lin@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi/acpica/nspredef.c')
-rw-r--r-- | drivers/acpi/acpica/nspredef.c | 120 |
1 files changed, 2 insertions, 118 deletions
diff --git a/drivers/acpi/acpica/nspredef.c b/drivers/acpi/acpica/nspredef.c index 1dc1a4737aa9..e3f08dcb5275 100644 --- a/drivers/acpi/acpica/nspredef.c +++ b/drivers/acpi/acpica/nspredef.c | |||
@@ -91,12 +91,6 @@ static acpi_status | |||
91 | acpi_ns_check_reference(struct acpi_predefined_data *data, | 91 | acpi_ns_check_reference(struct acpi_predefined_data *data, |
92 | union acpi_operand_object *return_object); | 92 | union acpi_operand_object *return_object); |
93 | 93 | ||
94 | static acpi_status | ||
95 | acpi_ns_repair_object(struct acpi_predefined_data *data, | ||
96 | u32 expected_btypes, | ||
97 | u32 package_index, | ||
98 | union acpi_operand_object **return_object_ptr); | ||
99 | |||
100 | static void acpi_ns_get_expected_types(char *buffer, u32 expected_btypes); | 94 | static void acpi_ns_get_expected_types(char *buffer, u32 expected_btypes); |
101 | 95 | ||
102 | /* | 96 | /* |
@@ -111,14 +105,6 @@ static const char *acpi_rtype_names[] = { | |||
111 | "/Reference", | 105 | "/Reference", |
112 | }; | 106 | }; |
113 | 107 | ||
114 | /* Object is not a package element */ | ||
115 | |||
116 | #define ACPI_NOT_PACKAGE_ELEMENT ACPI_UINT32_MAX | ||
117 | |||
118 | /* Always emit warning message, not dependent on node flags */ | ||
119 | |||
120 | #define ACPI_WARN_ALWAYS 0 | ||
121 | |||
122 | /******************************************************************************* | 108 | /******************************************************************************* |
123 | * | 109 | * |
124 | * FUNCTION: acpi_ns_check_predefined_names | 110 | * FUNCTION: acpi_ns_check_predefined_names |
@@ -580,8 +566,8 @@ acpi_ns_check_package(struct acpi_predefined_data *data, | |||
580 | case ACPI_PTYPE2_COUNT: | 566 | case ACPI_PTYPE2_COUNT: |
581 | 567 | ||
582 | /* | 568 | /* |
583 | * These types all return a single package that consists of a variable | 569 | * These types all return a single package that consists of a |
584 | * number of sub-packages | 570 | * variable number of sub-packages. |
585 | */ | 571 | */ |
586 | for (i = 0; i < count; i++) { | 572 | for (i = 0; i < count; i++) { |
587 | sub_package = *elements; | 573 | sub_package = *elements; |
@@ -979,108 +965,6 @@ acpi_ns_check_reference(struct acpi_predefined_data *data, | |||
979 | 965 | ||
980 | /******************************************************************************* | 966 | /******************************************************************************* |
981 | * | 967 | * |
982 | * FUNCTION: acpi_ns_repair_object | ||
983 | * | ||
984 | * PARAMETERS: Data - Pointer to validation data structure | ||
985 | * expected_btypes - Object types expected | ||
986 | * package_index - Index of object within parent package (if | ||
987 | * applicable - ACPI_NOT_PACKAGE_ELEMENT | ||
988 | * otherwise) | ||
989 | * return_object_ptr - Pointer to the object returned from the | ||
990 | * evaluation of a method or object | ||
991 | * | ||
992 | * RETURN: Status. AE_OK if repair was successful. | ||
993 | * | ||
994 | * DESCRIPTION: Attempt to repair/convert a return object of a type that was | ||
995 | * not expected. | ||
996 | * | ||
997 | ******************************************************************************/ | ||
998 | |||
999 | static acpi_status | ||
1000 | acpi_ns_repair_object(struct acpi_predefined_data *data, | ||
1001 | u32 expected_btypes, | ||
1002 | u32 package_index, | ||
1003 | union acpi_operand_object **return_object_ptr) | ||
1004 | { | ||
1005 | union acpi_operand_object *return_object = *return_object_ptr; | ||
1006 | union acpi_operand_object *new_object; | ||
1007 | acpi_size length; | ||
1008 | |||
1009 | switch (return_object->common.type) { | ||
1010 | case ACPI_TYPE_BUFFER: | ||
1011 | |||
1012 | /* Does the method/object legally return a string? */ | ||
1013 | |||
1014 | if (!(expected_btypes & ACPI_RTYPE_STRING)) { | ||
1015 | return (AE_AML_OPERAND_TYPE); | ||
1016 | } | ||
1017 | |||
1018 | /* | ||
1019 | * Have a Buffer, expected a String, convert. Use a to_string | ||
1020 | * conversion, no transform performed on the buffer data. The best | ||
1021 | * example of this is the _BIF method, where the string data from | ||
1022 | * the battery is often (incorrectly) returned as buffer object(s). | ||
1023 | */ | ||
1024 | length = 0; | ||
1025 | while ((length < return_object->buffer.length) && | ||
1026 | (return_object->buffer.pointer[length])) { | ||
1027 | length++; | ||
1028 | } | ||
1029 | |||
1030 | /* Allocate a new string object */ | ||
1031 | |||
1032 | new_object = acpi_ut_create_string_object(length); | ||
1033 | if (!new_object) { | ||
1034 | return (AE_NO_MEMORY); | ||
1035 | } | ||
1036 | |||
1037 | /* | ||
1038 | * Copy the raw buffer data with no transform. String is already NULL | ||
1039 | * terminated at Length+1. | ||
1040 | */ | ||
1041 | ACPI_MEMCPY(new_object->string.pointer, | ||
1042 | return_object->buffer.pointer, length); | ||
1043 | |||
1044 | /* | ||
1045 | * If the original object is a package element, we need to: | ||
1046 | * 1. Set the reference count of the new object to match the | ||
1047 | * reference count of the old object. | ||
1048 | * 2. Decrement the reference count of the original object. | ||
1049 | */ | ||
1050 | if (package_index != ACPI_NOT_PACKAGE_ELEMENT) { | ||
1051 | new_object->common.reference_count = | ||
1052 | return_object->common.reference_count; | ||
1053 | |||
1054 | if (return_object->common.reference_count > 1) { | ||
1055 | return_object->common.reference_count--; | ||
1056 | } | ||
1057 | |||
1058 | ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, | ||
1059 | data->node_flags, | ||
1060 | "Converted Buffer to expected String at index %u", | ||
1061 | package_index)); | ||
1062 | } else { | ||
1063 | ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, | ||
1064 | data->node_flags, | ||
1065 | "Converted Buffer to expected String")); | ||
1066 | } | ||
1067 | |||
1068 | /* Delete old object, install the new return object */ | ||
1069 | |||
1070 | acpi_ut_remove_reference(return_object); | ||
1071 | *return_object_ptr = new_object; | ||
1072 | data->flags |= ACPI_OBJECT_REPAIRED; | ||
1073 | return (AE_OK); | ||
1074 | |||
1075 | default: | ||
1076 | break; | ||
1077 | } | ||
1078 | |||
1079 | return (AE_AML_OPERAND_TYPE); | ||
1080 | } | ||
1081 | |||
1082 | /******************************************************************************* | ||
1083 | * | ||
1084 | * FUNCTION: acpi_ns_get_expected_types | 968 | * FUNCTION: acpi_ns_get_expected_types |
1085 | * | 969 | * |
1086 | * PARAMETERS: Buffer - Pointer to where the string is returned | 970 | * PARAMETERS: Buffer - Pointer to where the string is returned |