diff --git a/drivers/acpi/acpica/excreate.c b/drivers/acpi/acpica/excreate.c index 68675868e20f..b8adb11f1b07 100644 --- a/drivers/acpi/acpica/excreate.c +++ b/drivers/acpi/acpica/excreate.c @@ -88,36 +88,26 @@ acpi_status acpi_ex_create_alias(struct acpi_walk_state *walk_state) } /* Ensure that the target node is valid */ + if (!target_node) { return_ACPI_STATUS(AE_NULL_OBJECT); } - /* - * For objects that can never change (i.e., the NS node will - * permanently point to the same object), we can simply attach - * the object to the new NS node. For other objects (such as - * Integers, buffers, etc.), we have to point the Alias node - * to the original Node. - */ + /* Construct the alias object (a namespace node) */ + switch (target_node->type) { - - /* For these types, the sub-object can change dynamically via a Store */ - - case ACPI_TYPE_INTEGER: - case ACPI_TYPE_STRING: - case ACPI_TYPE_BUFFER: - case ACPI_TYPE_PACKAGE: - case ACPI_TYPE_BUFFER_FIELD: + case ACPI_TYPE_METHOD: /* - * These types open a new scope, so we need the NS node in order to access - * any children. + * Control method aliases need to be differentiated with + * a special type */ - case ACPI_TYPE_DEVICE: - case ACPI_TYPE_POWER: - case ACPI_TYPE_PROCESSOR: - case ACPI_TYPE_THERMAL: - case ACPI_TYPE_LOCAL_SCOPE: + alias_node->type = ACPI_TYPE_LOCAL_METHOD_ALIAS; + break; + + default: /* + * All other object types. + * * The new alias has the type ALIAS and points to the original * NS node, not the object itself. */ @@ -125,35 +115,12 @@ acpi_status acpi_ex_create_alias(struct acpi_walk_state *walk_state) alias_node->object = ACPI_CAST_PTR(union acpi_operand_object, target_node); break; - - case ACPI_TYPE_METHOD: - /* - * Control method aliases need to be differentiated - */ - alias_node->type = ACPI_TYPE_LOCAL_METHOD_ALIAS; - alias_node->object = - ACPI_CAST_PTR(union acpi_operand_object, target_node); - break; - - default: - - /* Attach the original source object to the new Alias Node */ - - /* - * The new alias assumes the type of the target, and it points - * to the same object. The reference count of the object has an - * additional reference to prevent deletion out from under either the - * target node or the alias Node - */ - status = acpi_ns_attach_object(alias_node, - acpi_ns_get_attached_object - (target_node), - target_node->type); - break; } /* Since both operands are Nodes, we don't need to delete them */ + alias_node->object = + ACPI_CAST_PTR(union acpi_operand_object, target_node); return_ACPI_STATUS(status); }