ACPICA: Move Package-to-Buffer repair code into common ToBuffer function

Move code specific to _FDE and _GTM into the generic repair 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>
diff --git a/drivers/acpi/acpica/nspredef.c b/drivers/acpi/acpica/nspredef.c
index 1782c3d..c6297f5 100644
--- a/drivers/acpi/acpica/nspredef.c
+++ b/drivers/acpi/acpica/nspredef.c
@@ -215,6 +215,8 @@
 	data->node_flags = node->flags;
 	data->pathname = pathname;
 
+	/* TBD: For variable-length Packages, remove NULL elements here */
+
 	/*
 	 * Check that the type of the return object is what is expected for
 	 * this predefined name
@@ -223,10 +225,11 @@
 					   predefined->info.expected_btypes,
 					   ACPI_NOT_PACKAGE_ELEMENT);
 	if (ACPI_SUCCESS(status)) {
-
-		/* For returned Package objects, check the type of all sub-objects */
-
-		if (return_object->common.type == ACPI_TYPE_PACKAGE) {
+		/*
+		 * For returned Package objects, check the type of all sub-objects.
+		 * Note: Package may have been created by call above.
+		 */
+		if ((*return_object_ptr)->common.type == ACPI_TYPE_PACKAGE) {
 			status = acpi_ns_check_package(data, return_object_ptr);
 		}
 	}