diff options
author | njl <njl@FreeBSD.org> | 2004-04-09 06:55:50 +0000 |
---|---|---|
committer | njl <njl@FreeBSD.org> | 2004-04-09 06:55:50 +0000 |
commit | 6c09d371b9306fe75463ad7af1b0a27ea13c8a51 (patch) | |
tree | e76f978793ddc11823c5adc2c8b545396bd2fae4 | |
parent | 2c8ba3e867635eb4b515d463795e90d9031e5c79 (diff) | |
download | FreeBSD-src-6c09d371b9306fe75463ad7af1b0a27ea13c8a51.zip FreeBSD-src-6c09d371b9306fe75463ad7af1b0a27ea13c8a51.tar.gz |
Replace more ad-hoc versions of acpi_GetReference(). Since the type of
Reference objects changed from ACPI_TYPE_ANY to ACPI_TYPE_LOCAL_REFERENCE
in Oct. 2002, this may help systems where switching the cooler on failed.
We support both types for now until this sorts out.
-rw-r--r-- | sys/dev/acpica/acpi_powerres.c | 26 | ||||
-rw-r--r-- | sys/dev/acpica/acpi_thermal.c | 95 |
2 files changed, 31 insertions, 90 deletions
diff --git a/sys/dev/acpica/acpi_powerres.c b/sys/dev/acpica/acpi_powerres.c index a0d8eb7..7bbcc01 100644 --- a/sys/dev/acpica/acpi_powerres.c +++ b/sys/dev/acpica/acpi_powerres.c @@ -488,30 +488,10 @@ acpi_pwr_reference_resource(ACPI_OBJECT *obj, void *arg) ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); - /* check the object type */ - switch (obj->Type) { - 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; - 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_VOID; - } - break; - default: + res = acpi_GetReference(NULL, obj); + if (res == NULL) { ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, - "can't create a power reference for object type %d\n", + "can't create a power reference for object type %d\n", obj->Type)); return_VOID; } diff --git a/sys/dev/acpica/acpi_thermal.c b/sys/dev/acpica/acpi_thermal.c index c539a4e..2dfc435 100644 --- a/sys/dev/acpica/acpi_thermal.c +++ b/sys/dev/acpica/acpi_thermal.c @@ -550,38 +550,27 @@ acpi_tz_all_off(struct acpi_tz_softc *sc) static void acpi_tz_switch_cooler_off(ACPI_OBJECT *obj, void *arg) { - ACPI_HANDLE cooler; + struct acpi_tz_softc *sc = (struct acpi_tz_softc *)arg; + ACPI_HANDLE cooler; + ACPI_STATUS status; ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); ACPI_ASSERTLOCK; - switch(obj->Type) { - case ACPI_TYPE_ANY: - ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "called to turn %s off\n", - acpi_name(obj->Reference.Handle))); + cooler = acpi_GetReference(NULL, obj); + if (cooler == NULL) { + ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "can't get handle\n")); + return_VOID; + } - acpi_pwr_switch_consumer(obj->Reference.Handle, ACPI_STATE_D3); - break; - case ACPI_TYPE_STRING: - ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "called to turn %s off\n", - obj->String.Pointer)); - - /* - * Find the handle for the device and turn it off. - * The String object here seems to contain a fully-qualified path, so we - * don't have to search for it in our parents. - * - * XXX This may not always be the case. - */ - if (ACPI_SUCCESS(AcpiGetHandle(NULL, obj->String.Pointer, &cooler))) - acpi_pwr_switch_consumer(cooler, ACPI_STATE_D3); - break; - default: - ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, - "called to handle unsupported object type %d\n", - obj->Type)); - break; + ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "called to turn %s off\n", + acpi_name(cooler))); + status = acpi_pwr_switch_consumer(cooler, ACPI_STATE_D3); + if (ACPI_FAILURE(status)) { + ACPI_VPRINT(sc->tz_dev, acpi_device_get_parent_softc(sc->tz_dev), + "failed to deactivate %s - %s\n", acpi_name(cooler), + AcpiFormatException(status)); } return_VOID; @@ -591,7 +580,7 @@ acpi_tz_switch_cooler_off(ACPI_OBJECT *obj, void *arg) * Given an object, verify that it's a reference to a device of some sort, * and try to switch it on. * - * XXX replication of off/on function code is bad, mmmkay? + * XXX replication of off/on function code is bad. */ static void acpi_tz_switch_cooler_on(ACPI_OBJECT *obj, void *arg) @@ -604,47 +593,19 @@ acpi_tz_switch_cooler_on(ACPI_OBJECT *obj, void *arg) ACPI_ASSERTLOCK; - switch(obj->Type) { - case ACPI_TYPE_ANY: - ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "called to turn %s on\n", - acpi_name(obj->Reference.Handle))); + cooler = acpi_GetReference(NULL, obj); + if (cooler == NULL) { + ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "can't get handle\n")); + return_VOID; + } - status = acpi_pwr_switch_consumer(obj->Reference.Handle, ACPI_STATE_D0); - if (ACPI_FAILURE(status)) { - ACPI_VPRINT(sc->tz_dev, acpi_device_get_parent_softc(sc->tz_dev), - "failed to activate %s - %s\n", - acpi_name(obj->Reference.Handle), - AcpiFormatException(status)); - } - break; - case ACPI_TYPE_STRING: - ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "called to turn %s on\n", - obj->String.Pointer)); - - /* - * Find the handle for the device and turn it off. - * The String object here seems to contain a fully-qualified path, so we - * don't have to search for it in our parents. - * - * XXX This may not always be the case. - */ - if (ACPI_SUCCESS(AcpiGetHandle(NULL, obj->String.Pointer, &cooler))) { - status = acpi_pwr_switch_consumer(cooler, ACPI_STATE_D0); - if (ACPI_FAILURE(status)) { - ACPI_VPRINT(sc->tz_dev, - acpi_device_get_parent_softc(sc->tz_dev), - "failed to activate %s - %s\n", - obj->String.Pointer, AcpiFormatException(status)); - } - } else { - ACPI_VPRINT(sc->tz_dev, acpi_device_get_parent_softc(sc->tz_dev), - "couldn't find %s\n", obj->String.Pointer); - } - break; - default: - ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "unsupported object type %d\n", - obj->Type)); - break; + ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "called to turn %s on\n", + acpi_name(cooler))); + status = acpi_pwr_switch_consumer(cooler, ACPI_STATE_D0); + if (ACPI_FAILURE(status)) { + ACPI_VPRINT(sc->tz_dev, acpi_device_get_parent_softc(sc->tz_dev), + "failed to activate %s - %s\n", acpi_name(cooler), + AcpiFormatException(status)); } return_VOID; |