summaryrefslogtreecommitdiffstats
path: root/sys/dev
diff options
context:
space:
mode:
authornjl <njl@FreeBSD.org>2004-11-29 18:48:51 +0000
committernjl <njl@FreeBSD.org>2004-11-29 18:48:51 +0000
commit2c704c1c939caaef42aee39e95af9f73ee1f2729 (patch)
tree0c677e1b9726f2551aae635e8d17986c47379587 /sys/dev
parentbe0be8707bee5e412ddea81ae8c0494a9eef9054 (diff)
downloadFreeBSD-src-2c704c1c939caaef42aee39e95af9f73ee1f2729.zip
FreeBSD-src-2c704c1c939caaef42aee39e95af9f73ee1f2729.tar.gz
Instead of translating PCI to ACPI power states, just use a CTASSERT
that they are equivalent.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/acpica/acpi_pci.c28
1 files changed, 10 insertions, 18 deletions
diff --git a/sys/dev/acpica/acpi_pci.c b/sys/dev/acpica/acpi_pci.c
index a3856e1..ad51129 100644
--- a/sys/dev/acpica/acpi_pci.c
+++ b/sys/dev/acpica/acpi_pci.c
@@ -59,6 +59,12 @@ struct acpi_pci_devinfo {
ACPI_SERIAL_DECL(pci_powerstate, "ACPI PCI power methods");
+/* Be sure that ACPI and PCI power states are equivalent. */
+CTASSERT(ACPI_STATE_D0 == PCI_POWERSTATE_D0);
+CTASSERT(ACPI_STATE_D1 == PCI_POWERSTATE_D1);
+CTASSERT(ACPI_STATE_D2 == PCI_POWERSTATE_D2);
+CTASSERT(ACPI_STATE_D3 == PCI_POWERSTATE_D3);
+
static int acpi_pci_attach(device_t dev);
static int acpi_pci_child_location_str_method(device_t cbdev,
device_t child, char *buf, size_t buflen);
@@ -183,25 +189,11 @@ acpi_pci_set_powerstate_method(device_t dev, device_t child, int state)
{
ACPI_HANDLE h;
ACPI_STATUS status;
- int acpi_state, old_state, error;
+ int old_state, error;
error = 0;
- switch (state) {
- case PCI_POWERSTATE_D0:
- acpi_state = ACPI_STATE_D0;
- break;
- case PCI_POWERSTATE_D1:
- acpi_state = ACPI_STATE_D1;
- break;
- case PCI_POWERSTATE_D2:
- acpi_state = ACPI_STATE_D2;
- break;
- case PCI_POWERSTATE_D3:
- acpi_state = ACPI_STATE_D3;
- break;
- default:
+ if (state < ACPI_STATE_D0 || state > ACPI_STATE_D3)
return (EINVAL);
- }
/*
* We set the state using PCI Power Management outside of setting
@@ -220,11 +212,11 @@ acpi_pci_set_powerstate_method(device_t dev, device_t child, int state)
goto out;
}
h = acpi_get_handle(child);
- status = acpi_pwr_switch_consumer(h, acpi_state);
+ status = acpi_pwr_switch_consumer(h, 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));
+ state, acpi_name(h), AcpiFormatException(status));
if (old_state > state)
error = pci_set_powerstate_method(dev, child, state);
OpenPOWER on IntegriCloud