drivers/acpi/acpica/nsconvert.c
Source file repositories/reference/linux-study-clean/drivers/acpi/acpica/nsconvert.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/acpi/acpica/nsconvert.c- Extension
.c- Size
- 13161 bytes
- Lines
- 491
- 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.
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
acpi/acpi.haccommon.hacnamesp.hacinterp.hacpredef.hamlresrc.h
Detected Declarations
function Copyrightfunction acpi_ns_convert_to_stringfunction acpi_ns_convert_to_bufferfunction acpi_ns_convert_to_unicodefunction acpi_ns_convert_to_resourcefunction acpi_ns_convert_to_reference
Annotated Snippet
if (ACPI_FAILURE(status)) {
return (status);
}
break;
case ACPI_TYPE_BUFFER:
/* Buffer-to-Integer conversion. Max buffer size is 64 bits. */
if (original_object->buffer.length > 8) {
return (AE_AML_OPERAND_TYPE);
}
/* Extract each buffer byte to create the integer */
for (i = 0; i < original_object->buffer.length; i++) {
value |= ((u64)
original_object->buffer.pointer[i] << (i *
8));
}
break;
default:
return (AE_AML_OPERAND_TYPE);
}
new_object = acpi_ut_create_integer_object(value);
if (!new_object) {
return (AE_NO_MEMORY);
}
*return_object = new_object;
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: acpi_ns_convert_to_string
*
* PARAMETERS: original_object - Object to be converted
* return_object - Where the new converted object is returned
*
* RETURN: Status. AE_OK if conversion was successful.
*
* DESCRIPTION: Attempt to convert a Integer/Buffer object to a String.
*
******************************************************************************/
acpi_status
acpi_ns_convert_to_string(union acpi_operand_object *original_object,
union acpi_operand_object **return_object)
{
union acpi_operand_object *new_object;
acpi_size length;
acpi_status status;
switch (original_object->common.type) {
case ACPI_TYPE_INTEGER:
/*
* Integer-to-String conversion. Commonly, convert
* an integer of value 0 to a NULL string. The last element of
* _BIF and _BIX packages occasionally need this fix.
*/
if (original_object->integer.value == 0) {
/* Allocate a new NULL string object */
new_object = acpi_ut_create_string_object(0);
if (!new_object) {
return (AE_NO_MEMORY);
}
} else {
status = acpi_ex_convert_to_string(original_object,
&new_object,
ACPI_IMPLICIT_CONVERT_HEX);
if (ACPI_FAILURE(status)) {
return (status);
}
}
break;
case ACPI_TYPE_BUFFER:
/*
* Buffer-to-String conversion. Use a to_string
* conversion, no transform performed on the buffer data. The best
* example of this is the _BIF method, where the string data from
* the battery is often (incorrectly) returned as buffer object(s).
*/
length = 0;
Annotation
- Immediate include surface: `acpi/acpi.h`, `accommon.h`, `acnamesp.h`, `acinterp.h`, `acpredef.h`, `amlresrc.h`.
- Detected declarations: `function Copyright`, `function acpi_ns_convert_to_string`, `function acpi_ns_convert_to_buffer`, `function acpi_ns_convert_to_unicode`, `function acpi_ns_convert_to_resource`, `function acpi_ns_convert_to_reference`.
- Atlas domain: Driver Families / drivers/acpi.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.