diff options
author | Jordan Hargrave <jordan@cvs.openbsd.org> | 2009-03-11 20:37:47 +0000 |
---|---|---|
committer | Jordan Hargrave <jordan@cvs.openbsd.org> | 2009-03-11 20:37:47 +0000 |
commit | 792deb44a3773eae61acf87bcaa84d581e9fb2b2 (patch) | |
tree | a73fa4e65d35c5b6700ba56d2cc5af1b63863b61 /sys/dev | |
parent | 19ce25b27427f1d8b93efb77e700f93762de2622 (diff) |
Cleanup.. use aml_evalinteger instead of aml_evalname
ok marco@
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/acpi/acpi.c | 28 | ||||
-rw-r--r-- | sys/dev/acpi/acpiac.c | 9 | ||||
-rw-r--r-- | sys/dev/acpi/acpidock.c | 12 | ||||
-rw-r--r-- | sys/dev/acpi/acpiec.c | 8 | ||||
-rw-r--r-- | sys/dev/acpi/acpiprt.c | 9 | ||||
-rw-r--r-- | sys/dev/acpi/acpithinkpad.c | 46 | ||||
-rw-r--r-- | sys/dev/acpi/dsdt.c | 14 |
7 files changed, 50 insertions, 76 deletions
diff --git a/sys/dev/acpi/acpi.c b/sys/dev/acpi/acpi.c index 73b80e8e6bc..6d88b5faf9f 100644 --- a/sys/dev/acpi/acpi.c +++ b/sys/dev/acpi/acpi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpi.c,v 1.133 2009/03/10 19:35:03 jordan Exp $ */ +/* $OpenBSD: acpi.c,v 1.134 2009/03/11 20:37:46 jordan Exp $ */ /* * Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com> * Copyright (c) 2005 Jordan Hargrave <jordan@openbsd.org> @@ -272,13 +272,7 @@ int acpi_inidev(struct aml_node *node, void *arg) { struct acpi_softc *sc = (struct acpi_softc *)arg; - struct aml_value res; - int st = 0; - - /* Default value */ - st = STA_PRESENT|STA_ENABLED; - st |= STA_SHOW_UI|STA_DEV_OK; - st |= STA_BATTERY; + int64_t st; /* * Per the ACPI spec 6.5.1, only run _INI when device is there or @@ -287,9 +281,8 @@ acpi_inidev(struct aml_node *node, void *arg) */ /* Evaluate _STA to decide _INI fate and walk fate */ - if (!aml_evalname(sc, node->parent, "_STA", 0, NULL, &res)) - st = (int)aml_val2int(&res); - aml_freevalue(&res); + if (aml_evalinteger(sc, node->parent, "_STA", 0, NULL, &st)) + st = STA_PRESENT | STA_ENABLED | STA_DEV_OK | 0x1000; /* Evaluate _INI if we are present */ if (st & STA_PRESENT) @@ -313,20 +306,13 @@ acpi_foundprt(struct aml_node *node, void *arg) struct acpi_softc *sc = (struct acpi_softc *)arg; struct device *self = (struct device *)arg; struct acpi_attach_args aaa; - struct aml_value res; - int st = 0; + int64_t st = 0; dnprintf(10, "found prt entry: %s\n", node->parent->name); - /* Default value */ - st = STA_PRESENT|STA_ENABLED; - st |= STA_SHOW_UI|STA_DEV_OK; - st |= STA_BATTERY; - /* Evaluate _STA to decide _PRT fate and walk fate */ - if (!aml_evalname(sc, node->parent, "_STA", 0, NULL, &res)) - st = (int)aml_val2int(&res); - aml_freevalue(&res); + if (aml_evalinteger(sc, node->parent, "_STA", 0, NULL, &st)) + st = STA_PRESENT | STA_ENABLED | STA_DEV_OK | 0x1000; if (st & STA_PRESENT) { memset(&aaa, 0, sizeof(aaa)); diff --git a/sys/dev/acpi/acpiac.c b/sys/dev/acpi/acpiac.c index 9d846c9ba1f..1e534c44703 100644 --- a/sys/dev/acpi/acpiac.c +++ b/sys/dev/acpi/acpiac.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpiac.c,v 1.26 2008/11/06 23:41:28 marco Exp $ */ +/* $OpenBSD: acpiac.c,v 1.27 2009/03/11 20:37:46 jordan Exp $ */ /* * Copyright (c) 2005 Marco Peereboom <marco@openbsd.org> * @@ -100,20 +100,19 @@ acpiac_refresh(void *arg) int acpiac_getsta(struct acpiac_softc *sc) { - struct aml_value res; + int64_t sta; if (aml_evalname(sc->sc_acpi, sc->sc_devnode, "_STA", 0, NULL, NULL)) { dnprintf(10, "%s: no _STA\n", DEVNAME(sc)); } - if (aml_evalname(sc->sc_acpi, sc->sc_devnode, "_PSR", 0, NULL, &res)) { + if (aml_evalinteger(sc->sc_acpi, sc->sc_devnode, "_PSR", 0, NULL, &sta)) { dnprintf(10, "%s: no _PSR\n", DEVNAME(sc)); return (1); } - sc->sc_ac_stat = aml_val2int(&res); - aml_freevalue(&res); + sc->sc_ac_stat = sta; return (0); } diff --git a/sys/dev/acpi/acpidock.c b/sys/dev/acpi/acpidock.c index c0e2ee8e81b..8826e5d554c 100644 --- a/sys/dev/acpi/acpidock.c +++ b/sys/dev/acpi/acpidock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpidock.c,v 1.30 2008/06/01 17:59:55 marco Exp $ */ +/* $OpenBSD: acpidock.c,v 1.31 2009/03/11 20:37:46 jordan Exp $ */ /* * Copyright (c) 2006,2007 Michael Knudsen <mk@openbsd.org> * @@ -118,21 +118,21 @@ acpidock_attach(struct device *parent, struct device *self, void *aux) int acpidock_status(struct acpidock_softc *sc) { - struct aml_value res; + int64_t sta; int rv; if (aml_evalname(sc->sc_acpi, sc->sc_devnode, "_STA", 0, NULL, - &res) != 0) + &sta) != 0) { + sta = 0; rv = 0; + } else rv = 1; - sc->sc_sta = aml_val2int(&res); + sc->sc_sta = sta; sc->sc_docked = sc->sc_sta & STA_PRESENT; - aml_freevalue(&res); - return (rv); } diff --git a/sys/dev/acpi/acpiec.c b/sys/dev/acpi/acpiec.c index 2cb642975e6..06138a196ee 100644 --- a/sys/dev/acpi/acpiec.c +++ b/sys/dev/acpi/acpiec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpiec.c,v 1.27 2009/03/10 20:36:10 jordan Exp $ */ +/* $OpenBSD: acpiec.c,v 1.28 2009/03/11 20:37:46 jordan Exp $ */ /* * Copyright (c) 2006 Can Erkin Acar <canacar@openbsd.org> * @@ -372,14 +372,14 @@ acpiec_getcrs(struct acpiec_softc *sc, struct acpi_attach_args *aa) int type1, type2; char *buf; int size, ret; + int64_t gpe; - if (aml_evalname(sc->sc_acpi, sc->sc_devnode, "_GPE", 0, NULL, &res)) { + if (aml_evalinteger(sc->sc_acpi, sc->sc_devnode, "_GPE", 0, NULL, &gpe)) { dnprintf(10, "%s: no _GPE\n", DEVNAME(sc)); return (1); } - sc->sc_gpe = aml_val2int(&res); - aml_freevalue(&res); + sc->sc_gpe = gpe; if (aml_evalname(sc->sc_acpi, sc->sc_devnode, "_CRS", 0, NULL, &res)) { dnprintf(10, "%s: no _CRS\n", DEVNAME(sc)); diff --git a/sys/dev/acpi/acpiprt.c b/sys/dev/acpi/acpiprt.c index 7359d0b3bfc..bd3e4f25cc0 100644 --- a/sys/dev/acpi/acpiprt.c +++ b/sys/dev/acpi/acpiprt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpiprt.c,v 1.31 2009/01/27 21:32:00 kettenis Exp $ */ +/* $OpenBSD: acpiprt.c,v 1.32 2009/03/11 20:37:46 jordan Exp $ */ /* * Copyright (c) 2006 Mark Kettenis <kettenis@openbsd.org> * @@ -216,7 +216,8 @@ acpiprt_prt_add(struct acpiprt_softc *sc, struct aml_value *v) struct aml_node *node; struct aml_value res, *pp; u_int64_t addr; - int pin, irq, sta; + int pin, irq; + int64_t sta; #if NIOAPIC > 0 struct mp_intr_map *map; struct ioapic_softc *apic; @@ -260,13 +261,11 @@ acpiprt_prt_add(struct acpiprt_softc *sc, struct aml_value *v) } if (pp->type == AML_OBJTYPE_DEVICE) { node = pp->node; - if (aml_evalname(sc->sc_acpi, node, "_STA", 0, NULL, &res)) { + if (aml_evalinteger(sc->sc_acpi, node, "_STA", 0, NULL, &sta)) { printf("no _STA method\n"); return; } - sta = aml_val2int(&res); - aml_freevalue(&res); if ((sta & STA_PRESENT) == 0) return; diff --git a/sys/dev/acpi/acpithinkpad.c b/sys/dev/acpi/acpithinkpad.c index a70755073f7..508e97a0a41 100644 --- a/sys/dev/acpi/acpithinkpad.c +++ b/sys/dev/acpi/acpithinkpad.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpithinkpad.c,v 1.16 2009/03/10 20:36:10 jordan Exp $ */ +/* $OpenBSD: acpithinkpad.c,v 1.17 2009/03/11 20:37:46 jordan Exp $ */ /* * Copyright (c) 2008 joshua stein <jcs@openbsd.org> * @@ -125,20 +125,19 @@ thinkpad_match(struct device *parent, void *match, void *aux) { struct acpi_attach_args *aa = aux; struct cfdata *cf = match; - struct aml_value res; + int64_t res; int rv = 0; if (!acpi_matchhids(aa, acpithinkpad_hids, cf->cf_driver->cd_name)) return (0); - if (aml_evalname((struct acpi_softc *)parent, aa->aaa_node, + if (aml_evalinteger((struct acpi_softc *)parent, aa->aaa_node, "MHKV", 0, NULL, &res)) return (0); - if (aml_val2int(&res) == THINKPAD_HKEY_VERSION) + if (res == THINKPAD_HKEY_VERSION) rv = 1; - aml_freevalue(&res); return (rv); } @@ -217,17 +216,15 @@ thinkpad_attach(struct device *parent, struct device *self, void *aux) int thinkpad_enable_events(struct acpithinkpad_softc *sc) { - struct aml_value res, arg, args[2]; + struct aml_value arg, args[2]; int64_t mask; int i, rv = 1; /* get the supported event mask */ - if (aml_evalname(sc->sc_acpi, sc->sc_devnode, "MHKA", 0, NULL, &res)) { + if (aml_evalinteger(sc->sc_acpi, sc->sc_devnode, "MHKA", 0, NULL, &mask)) { printf("%s: no MHKA\n", DEVNAME(sc)); goto fail; } - mask = aml_val2int(&res); - aml_freevalue(&res); /* update hotkey mask */ bzero(args, sizeof(args)); @@ -261,8 +258,8 @@ int thinkpad_hotkey(struct aml_node *node, int notify_type, void *arg) { struct acpithinkpad_softc *sc = arg; - struct aml_value res; - int val, type, event, handled, rv = 1, tot = 0; + int type, event, handled, rv = 1, tot = 0; + int64_t val; if (notify_type == 0x00) { /* poll sensors */ @@ -273,11 +270,9 @@ thinkpad_hotkey(struct aml_node *node, int notify_type, void *arg) goto fail; for (;;) { - if (aml_evalname(sc->sc_acpi, sc->sc_devnode, "MHKP", 0, NULL, - &res)) + if (aml_evalinteger(sc->sc_acpi, sc->sc_devnode, "MHKP", 0, NULL, + &val)) goto done; - val = aml_val2int(&res); - aml_freevalue(&res); if (val == 0) goto done; @@ -285,6 +280,7 @@ thinkpad_hotkey(struct aml_node *node, int notify_type, void *arg) event = val & 0x0fff; handled = 0; + printf("ibmkey type:%x event:%.3x\n", type, event); switch (type) { case 1: switch (event) { @@ -382,15 +378,13 @@ fail: int thinkpad_toggle_bluetooth(struct acpithinkpad_softc *sc) { - struct aml_value res, arg; - int bluetooth, rv = 1; + struct aml_value arg; + int rv = 1; + int64_t bluetooth; - if (aml_evalname(sc->sc_acpi, sc->sc_devnode, "GBDC", 0, NULL, &res)) + if (aml_evalinteger(sc->sc_acpi, sc->sc_devnode, "GBDC", 0, NULL, &bluetooth)) goto fail; - bluetooth = aml_val2int(&res); - aml_freevalue(&res); - if (!(bluetooth & THINKPAD_BLUETOOTH_PRESENT)) goto fail; @@ -410,15 +404,13 @@ fail: int thinkpad_toggle_wan(struct acpithinkpad_softc *sc) { - struct aml_value res, arg; - int wan, rv = 1;; + struct aml_value arg; + int rv = 1; + int64_t wan; - if (aml_evalname(sc->sc_acpi, sc->sc_devnode, "GWAN", 0, NULL, &res)) + if (aml_evalinteger(sc->sc_acpi, sc->sc_devnode, "GWAN", 0, NULL, &wan)) goto fail; - wan = aml_val2int(&res); - aml_freevalue(&res); - if (!(wan & THINKPAD_WAN_PRESENT)) goto fail; diff --git a/sys/dev/acpi/dsdt.c b/sys/dev/acpi/dsdt.c index 2be52c2d40b..29edc0b01d3 100644 --- a/sys/dev/acpi/dsdt.c +++ b/sys/dev/acpi/dsdt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dsdt.c,v 1.140 2009/03/10 20:36:10 jordan Exp $ */ +/* $OpenBSD: dsdt.c,v 1.141 2009/03/11 20:37:46 jordan Exp $ */ /* * Copyright (c) 2005 Jordan Hargrave <jordan@openbsd.org> * @@ -1378,15 +1378,14 @@ int amlop_delay; u_int64_t aml_getpciaddr(struct acpi_softc *sc, struct aml_node *root) { - struct aml_value tmpres; + int64_t tmpres; u_int64_t pciaddr; /* PCI */ pciaddr = 0; - if (!aml_evalname(dsdt_softc, root, "_ADR", 0, NULL, &tmpres)) { + if (!aml_evalinteger(dsdt_softc, root, "_ADR", 0, NULL, &tmpres)) { /* Device:Function are bits 16-31,32-47 */ - pciaddr += (aml_val2int(&tmpres) << 16L); - aml_freevalue(&tmpres); + pciaddr += (tmpres << 16L); dnprintf(20, "got _adr [%s]\n", aml_nodename(root)); } else { /* Mark invalid */ @@ -1394,10 +1393,9 @@ aml_getpciaddr(struct acpi_softc *sc, struct aml_node *root) return pciaddr; } - if (!aml_evalname(dsdt_softc, root, "_BBN", 0, NULL, &tmpres)) { + if (!aml_evalinteger(dsdt_softc, root, "_BBN", 0, NULL, &tmpres)) { /* PCI bus is in bits 48-63 */ - pciaddr += (aml_val2int(&tmpres) << 48L); - aml_freevalue(&tmpres); + pciaddr += (tmpres << 48L); dnprintf(20, "got _bbn [%s]\n", aml_nodename(root)); } dnprintf(20, "got pciaddr: %s:%llx\n", aml_nodename(root), pciaddr); |