acpi: use AcpiGetObjectInfo() for get_device_hid().

This commit is contained in:
Jérôme Duval 2013-11-01 16:49:34 +01:00
parent 0e1c6462de
commit b7c15bf02a

View File

@ -450,8 +450,7 @@ status_t
get_device_hid(const char *path, char *hid, size_t bufferLength)
{
ACPI_HANDLE handle;
ACPI_OBJECT info;
ACPI_BUFFER infoBuffer;
ACPI_DEVICE_INFO *info;
TRACE("get_device_hid: path %s, hid %s\n", path, hid);
if (AcpiGetHandle(NULL, (ACPI_STRING)path, &handle) != AE_OK)
@ -460,29 +459,14 @@ get_device_hid(const char *path, char *hid, size_t bufferLength)
if (bufferLength < ACPI_DEVICE_ID_LENGTH)
return B_BUFFER_OVERFLOW;
infoBuffer.Pointer = &info;
infoBuffer.Length = sizeof(ACPI_OBJECT);
info.String.Pointer = hid;
info.String.Length = 9;
info.String.Type = ACPI_TYPE_STRING;
if (AcpiEvaluateObject(handle, "_HID", NULL, &infoBuffer) != AE_OK)
if (AcpiGetObjectInfo(handle, &info) != AE_OK)
return B_BAD_TYPE;
if (info.Type == ACPI_TYPE_INTEGER) {
uint32 eisaId = AcpiUtDwordByteSwap(info.Integer.Value);
hid[0] = (char) ('@' + ((eisaId >> 26) & 0x1f));
hid[1] = (char) ('@' + ((eisaId >> 21) & 0x1f));
hid[2] = (char) ('@' + ((eisaId >> 16) & 0x1f));
hid[3] = AcpiUtHexToAsciiChar((ACPI_INTEGER)eisaId, 12);
hid[4] = AcpiUtHexToAsciiChar((ACPI_INTEGER)eisaId, 8);
hid[5] = AcpiUtHexToAsciiChar((ACPI_INTEGER)eisaId, 4);
hid[6] = AcpiUtHexToAsciiChar((ACPI_INTEGER)eisaId, 0);
hid[7] = 0;
}
hid[ACPI_DEVICE_ID_LENGTH] = '\0';
if ((info->Valid & ACPI_VALID_HID) != 0)
strlcpy(hid, info->HardwareId.String, bufferLength);
else
hid[0] = '\0';
AcpiOsFree(info);
return B_OK;
}