From 0b2304cb4b818ffb94266a1890643c11508d0029 Mon Sep 17 00:00:00 2001 From: Joshua Stein Date: Wed, 31 Jul 2019 15:58:01 +0000 Subject: aml_find_node: perform callback on matched direct-child nodes before recursing into child devices looking for matches. This ensures that when walking nodes with acpi_inidev, a method like \_SB_.PCI0._INI will be executed before \_SB_.PCI0.I2C1.TPL1._INI. This matches how ACPICA walks nodes and a commonly-used DSDT template assumes that \OSYS has been initialized in \_SB_.PCI0._INI before being used by other device _INI methods. This should also help to execute \_INI and \_SB_._INI first, if present, which ACPICA does explicitly. Tested in snaps, ok deraadt --- sys/dev/acpi/dsdt.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'sys/dev/acpi') diff --git a/sys/dev/acpi/dsdt.c b/sys/dev/acpi/dsdt.c index cbd38c9be6f..68651c0bffd 100644 --- a/sys/dev/acpi/dsdt.c +++ b/sys/dev/acpi/dsdt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dsdt.c,v 1.245 2019/07/31 15:47:49 jcs Exp $ */ +/* $OpenBSD: dsdt.c,v 1.246 2019/07/31 15:58:00 jcs Exp $ */ /* * Copyright (c) 2005 Jordan Hargrave * @@ -1263,6 +1263,7 @@ aml_find_node(struct aml_node *node, const char *name, struct aml_node *child; const char *nn; + /* match child of this node first before recursing */ SIMPLEQ_FOREACH(child, &node->son, sib) { nn = child->name; if (nn != NULL) { @@ -1270,12 +1271,14 @@ aml_find_node(struct aml_node *node, const char *name, while (*nn == AMLOP_PARENTPREFIX) nn++; if (strcmp(name, nn) == 0) { /* Only recurse if cbproc() wants us to */ - if (cbproc(child, arg) == 0) - continue; + if (cbproc(child, arg) != 0) + return; } } - aml_find_node(child, name, cbproc, arg); } + + SIMPLEQ_FOREACH(child, &node->son, sib) + aml_find_node(child, name, cbproc, arg); } /* -- cgit v1.2.3