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.c59
1 files changed, 14 insertions, 45 deletions
diff --git a/drivers/acpi/acpica/nspredef.c b/drivers/acpi/acpica/nspredef.c
index 239fa2f731ca..d34fa59548f7 100644
--- a/drivers/acpi/acpica/nspredef.c
+++ b/drivers/acpi/acpica/nspredef.c
@@ -231,9 +231,6 @@ 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
235 /* TBD: For variable-length Packages, remove NULL elements here */
236
237 status = acpi_ns_check_package(data, return_object_ptr); 234 status = acpi_ns_check_package(data, return_object_ptr);
238 if (ACPI_FAILURE(status)) { 235 if (ACPI_FAILURE(status)) {
239 goto exit; 236 goto exit;
@@ -439,6 +436,13 @@ acpi_ns_check_package(struct acpi_predefined_data *data,
439 data->pathname, package->ret_info.type, 436 data->pathname, package->ret_info.type,
440 return_object->package.count)); 437 return_object->package.count));
441 438
439 /*
440 * For variable-length Packages, we can safely remove all embedded
441 * and trailing NULL package elements
442 */
443 acpi_ns_remove_null_elements(data, package->ret_info.type,
444 return_object);
445
442 /* Extract package count and elements array */ 446 /* Extract package count and elements array */
443 447
444 elements = return_object->package.elements; 448 elements = return_object->package.elements;
@@ -692,53 +696,18 @@ acpi_ns_check_package_list(struct acpi_predefined_data *data,
692 union acpi_operand_object *sub_package; 696 union acpi_operand_object *sub_package;
693 union acpi_operand_object **sub_elements; 697 union acpi_operand_object **sub_elements;
694 acpi_status status; 698 acpi_status status;
695 u8 non_trailing_null = FALSE;
696 u32 expected_count; 699 u32 expected_count;
697 u32 i; 700 u32 i;
698 u32 j; 701 u32 j;
699 702
700 /* Validate each sub-Package in the parent Package */ 703 /*
701 704 * Validate each sub-Package in the parent Package
705 *
706 * NOTE: assumes list of sub-packages contains no NULL elements.
707 * Any NULL elements should have been removed by earlier call
708 * to acpi_ns_remove_null_elements.
709 */
702 for (i = 0; i < count; i++) { 710 for (i = 0; i < count; i++) {
703 /*
704 * Handling for NULL package elements. For now, we will simply allow
705 * a parent package with trailing NULL elements. This can happen if
706 * the package was defined to be longer than the initializer list.
707 * This is legal as per the ACPI specification. It is often used
708 * to allow for dynamic initialization of a Package.
709 *
710 * A future enhancement may be to simply truncate the package to
711 * remove the trailing NULL elements.
712 */
713 if (!(*elements)) {
714 if (!non_trailing_null) {
715
716 /* Ensure the remaining elements are all NULL */
717
718 for (j = 1; j < (count - i + 1); j++) {
719 if (elements[j]) {
720 non_trailing_null = TRUE;
721 }
722 }
723
724 if (!non_trailing_null) {
725
726 /* Ignore the trailing NULL elements */
727
728 return (AE_OK);
729 }
730 }
731
732 /* There are trailing non-null elements, issue warning */
733
734 ACPI_WARN_PREDEFINED((AE_INFO, data->pathname,
735 data->node_flags,
736 "Found NULL element at package index %u",
737 i));
738 elements++;
739 continue;
740 }
741
742 sub_package = *elements; 711 sub_package = *elements;
743 sub_elements = sub_package->package.elements; 712 sub_elements = sub_package->package.elements;
744 713