drivers/acpi/acpica/dbconvert.c

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

File Facts

System
Linux kernel
Corpus path
drivers/acpi/acpica/dbconvert.c
Extension
.c
Size
12895 bytes
Lines
456
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

while (string[i] && ((string[i] == ',') || (string[i] == ' '))) {
			i++;
		}
	}

	buffer = ACPI_ALLOCATE(length);
	if (!buffer) {
		return (AE_NO_MEMORY);
	}

	/* Convert the command line bytes to the buffer */

	for (i = 0, j = 0; string[i];) {
		status = acpi_db_hex_byte_to_binary(&string[i], &buffer[j]);
		if (ACPI_FAILURE(status)) {
			ACPI_FREE(buffer);
			return (status);
		}

		j++;
		i += 2;
		while (string[i] && ((string[i] == ',') || (string[i] == ' '))) {
			i++;
		}
	}

	object->type = ACPI_TYPE_BUFFER;
	object->buffer.pointer = buffer;
	object->buffer.length = length;
	return (AE_OK);
}

/*******************************************************************************
 *
 * FUNCTION:    acpi_db_convert_to_package
 *
 * PARAMETERS:  string              - Input string to be converted
 *              object              - Where the package object is returned
 *
 * RETURN:      Status
 *
 * DESCRIPTION: Convert a string to a package object. Handles nested packages
 *              via recursion with acpi_db_convert_to_object.
 *
 ******************************************************************************/

acpi_status acpi_db_convert_to_package(char *string, union acpi_object *object)
{
	char *this;
	char *next;
	u32 i;
	acpi_object_type type;
	union acpi_object *elements;
	acpi_status status;

	elements =
	    ACPI_ALLOCATE_ZEROED(DB_DEFAULT_PKG_ELEMENTS *
				 sizeof(union acpi_object));
	if (!elements)
		return (AE_NO_MEMORY);

	this = string;
	for (i = 0; i < (DB_DEFAULT_PKG_ELEMENTS - 1); i++) {
		this = acpi_db_get_next_token(this, &next, &type);
		if (!this) {
			break;
		}

		/* Recursive call to convert each package element */

		status = acpi_db_convert_to_object(type, this, &elements[i]);
		if (ACPI_FAILURE(status)) {
			acpi_db_delete_objects(i + 1, elements);
			ACPI_FREE(elements);
			return (status);
		}

		this = next;
	}

	object->type = ACPI_TYPE_PACKAGE;
	object->package.count = i;
	object->package.elements = elements;
	return (AE_OK);
}

/*******************************************************************************
 *
 * FUNCTION:    acpi_db_convert_to_object
 *

Annotation

Implementation Notes