diff options
author | Jordan Hargrave <jordan@cvs.openbsd.org> | 2010-07-01 01:39:40 +0000 |
---|---|---|
committer | Jordan Hargrave <jordan@cvs.openbsd.org> | 2010-07-01 01:39:40 +0000 |
commit | f844018e6a6c85716be39c97a0dbf32ac107bf69 (patch) | |
tree | db60e1baf6ba70843cca65fc63735b8d3be35b46 | |
parent | 8b0cabf08a8a73f93206ccb4d96db6d1e3a86481 (diff) |
Simplified aml_parse_resource call, cleanup code
ok marco
-rw-r--r-- | sys/dev/acpi/acpi.c | 9 | ||||
-rw-r--r-- | sys/dev/acpi/acpiprt.c | 13 | ||||
-rw-r--r-- | sys/dev/acpi/dsdt.c | 14 | ||||
-rw-r--r-- | sys/dev/acpi/dsdt.h | 4 |
4 files changed, 17 insertions, 23 deletions
diff --git a/sys/dev/acpi/acpi.c b/sys/dev/acpi/acpi.c index 49808b848de..b91fedb5382 100644 --- a/sys/dev/acpi/acpi.c +++ b/sys/dev/acpi/acpi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpi.c,v 1.166 2010/07/01 01:14:36 jordan Exp $ */ +/* $OpenBSD: acpi.c,v 1.167 2010/07/01 01:39:39 jordan Exp $ */ /* * Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com> * Copyright (c) 2005 Jordan Hargrave <jordan@openbsd.org> @@ -572,11 +572,8 @@ acpi_getpci(struct aml_node *node, void *arg) if (!aml_evalinteger(sc, node, "_BBN", 0, NULL, &val)) pci->bus = val; else if (!aml_evalname(sc, node, "_CRS", 0, NULL, &res)) { - if (res.type == AML_OBJTYPE_BUFFER && - res.length > 5) - aml_parse_resource(res.length, - res.v_buffer, acpi_getminbus, - &pci->bus); + aml_parse_resource(&res, acpi_getminbus, + &pci->bus); } pci->sub = pci->bus; node->pci = pci; diff --git a/sys/dev/acpi/acpiprt.c b/sys/dev/acpi/acpiprt.c index 92c643003ab..f1f7578e912 100644 --- a/sys/dev/acpi/acpiprt.c +++ b/sys/dev/acpi/acpiprt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpiprt.c,v 1.36 2010/06/29 23:44:34 jordan Exp $ */ +/* $OpenBSD: acpiprt.c,v 1.37 2010/07/01 01:39:39 jordan Exp $ */ /* * Copyright (c) 2006 Mark Kettenis <kettenis@openbsd.org> * @@ -278,18 +278,13 @@ acpiprt_prt_add(struct acpiprt_softc *sc, struct aml_value *v) aml_freevalue(&res); return; } - aml_parse_resource(res.length, res.v_buffer, - acpiprt_getirq, &irq); + aml_parse_resource(&res, acpiprt_getirq, &irq); aml_freevalue(&res); /* Pick a new IRQ if necessary. */ if ((irq == 0 || irq == 2 || irq == 13) && !aml_evalname(sc->sc_acpi, node, "_PRS", 0, NULL, &res)){ - if (res.type == AML_OBJTYPE_BUFFER && - res.length >= 5) { - aml_parse_resource(res.length, res.v_buffer, - acpiprt_chooseirq, &irq); - } + aml_parse_resource(&res, acpiprt_chooseirq, &irq); aml_freevalue(&res); } @@ -409,7 +404,7 @@ acpiprt_route_interrupt(int bus, int dev, int pin) aml_freevalue(&res); return; } - aml_parse_resource(res.length, res.v_buffer, acpiprt_getirq, &irq); + aml_parse_resource(&res, acpiprt_getirq, &irq); /* Only re-route interrupts when necessary. */ if ((sta & STA_ENABLED) && irq == newirq) { diff --git a/sys/dev/acpi/dsdt.c b/sys/dev/acpi/dsdt.c index 9e8c5558910..178d145a661 100644 --- a/sys/dev/acpi/dsdt.c +++ b/sys/dev/acpi/dsdt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dsdt.c,v 1.162 2010/06/30 19:23:09 jordan Exp $ */ +/* $OpenBSD: dsdt.c,v 1.163 2010/07/01 01:39:39 jordan Exp $ */ /* * Copyright (c) 2005 Jordan Hargrave <jordan@openbsd.org> * @@ -1628,14 +1628,16 @@ aml_mapresource(union acpi_resource *crs) } int -aml_parse_resource(int length, uint8_t *buffer, +aml_parse_resource(struct aml_value *res, int (*crs_enum)(union acpi_resource *, void *), void *arg) { int off, rlen; union acpi_resource *crs; - for (off = 0; off < length; off += rlen) { - crs = (union acpi_resource *)(buffer+off); + if (res->type != AML_OBJTYPE_BUFFER || res->length < 5) + return (-1); + for (off = 0; off < res->length; off += rlen) { + crs = (union acpi_resource *)(res->v_buffer+off); rlen = AML_CRSLEN(crs); if (crs->hdr.typecode == 0x79 || rlen <= 3) @@ -2188,8 +2190,8 @@ aml_xconcatres(struct aml_value *a1, struct aml_value *a2) aml_die("concatres: not buffers\n"); /* Walk a1, a2, get length minus end tags, concatenate buffers, add end tag */ - aml_parse_resource(a1->length, a1->v_buffer, aml_ccrlen, &l1); - aml_parse_resource(a2->length, a2->v_buffer, aml_ccrlen, &l2); + aml_parse_resource(a1, aml_ccrlen, &l1); + aml_parse_resource(a2, aml_ccrlen, &l2); /* Concatenate buffers, add end tag */ c = aml_allocvalue(AML_OBJTYPE_BUFFER, l1+l2+l3, NULL); diff --git a/sys/dev/acpi/dsdt.h b/sys/dev/acpi/dsdt.h index 44425bb01ac..9be45946b0f 100644 --- a/sys/dev/acpi/dsdt.h +++ b/sys/dev/acpi/dsdt.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dsdt.h,v 1.46 2009/09/04 22:50:11 jordan Exp $ */ +/* $OpenBSD: dsdt.h,v 1.47 2010/07/01 01:39:39 jordan Exp $ */ /* * Copyright (c) 2005 Marco Peereboom <marco@openbsd.org> * @@ -213,7 +213,7 @@ union acpi_resource { 3+(x)->hdr.length : 1+((x)->hdr.typecode & 0x7)) int aml_print_resource(union acpi_resource *, void *); -int aml_parse_resource(int, uint8_t *, +int aml_parse_resource(struct aml_value *, int (*)(union acpi_resource *, void *), void *); #define ACPI_E_NOERROR 0x00 |