MFC 267647:

Trust the state of a power resource that we get from a working _STA method
instead of trying to cache it.
This commit is contained in:
jhb 2014-06-27 20:57:12 +00:00
parent 6af57d4a5e
commit 7a51d55007

View File

@ -64,7 +64,6 @@ ACPI_MODULE_NAME("POWERRES")
/* Return values from _STA on a power resource */
#define ACPI_PWR_OFF 0
#define ACPI_PWR_ON 1
#define ACPI_PWR_UNK (-1)
/* A relationship between a power resource and a consumer. */
struct acpi_powerreference {
@ -90,7 +89,6 @@ struct acpi_powerresource {
ACPI_HANDLE ap_resource;
UINT64 ap_systemlevel;
UINT64 ap_order;
int ap_state;
};
static TAILQ_HEAD(acpi_powerresource_list, acpi_powerresource)
@ -173,7 +171,6 @@ acpi_pwr_register_resource(ACPI_HANDLE res)
}
rp->ap_systemlevel = obj->PowerResource.SystemLevel;
rp->ap_order = obj->PowerResource.ResourceOrder;
rp->ap_state = ACPI_PWR_UNK;
/* Sort the resource into the list */
status = AE_OK;
@ -638,22 +635,20 @@ acpi_pwr_switch_power(void)
continue;
}
/* We could cache this if we trusted it not to change under us */
status = acpi_GetInteger(rp->ap_resource, "_STA", &cur);
if (ACPI_FAILURE(status)) {
ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "can't get status of %s - %d\n",
acpi_name(rp->ap_resource), status));
/* XXX is this correct? Always switch if in doubt? */
continue;
} else if (rp->ap_state == ACPI_PWR_UNK)
rp->ap_state = cur;
}
/*
* Switch if required. Note that we ignore the result of the switch
* effort; we don't know what to do if it fails, so checking wouldn't
* help much.
*/
if (rp->ap_state != ACPI_PWR_ON) {
if (cur != ACPI_PWR_ON) {
status = AcpiEvaluateObject(rp->ap_resource, "_ON", NULL, NULL);
if (ACPI_FAILURE(status)) {
ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS,
@ -661,7 +656,6 @@ acpi_pwr_switch_power(void)
acpi_name(rp->ap_resource),
AcpiFormatException(status)));
} else {
rp->ap_state = ACPI_PWR_ON;
ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "switched %s on\n",
acpi_name(rp->ap_resource)));
}
@ -682,22 +676,20 @@ acpi_pwr_switch_power(void)
continue;
}
/* We could cache this if we trusted it not to change under us */
status = acpi_GetInteger(rp->ap_resource, "_STA", &cur);
if (ACPI_FAILURE(status)) {
ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "can't get status of %s - %d\n",
acpi_name(rp->ap_resource), status));
/* XXX is this correct? Always switch if in doubt? */
continue;
} else if (rp->ap_state == ACPI_PWR_UNK)
rp->ap_state = cur;
}
/*
* Switch if required. Note that we ignore the result of the switch
* effort; we don't know what to do if it fails, so checking wouldn't
* help much.
*/
if (rp->ap_state != ACPI_PWR_OFF) {
if (cur != ACPI_PWR_OFF) {
status = AcpiEvaluateObject(rp->ap_resource, "_OFF", NULL, NULL);
if (ACPI_FAILURE(status)) {
ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS,
@ -705,7 +697,6 @@ acpi_pwr_switch_power(void)
acpi_name(rp->ap_resource),
AcpiFormatException(status)));
} else {
rp->ap_state = ACPI_PWR_OFF;
ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "switched %s off\n",
acpi_name(rp->ap_resource)));
}