Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/acpi Use acpi_eval_reference_handle() to simplify co...
details: https://anonhg.NetBSD.org/src/rev/64c417ae9f82
branches: trunk
changeset: 750911:64c417ae9f82
user: jruoho <jruoho%NetBSD.org@localhost>
date: Mon Jan 18 18:36:49 2010 +0000
description:
Use acpi_eval_reference_handle() to simplify code. No functional change.
ok jmcneill@, pgoyette@
diffstat:
sys/dev/acpi/acpi_ec.c | 27 ++++++++-------------------
sys/dev/acpi/acpi_powerres.c | 36 +++++-------------------------------
sys/dev/acpi/acpi_tz.c | 25 ++++++-------------------
3 files changed, 19 insertions(+), 69 deletions(-)
diffs (156 lines):
diff -r 3bb85e4f1dd7 -r 64c417ae9f82 sys/dev/acpi/acpi_ec.c
--- a/sys/dev/acpi/acpi_ec.c Mon Jan 18 18:23:53 2010 +0000
+++ b/sys/dev/acpi/acpi_ec.c Mon Jan 18 18:36:49 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_ec.c,v 1.58 2010/01/08 20:40:41 dyoung Exp $ */
+/* $NetBSD: acpi_ec.c,v 1.59 2010/01/18 18:36:49 jruoho Exp $ */
/*-
* Copyright (c) 2007 Joerg Sonnenberger <joerg%NetBSD.org@localhost>.
@@ -59,7 +59,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_ec.c,v 1.58 2010/01/08 20:40:41 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_ec.c,v 1.59 2010/01/18 18:36:49 jruoho Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -459,27 +459,16 @@
}
c = &p->Package.Elements[0];
- switch (c->Type) {
- case ACPI_TYPE_LOCAL_REFERENCE:
- case ACPI_TYPE_ANY:
- *gpe_handle = c->Reference.Handle;
- break;
- case ACPI_TYPE_STRING:
- /* XXX should be using real scope here */
- rv = AcpiGetHandle(NULL, p->String.Pointer, gpe_handle);
- if (rv != AE_OK) {
- aprint_error_dev(self,
- "_GPE device reference unresolvable\n");
- ACPI_FREE(p);
- return false;
- }
- break;
- default:
- aprint_error_dev(self, "_GPE device reference incorrect\n");
+ rv = acpi_eval_reference_handle(c, gpe_handle);
+
+ if (ACPI_FAILURE(rv)) {
+ aprint_error_dev(self, "failed to evaluate _GPE handle\n");
ACPI_FREE(p);
return false;
}
+
c = &p->Package.Elements[1];
+
if (c->Type != ACPI_TYPE_INTEGER) {
aprint_error_dev(self,
"_GPE package needs integer as 2nd field\n");
diff -r 3bb85e4f1dd7 -r 64c417ae9f82 sys/dev/acpi/acpi_powerres.c
--- a/sys/dev/acpi/acpi_powerres.c Mon Jan 18 18:23:53 2010 +0000
+++ b/sys/dev/acpi/acpi_powerres.c Mon Jan 18 18:36:49 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_powerres.c,v 1.8 2010/01/05 13:39:49 jruoho Exp $ */
+/* $NetBSD: acpi_powerres.c,v 1.9 2010/01/18 18:36:50 jruoho Exp $ */
/*-
* Copyright (c) 2001 Michael Smith
@@ -29,7 +29,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_powerres.c,v 1.8 2010/01/05 13:39:49 jruoho Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_powerres.c,v 1.9 2010/01/18 18:36:50 jruoho Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@@ -487,36 +487,10 @@
ACPI_FUNCTION_TRACE(__func__);
- /* check the object type */
- switch (obj->Type) {
- case ACPI_TYPE_LOCAL_REFERENCE:
- case ACPI_TYPE_ANY:
- ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "building reference from %s to %s\n",
- acpi_name(pc->ac_consumer), acpi_name(obj->Reference.Handle)));
-
- res = obj->Reference.Handle;
- break;
+ status = acpi_eval_reference_handle(obj, &res);
- case ACPI_TYPE_STRING:
- ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS,
- "building reference from %s to %s\n",
- acpi_name(pc->ac_consumer),
- obj->String.Pointer));
-
- /* get the handle of the resource */
- status = AcpiGetHandle(NULL, obj->String.Pointer, &res);
- if (ACPI_FAILURE(status)) {
- ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS,
- "couldn't find power resource %s\n",
- obj->String.Pointer));
- return_ACPI_STATUS(AE_OK);
- }
- break;
-
- default:
- ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS,
- "don't know how to create a power reference to object type %d\n",
- obj->Type));
+ if (ACPI_FAILURE(status)) {
+ ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "failed to get handle\n"));
return_ACPI_STATUS(AE_OK);
}
diff -r 3bb85e4f1dd7 -r 64c417ae9f82 sys/dev/acpi/acpi_tz.c
--- a/sys/dev/acpi/acpi_tz.c Mon Jan 18 18:23:53 2010 +0000
+++ b/sys/dev/acpi/acpi_tz.c Mon Jan 18 18:36:49 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_tz.c,v 1.55 2010/01/18 17:09:17 jruoho Exp $ */
+/* $NetBSD: acpi_tz.c,v 1.56 2010/01/18 18:36:50 jruoho Exp $ */
/*
* Copyright (c) 2003 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_tz.c,v 1.55 2010/01/18 17:09:17 jruoho Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_tz.c,v 1.56 2010/01/18 18:36:50 jruoho Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -393,23 +393,10 @@
else
pwr_state = ACPI_STATE_D3;
- switch(obj->Type) {
- case ACPI_TYPE_LOCAL_REFERENCE:
- case ACPI_TYPE_ANY:
- cooler = obj->Reference.Handle;
- break;
- case ACPI_TYPE_STRING:
- rv = AcpiGetHandle(NULL, obj->String.Pointer, &cooler);
- if (ACPI_FAILURE(rv)) {
- aprint_error("%s: failed to get handler from %s\n",
- __func__, obj->String.Pointer);
- return rv;
- }
- break;
- default:
- aprint_error("%s: unknown power type: %u\n",
- __func__, obj->Type);
- return AE_OK;
+ rv = acpi_eval_reference_handle(obj, &cooler);
+ if (ACPI_FAILURE(rv)) {
+ aprint_error("%s: failed to get handle\n", __func__);
+ return rv;
}
rv = acpi_pwr_switch_consumer(cooler, pwr_state);
Home |
Main Index |
Thread Index |
Old Index