1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-25 11:37:56 +00:00

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.
This commit is contained in:
Nate Lawson 2004-04-09 06:55:50 +00:00
parent 4a74bb97ed
commit aa95c5b148
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=128047
2 changed files with 31 additions and 90 deletions

View File

@ -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;
}

View File

@ -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;