drivers/acpi/acpica/uttrack.c

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

File Facts

System
Linux kernel
Corpus path
drivers/acpi/acpica/uttrack.c
Extension
.c
Size
19017 bytes
Lines
706
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

if (!element->next) {
			return (element);
		}

		element = element->next;
	}

	if (element == allocation) {
		return (element);
	}

	return (element->previous);
}

/*******************************************************************************
 *
 * FUNCTION:    acpi_ut_track_allocation
 *
 * PARAMETERS:  allocation          - Address of allocated memory
 *              size                - Size of the allocation
 *              alloc_type          - MEM_MALLOC or MEM_CALLOC
 *              component           - Component type of caller
 *              module              - Source file name of caller
 *              line                - Line number of caller
 *
 * RETURN:      Status
 *
 * DESCRIPTION: Inserts an element into the global allocation tracking list.
 *
 ******************************************************************************/

static acpi_status
acpi_ut_track_allocation(struct acpi_debug_mem_block *allocation,
			 acpi_size size,
			 u8 alloc_type,
			 u32 component, const char *module, u32 line)
{
	struct acpi_memory_list *mem_list;
	struct acpi_debug_mem_block *element;
	acpi_status status = AE_OK;

	ACPI_FUNCTION_TRACE_PTR(ut_track_allocation, allocation);

	if (acpi_gbl_disable_mem_tracking) {
		return_ACPI_STATUS(AE_OK);
	}

	mem_list = acpi_gbl_global_list;
	status = acpi_ut_acquire_mutex(ACPI_MTX_MEMORY);
	if (ACPI_FAILURE(status)) {
		return_ACPI_STATUS(status);
	}

	/*
	 * Search the global list for this address to make sure it is not
	 * already present. This will catch several kinds of problems.
	 */
	element = acpi_ut_find_allocation(allocation);
	if (element == allocation) {
		ACPI_ERROR((AE_INFO,
			    "UtTrackAllocation: Allocation (%p) already present in global list!",
			    allocation));
		goto unlock_and_exit;
	}

	/* Fill in the instance data */

	allocation->size = (u32)size;
	allocation->alloc_type = alloc_type;
	allocation->component = component;
	allocation->line = line;

	acpi_ut_safe_strncpy(allocation->module, (char *)module,
			     ACPI_MAX_MODULE_NAME);

	if (!element) {

		/* Insert at list head */

		if (mem_list->list_head) {
			((struct acpi_debug_mem_block *)(mem_list->list_head))->
			    previous = allocation;
		}

		allocation->next = mem_list->list_head;
		allocation->previous = NULL;

		mem_list->list_head = allocation;
	} else {
		/* Insert after element */

Annotation

Implementation Notes