From: jordan Date: Fri, 23 Jul 2010 18:38:46 +0000 (+0000) Subject: Fix searchname to handle short name segments, remove hack in acpidock. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=b5fcabd99ebd97dd01d476c8b0c413fc89e787cd;p=openbsd Fix searchname to handle short name segments, remove hack in acpidock. --- diff --git a/sys/dev/acpi/acpidock.c b/sys/dev/acpi/acpidock.c index 964a6adfcb2..2d213803e23 100644 --- a/sys/dev/acpi/acpidock.c +++ b/sys/dev/acpi/acpidock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpidock.c,v 1.40 2010/07/21 19:35:15 deraadt Exp $ */ +/* $OpenBSD: acpidock.c,v 1.41 2010/07/23 18:38:46 jordan Exp $ */ /* * Copyright (c) 2006,2007 Michael Knudsen * @@ -282,11 +282,7 @@ acpidock_foundejd(struct aml_node *node, void *arg) if (aml_evalnode(sc->sc_acpi, node, 0, NULL, &res) == -1) printf(": error\n"); else { - if (!memcmp(res.v_string, "_SB.", 4)) { - dock = aml_searchname(&aml_root, "_SB_"); - dock = aml_searchname(dock, res.v_string+4); - } else - dock = aml_searchname(&aml_root, res.v_string); + dock = aml_searchname(&aml_root, res.v_string); if (dock == sc->sc_devnode) /* Add all children devices of Device containing _EJD */ diff --git a/sys/dev/acpi/dsdt.c b/sys/dev/acpi/dsdt.c index f5876bc4af8..7f4a319c9a1 100644 --- a/sys/dev/acpi/dsdt.c +++ b/sys/dev/acpi/dsdt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dsdt.c,v 1.172 2010/07/22 14:19:47 deraadt Exp $ */ +/* $OpenBSD: dsdt.c,v 1.173 2010/07/23 18:38:46 jordan Exp $ */ /* * Copyright (c) 2005 Jordan Hargrave * @@ -4101,6 +4101,8 @@ struct aml_node * aml_searchname(struct aml_node *root, const void *vname) { char *name = (char *)vname; + char nseg[AML_NAMESEG_LEN + 1]; + int i; dnprintf(25,"Searchname: %s:%s = ", aml_nodename(root), vname); if (*name == AMLOP_ROOTCHAR) { @@ -4108,8 +4110,13 @@ aml_searchname(struct aml_node *root, const void *vname) name++; } while (*name != 0) { - root = __aml_search(root, name, 0); - name += (name[4] == '.') ? 5 : 4; + /* Ugh.. we can have short names here: append '_' */ + strlcpy(nseg, "____", sizeof(nseg)); + for (i=0; i < AML_NAMESEG_LEN && *name && *name != '.'; i++) + nseg[i] = *name++; + if (*name == '.') + name++; + root = __aml_search(root, nseg, 0); } dnprintf(25,"%p %s\n", root, aml_nodename(root)); return root;