Only try to set the ACPI power state if the handle is valid. There was

probably no problem with this except it may have had the side effect of
registering a NULL consumer.
This commit is contained in:
Nate Lawson 2004-04-14 17:46:21 +00:00
parent 95ee367419
commit 916dc0e20c
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=128247

View File

@ -162,6 +162,7 @@ acpi_pci_child_location_str_method(device_t cbdev, device_t child, char *buf,
static int
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;
@ -197,12 +198,15 @@ acpi_pci_set_powerstate_method(device_t dev, device_t child, int state)
if (error)
return (error);
}
status = acpi_pwr_switch_consumer(acpi_get_handle(child), 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(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));
}
if (state > old_state)
return (pci_set_powerstate_method(dev, child, state));
else