svn commit: r267983 - in stable: 10/sys/dev/acpica 9/sys/dev/acpica
John Baldwin
jhb at FreeBSD.org
Fri Jun 27 20:57:13 UTC 2014
Author: jhb
Date: Fri Jun 27 20:57:12 2014
New Revision: 267983
URL: http://svnweb.freebsd.org/changeset/base/267983
Log:
MFC 267647:
Trust the state of a power resource that we get from a working _STA method
instead of trying to cache it.
Modified:
stable/9/sys/dev/acpica/acpi_powerres.c
Directory Properties:
stable/9/sys/ (props changed)
stable/9/sys/dev/ (props changed)
Changes in other areas also in this revision:
Modified:
stable/10/sys/dev/acpica/acpi_powerres.c
Directory Properties:
stable/10/ (props changed)
Modified: stable/9/sys/dev/acpica/acpi_powerres.c
==============================================================================
--- stable/9/sys/dev/acpica/acpi_powerres.c Fri Jun 27 20:45:17 2014 (r267982)
+++ stable/9/sys/dev/acpica/acpi_powerres.c Fri Jun 27 20:57:12 2014 (r267983)
@@ -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 r
}
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)));
}
More information about the svn-src-stable-9
mailing list