summaryrefslogtreecommitdiffstats
path: root/sys/dev/acpica
diff options
context:
space:
mode:
authornjl <njl@FreeBSD.org>2004-06-07 21:39:15 +0000
committernjl <njl@FreeBSD.org>2004-06-07 21:39:15 +0000
commitd04844812ea9d1a27f4e9d3895341dc308b909c5 (patch)
treee6f2f2aa47f9e9e17bcf3afb68e799c6d91327eb /sys/dev/acpica
parentc18972f0f67d9ba4a57c2bbed07ebf67761e31a4 (diff)
downloadFreeBSD-src-d04844812ea9d1a27f4e9d3895341dc308b909c5.zip
FreeBSD-src-d04844812ea9d1a27f4e9d3895341dc308b909c5.tar.gz
Avoid printing extraneous warning messages when trying to switch a device
which doesn't support ACPI power states. Return AE_NOT_FOUND for these cases and don't print the warning message. Also, print the name of the handle instead of device when unable to switch states. The device is often not attached at this point and so its name is NULL, which doesn't help debugging.
Diffstat (limited to 'sys/dev/acpica')
-rw-r--r--sys/dev/acpica/acpi_pci.c15
-rw-r--r--sys/dev/acpica/acpi_powerres.c19
2 files changed, 17 insertions, 17 deletions
diff --git a/sys/dev/acpica/acpi_pci.c b/sys/dev/acpica/acpi_pci.c
index ae12318..9c133e1 100644
--- a/sys/dev/acpica/acpi_pci.c
+++ b/sys/dev/acpica/acpi_pci.c
@@ -193,15 +193,12 @@ acpi_pci_set_powerstate_method(device_t dev, device_t child, int state)
if (error)
return (error);
}
- h = acpi_get_handle(child);
- if (h != NULL) {
- status = acpi_pwr_switch_consumer(h, acpi_state);
- if (ACPI_FAILURE(status))
- device_printf(dev,
- "Failed to set ACPI power state D%d on %s: %s\n",
- acpi_state, device_get_nameunit(child),
- AcpiFormatException(status));
- }
+ h = acpi_get_handle(dev);
+ status = acpi_pwr_switch_consumer(h, acpi_state);
+ if (ACPI_FAILURE(status) && status != AE_NOT_FOUND)
+ device_printf(dev,
+ "Failed to set ACPI power state D%d on %s: %s\n",
+ acpi_state, acpi_name(h), AcpiFormatException(status));
if (old_state > state)
return (pci_set_powerstate_method(dev, child, state));
else
diff --git a/sys/dev/acpica/acpi_powerres.c b/sys/dev/acpica/acpi_powerres.c
index 73c20f2..943a0bf 100644
--- a/sys/dev/acpica/acpi_powerres.c
+++ b/sys/dev/acpica/acpi_powerres.c
@@ -326,7 +326,7 @@ acpi_pwr_switch_consumer(ACPI_HANDLE consumer, int state)
return_ACPI_STATUS (AE_BAD_PARAMETER); /* can only go to D0 from D3 */
/* Find transition mechanism(s) */
- switch(state) {
+ switch (state) {
case ACPI_STATE_D0:
method_name = "_PS0";
reslist_name = "_PR0";
@@ -359,6 +359,7 @@ acpi_pwr_switch_consumer(ACPI_HANDLE consumer, int state)
* support D0 and D3. It's never an error to try to go to
* D0.
*/
+ status = AE_BAD_PARAMETER;
reslist_buffer.Pointer = NULL;
reslist_object = NULL;
if (ACPI_FAILURE(AcpiGetHandle(consumer, method_name, &method_handle)))
@@ -373,19 +374,22 @@ acpi_pwr_switch_consumer(ACPI_HANDLE consumer, int state)
if (state != ACPI_STATE_D3)
goto bad;
- /* Turn off the resources listed in _PR0 to go to D3. */
- if (ACPI_FAILURE(AcpiGetHandle(consumer, "_PR0", &pr0_handle)))
+ /*
+ * Turn off the resources listed in _PR0 to go to D3. If there is
+ * no _PR0 method, this object doesn't support ACPI power states.
+ */
+ if (ACPI_FAILURE(AcpiGetHandle(consumer, "_PR0", &pr0_handle))) {
+ status = AE_NOT_FOUND;
goto bad;
+ }
reslist_buffer.Length = ACPI_ALLOCATE_BUFFER;
status = AcpiEvaluateObject(pr0_handle, NULL, NULL, &reslist_buffer);
if (ACPI_FAILURE(status))
goto bad;
reslist_object = (ACPI_OBJECT *)reslist_buffer.Pointer;
if (reslist_object->Type != ACPI_TYPE_PACKAGE ||
- reslist_object->Package.Count == 0) {
-
+ reslist_object->Package.Count == 0)
goto bad;
- }
AcpiOsFree(reslist_buffer.Pointer);
reslist_buffer.Pointer = NULL;
reslist_object = NULL;
@@ -419,7 +423,7 @@ acpi_pwr_switch_consumer(ACPI_HANDLE consumer, int state)
* resource references.
*/
res_changed = 0;
- while((pr = TAILQ_FIRST(&pc->ac_references)) != NULL) {
+ while ((pr = TAILQ_FIRST(&pc->ac_references)) != NULL) {
res_changed = 1;
ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "removing reference to %s\n",
acpi_name(pr->ar_resource->ap_resource)));
@@ -477,7 +481,6 @@ acpi_pwr_switch_consumer(ACPI_HANDLE consumer, int state)
bad:
ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS,
"attempt to set unsupported state D%d\n", state));
- status = AE_BAD_PARAMETER;
out:
if (reslist_buffer.Pointer != NULL)
OpenPOWER on IntegriCloud