dsdt: add support for pnp ids as strings
PNP devices can be declared using eisaid encoding ...
Name (_HID, EisaId ("PNP0103"))
... or as string ...
Name (_HID, "PNP0A06")
.. so lets support both variants.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-id: 20200930111222.6020-3-kraxel@redhat.com
diff --git a/src/fw/dsdt_parser.c b/src/fw/dsdt_parser.c
index 87c1a3a..eb5496f 100644
--- a/src/fw/dsdt_parser.c
+++ b/src/fw/dsdt_parser.c
@@ -515,7 +515,8 @@
}
static struct acpi_device *acpi_dsdt_find(struct acpi_device *prev,
- const u8 *aml, int size)
+ const u8 *aml1, int size1,
+ const u8 *aml2, int size2)
{
struct acpi_device *dev;
struct hlist_node *node;
@@ -527,11 +528,13 @@
for (; node != NULL; node = dev->node.next) {
dev = container_of(node, struct acpi_device, node);
- if (!aml)
+ if (!aml1 && !aml2)
return dev;
if (!dev->hid_aml)
continue;
- if (memcmp(dev->hid_aml + 5, aml, size) == 0)
+ if (aml1 && memcmp(dev->hid_aml + 5, aml1, size1) == 0)
+ return dev;
+ if (aml2 && memcmp(dev->hid_aml + 5, aml2, size2) == 0)
return dev;
}
return NULL;
@@ -568,19 +571,21 @@
u8 aml[10];
int len = snprintf((char*)aml, sizeof(aml), "\x0d%s", hid);
- return acpi_dsdt_find(prev, aml, len);
+ return acpi_dsdt_find(prev, aml, len, NULL, 0);
}
struct acpi_device *acpi_dsdt_find_eisaid(struct acpi_device *prev, u16 eisaid)
{
if (!CONFIG_ACPI_PARSE)
return NULL;
- u8 aml[] = {
+ u8 aml1[] = {
0x0c, 0x41, 0xd0,
eisaid >> 8,
eisaid & 0xff
};
- return acpi_dsdt_find(prev, aml, 5);
+ u8 aml2[10];
+ int len2 = snprintf((char*)aml2, sizeof(aml2), "\x0dPNP%04X", eisaid);
+ return acpi_dsdt_find(prev, aml1, 5, aml2, len2);
}
char *acpi_dsdt_name(struct acpi_device *dev)
@@ -651,9 +656,9 @@
struct acpi_device *dev;
dprintf(1, "ACPI: dumping dsdt devices\n");
- for (dev = acpi_dsdt_find(NULL, NULL, 0);
+ for (dev = acpi_dsdt_find(NULL, NULL, 0, NULL, 0);
dev != NULL;
- dev = acpi_dsdt_find(dev, NULL, 0)) {
+ dev = acpi_dsdt_find(dev, NULL, 0, NULL, 0)) {
dprintf(1, " %s", acpi_dsdt_name(dev));
if (dev->hid_aml)
dprintf(1, ", hid");