drivers/acpi/acpica/excreate.c

Source file repositories/reference/linux-study-clean/drivers/acpi/acpica/excreate.c

File Facts

System
Linux kernel
Corpus path
drivers/acpi/acpica/excreate.c
Extension
.c
Size
13041 bytes
Lines
471
Domain
Driver Families
Bucket
drivers/acpi
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

// SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
/******************************************************************************
 *
 * Module Name: excreate - Named object creation
 *
 * Copyright (C) 2000 - 2026, Intel Corp.
 *
 *****************************************************************************/

#include <acpi/acpi.h>
#include "accommon.h"
#include "acinterp.h"
#include "amlcode.h"
#include "acnamesp.h"

#define _COMPONENT          ACPI_EXECUTER
ACPI_MODULE_NAME("excreate")
/*******************************************************************************
 *
 * FUNCTION:    acpi_ex_create_alias
 *
 * PARAMETERS:  walk_state           - Current state, contains operands
 *
 * RETURN:      Status
 *
 * DESCRIPTION: Create a new named alias
 *
 ******************************************************************************/
acpi_status acpi_ex_create_alias(struct acpi_walk_state *walk_state)
{
	struct acpi_namespace_node *target_node;
	struct acpi_namespace_node *alias_node;
	acpi_status status = AE_OK;

	ACPI_FUNCTION_TRACE(ex_create_alias);

	/* Get the source/alias operands (both namespace nodes) */

	alias_node = (struct acpi_namespace_node *)walk_state->operands[0];
	target_node = (struct acpi_namespace_node *)walk_state->operands[1];

	if ((target_node->type == ACPI_TYPE_LOCAL_ALIAS) ||
	    (target_node->type == ACPI_TYPE_LOCAL_METHOD_ALIAS)) {
		/*
		 * Dereference an existing alias so that we don't create a chain
		 * of aliases. With this code, we guarantee that an alias is
		 * always exactly one level of indirection away from the
		 * actual aliased name.
		 */
		target_node =
		    ACPI_CAST_PTR(struct acpi_namespace_node,
				  target_node->object);
	}

	/* Ensure that the target node is valid */

	if (!target_node) {
		return_ACPI_STATUS(AE_NULL_OBJECT);
	}

	/* Construct the alias object (a namespace node) */

	switch (target_node->type) {
	case ACPI_TYPE_METHOD:
		/*
		 * Control method aliases need to be differentiated with
		 * a special type
		 */
		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.
		 */
		alias_node->type = ACPI_TYPE_LOCAL_ALIAS;
		alias_node->object =
		    ACPI_CAST_PTR(union acpi_operand_object, target_node);
		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);
}

Annotation

Implementation Notes