Merge branches 'acpi-battery', 'acpi-video' and 'acpi-misc'
[sfrench/cifs-2.6.git] / drivers / acpi / acpica / exconfig.c
index 6c2685a6a4c1cc89333df447c9c568dc454de936..d7d74ef87b186164b1e45e9a19279df192f743d3 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Module Name: exconfig - Namespace reconfiguration (Load/Unload opcodes)
  *
- * Copyright (C) 2000 - 2021, Intel Corp.
+ * Copyright (C) 2000 - 2022, Intel Corp.
  *
  *****************************************************************************/
 
@@ -87,11 +87,21 @@ acpi_ex_load_table_op(struct acpi_walk_state *walk_state,
        struct acpi_namespace_node *parent_node;
        struct acpi_namespace_node *start_node;
        struct acpi_namespace_node *parameter_node = NULL;
+       union acpi_operand_object *return_obj;
        union acpi_operand_object *ddb_handle;
        u32 table_index;
 
        ACPI_FUNCTION_TRACE(ex_load_table_op);
 
+       /* Create the return object */
+
+       return_obj = acpi_ut_create_integer_object((u64)0);
+       if (!return_obj) {
+               return_ACPI_STATUS(AE_NO_MEMORY);
+       }
+
+       *return_desc = return_obj;
+
        /* Find the ACPI table in the RSDT/XSDT */
 
        acpi_ex_exit_interpreter();
@@ -106,12 +116,6 @@ acpi_ex_load_table_op(struct acpi_walk_state *walk_state,
 
                /* Table not found, return an Integer=0 and AE_OK */
 
-               ddb_handle = acpi_ut_create_integer_object((u64) 0);
-               if (!ddb_handle) {
-                       return_ACPI_STATUS(AE_NO_MEMORY);
-               }
-
-               *return_desc = ddb_handle;
                return_ACPI_STATUS(AE_OK);
        }
 
@@ -198,7 +202,13 @@ acpi_ex_load_table_op(struct acpi_walk_state *walk_state,
                }
        }
 
-       *return_desc = ddb_handle;
+       /* Remove the reference to ddb_handle created by acpi_ex_add_table above */
+
+       acpi_ut_remove_reference(ddb_handle);
+
+       /* Return -1 (non-zero) indicates success */
+
+       return_obj->integer.value = 0xFFFFFFFFFFFFFFFF;
        return_ACPI_STATUS(status);
 }
 
@@ -249,7 +259,7 @@ acpi_ex_region_read(union acpi_operand_object *obj_desc, u32 length, u8 *buffer)
  *
  * PARAMETERS:  obj_desc        - Region or Buffer/Field where the table will be
  *                                obtained
- *              target          - Where a handle to the table will be stored
+ *              target          - Where the status of the load will be stored
  *              walk_state      - Current state
  *
  * RETURN:      Status
@@ -278,6 +288,20 @@ acpi_ex_load_op(union acpi_operand_object *obj_desc,
 
        ACPI_FUNCTION_TRACE(ex_load_op);
 
+       if (target->common.descriptor_type == ACPI_DESC_TYPE_NAMED) {
+               target =
+                   acpi_ns_get_attached_object(ACPI_CAST_PTR
+                                               (struct acpi_namespace_node,
+                                                target));
+       }
+       if (target->common.type != ACPI_TYPE_INTEGER) {
+               ACPI_EXCEPTION((AE_INFO, AE_TYPE,
+                               "Type not integer: %X\n", target->common.type));
+               return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
+       }
+
+       target->integer.value = 0;
+
        /* Source Object can be either an op_region or a Buffer/Field */
 
        switch (obj_desc->common.type) {
@@ -430,9 +454,6 @@ acpi_ex_load_op(union acpi_operand_object *obj_desc,
         */
        status = acpi_ex_add_table(table_index, &ddb_handle);
        if (ACPI_FAILURE(status)) {
-
-               /* On error, table_ptr was deallocated above */
-
                return_ACPI_STATUS(status);
        }
 
@@ -442,21 +463,13 @@ acpi_ex_load_op(union acpi_operand_object *obj_desc,
        acpi_ns_initialize_objects();
        acpi_ex_enter_interpreter();
 
-       /* Store the ddb_handle into the Target operand */
+       /* Remove the reference to ddb_handle created by acpi_ex_add_table above */
 
-       status = acpi_ex_store(ddb_handle, target, walk_state);
-       if (ACPI_FAILURE(status)) {
-               (void)acpi_ex_unload_table(ddb_handle);
-
-               /* table_ptr was deallocated above */
-
-               acpi_ut_remove_reference(ddb_handle);
-               return_ACPI_STATUS(status);
-       }
+       acpi_ut_remove_reference(ddb_handle);
 
-       /* Remove the reference by added by acpi_ex_store above */
+       /* Return -1 (non-zero) indicates success */
 
-       acpi_ut_remove_reference(ddb_handle);
+       target->integer.value = 0xFFFFFFFFFFFFFFFF;
        return_ACPI_STATUS(status);
 }