Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 350932
b: refs/heads/master
c: 9c0f45e
h: refs/heads/master
v: v3
  • Loading branch information
Rafael J. Wysocki committed Jan 22, 2013
1 parent 6171ea8 commit 8f1bb0d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 29 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: a2367807b8d2c0aca5afb92fead2537dcd3d10b0
refs/heads/master: 9c0f45e388fb9f9003ea22f98b84ffbab65ba554
51 changes: 23 additions & 28 deletions trunk/drivers/acpi/device_pm.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,19 @@ int acpi_device_get_power(struct acpi_device *device, int *state)
return 0;
}

static int acpi_dev_pm_explicit_set(struct acpi_device *adev, int state)
{
if (adev->power.states[state].flags.explicit_set) {
char method[5] = { '_', 'P', 'S', '0' + state, '\0' };
acpi_status status;

status = acpi_evaluate_object(adev->handle, method, NULL, NULL);
if (ACPI_FAILURE(status))
return -ENODEV;
}
return 0;
}

/**
* acpi_device_set_power - Set power state of an ACPI device.
* @device: Device to set the power state of.
Expand All @@ -197,8 +210,6 @@ int acpi_device_get_power(struct acpi_device *device, int *state)
int acpi_device_set_power(struct acpi_device *device, int state)
{
int result = 0;
acpi_status status = AE_OK;
char object_name[5] = { '_', 'P', 'S', '0' + state, '\0' };
bool cut_power = false;

if (!device || (state < ACPI_STATE_D0) || (state > ACPI_STATE_D3_COLD))
Expand Down Expand Up @@ -228,7 +239,6 @@ int acpi_device_set_power(struct acpi_device *device, int state)
if (state == ACPI_STATE_D3_COLD
&& device->power.states[ACPI_STATE_D3_COLD].flags.os_accessible) {
state = ACPI_STATE_D3_HOT;
object_name[3] = '3';
cut_power = true;
}

Expand All @@ -251,23 +261,14 @@ int acpi_device_set_power(struct acpi_device *device, int state)
if (result)
goto end;
}
if (device->power.states[state].flags.explicit_set) {
status = acpi_evaluate_object(device->handle,
object_name, NULL, NULL);
if (ACPI_FAILURE(status)) {
result = -ENODEV;
goto end;
}
}
result = acpi_dev_pm_explicit_set(device, state);
if (result)
goto end;
} else {
if (device->power.states[state].flags.explicit_set) {
status = acpi_evaluate_object(device->handle,
object_name, NULL, NULL);
if (ACPI_FAILURE(status)) {
result = -ENODEV;
goto end;
}
}
result = acpi_dev_pm_explicit_set(device, state);
if (result)
goto end;

if (device->power.flags.power_resources) {
result = acpi_power_transition(device, state);
if (result)
Expand Down Expand Up @@ -335,15 +336,9 @@ int acpi_bus_init_power(struct acpi_device *device)
if (result)
return result;

if (device->power.states[state].flags.explicit_set) {
char method[5] = { '_', 'P', 'S', '0' + state, '\0' };
acpi_status status;

status = acpi_evaluate_object(device->handle, method,
NULL, NULL);
if (ACPI_FAILURE(status))
return -ENODEV;
}
result = acpi_dev_pm_explicit_set(device, state);
if (result)
return result;
}
device->power.state = state;
return 0;
Expand Down

0 comments on commit 8f1bb0d

Please sign in to comment.