Source
x
// SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
/******************************************************************************
*
* Module Name: utids - support for device Ids - HID, UID, CID, SUB, CLS
*
* Copyright (C) 2000 - 2019, Intel Corp.
*
*****************************************************************************/
ACPI_MODULE_NAME("utids")
/*******************************************************************************
*
* FUNCTION: acpi_ut_execute_HID
*
* PARAMETERS: device_node - Node for the device
* return_id - Where the string HID is returned
*
* RETURN: Status
*
* DESCRIPTION: Executes the _HID control method that returns the hardware
* ID of the device. The HID is either an 32-bit encoded EISAID
* Integer or a String. A string is always returned. An EISAID
* is converted to a string.
*
* NOTE: Internal function, no parameter validation
*
******************************************************************************/
acpi_status
acpi_ut_execute_HID(struct acpi_namespace_node *device_node,
struct acpi_pnp_device_id **return_id)
{
union acpi_operand_object *obj_desc;
struct acpi_pnp_device_id *hid;
u32 length;
acpi_status status;
ACPI_FUNCTION_TRACE(ut_execute_HID);
status = acpi_ut_evaluate_object(device_node, METHOD_NAME__HID,
ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING,
&obj_desc);
if (ACPI_FAILURE(status)) {
return_ACPI_STATUS(status);
}
/* Get the size of the String to be returned, includes null terminator */
if (obj_desc->common.type == ACPI_TYPE_INTEGER) {
length = ACPI_EISAID_STRING_SIZE;
} else {
length = obj_desc->string.length + 1;
}
/* Allocate a buffer for the HID */
hid =
ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_pnp_device_id) +
(acpi_size)length);
if (!hid) {
status = AE_NO_MEMORY;
goto cleanup;
}
/* Area for the string starts after PNP_DEVICE_ID struct */
hid->string =
ACPI_ADD_PTR(char, hid, sizeof(struct acpi_pnp_device_id));
/* Convert EISAID to a string or simply copy existing string */
if (obj_desc->common.type == ACPI_TYPE_INTEGER) {
acpi_ex_eisa_id_to_string(hid->string, obj_desc->integer.value);
} else {
strcpy(hid->string, obj_desc->string.pointer);
}
hid->length = length;
*return_id = hid;
cleanup:
/* On exit, we must delete the return object */
acpi_ut_remove_reference(obj_desc);
return_ACPI_STATUS(status);
}