summaryrefslogtreecommitdiff
path: root/sys/dev/acpi/dsdt.c
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2016-01-13 23:11:23 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2016-01-13 23:11:23 +0000
commit0266bc4fff3b9f50badd8cf517f162f80cd73e3c (patch)
tree0956523787cfae3fea3afd36af277fd1312e688e /sys/dev/acpi/dsdt.c
parent034ac86a8271f72b97dd4bcd569127b7d3989645 (diff)
Change aml_find_node() such that it only walks down the tree and doesn't
traverse sideways. This seems to be what all callersexpect it to do, and fixes a bug in dwiic(4) where it would try to access i2c devices on busses they're not attached to. If there is any fallout from this change, the right thing to do is probably to make sure callers pass the right node. While there, change the return type to void, as the return value was useless and none of the callers looked at it. ok mlarkin@
Diffstat (limited to 'sys/dev/acpi/dsdt.c')
-rw-r--r--sys/dev/acpi/dsdt.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/sys/dev/acpi/dsdt.c b/sys/dev/acpi/dsdt.c
index 85885949141..769f8686096 100644
--- a/sys/dev/acpi/dsdt.c
+++ b/sys/dev/acpi/dsdt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dsdt.c,v 1.218 2015/08/20 20:50:10 kettenis Exp $ */
+/* $OpenBSD: dsdt.c,v 1.219 2016/01/13 23:11:22 kettenis Exp $ */
/*
* Copyright (c) 2005 Jordan Hargrave <jordan@openbsd.org>
*
@@ -1249,26 +1249,26 @@ aml_walknodes(struct aml_node *node, int mode,
nodecb(node, arg);
}
-int
+void
aml_find_node(struct aml_node *node, const char *name,
int (*cbproc)(struct aml_node *, void *arg), void *arg)
{
+ struct aml_node *child;
const char *nn;
- int st = 0;
- while (node) {
- if ((nn = node->name) != NULL) {
+ SIMPLEQ_FOREACH(child, &node->son, sib) {
+ nn = child->name;
+ if ((nn = child->name) != NULL) {
if (*nn == AMLOP_ROOTCHAR) nn++;
while (*nn == AMLOP_PARENTPREFIX) nn++;
- if (!strcmp(name, nn))
- st = cbproc(node, arg);
+ if (strcmp(name, nn) == 0) {
+ /* Only recurse if cbproc() wants us to */
+ if (cbproc(child, arg) == 0)
+ continue;
+ }
}
- /* Only recurse if cbproc() wants us to */
- if (!st)
- aml_find_node(SIMPLEQ_FIRST(&node->son), name, cbproc, arg);
- node = SIMPLEQ_NEXT(node, sib);
+ aml_find_node(child, name, cbproc, arg);
}
- return st;
}
/*