Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 310434
b: refs/heads/master
c: 63a1a76
h: refs/heads/master
v: v3
  • Loading branch information
Rafael J. Wysocki committed May 29, 2012
1 parent d47f431 commit 0e80f73
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 10 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: b2201e5482bc2376ea5c049442850a260142ac40
refs/heads/master: 63a1a765dffb1e59d82c7948638e56d5f4f2e3a1
37 changes: 28 additions & 9 deletions trunk/drivers/acpi/bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,24 @@ EXPORT_SYMBOL(acpi_bus_get_private_data);
Power Management
-------------------------------------------------------------------------- */

static const char *state_string(int state)
{
switch (state) {
case ACPI_STATE_D0:
return "D0";
case ACPI_STATE_D1:
return "D1";
case ACPI_STATE_D2:
return "D2";
case ACPI_STATE_D3_HOT:
return "D3hot";
case ACPI_STATE_D3_COLD:
return "D3";
default:
return "(unknown)";
}
}

static int __acpi_bus_get_power(struct acpi_device *device, int *state)
{
int result = 0;
Expand Down Expand Up @@ -215,8 +233,8 @@ static int __acpi_bus_get_power(struct acpi_device *device, int *state)
device->parent->power.state : ACPI_STATE_D0;
}

ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] power state is D%d\n",
device->pnp.bus_id, *state));
ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] power state is %s\n",
device->pnp.bus_id, state_string(*state)));

return 0;
}
Expand All @@ -234,13 +252,14 @@ static int __acpi_bus_set_power(struct acpi_device *device, int state)
/* Make sure this is a valid target state */

if (state == device->power.state) {
ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device is already at D%d\n",
state));
ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device is already at %s\n",
state_string(state)));
return 0;
}

if (!device->power.states[state].flags.valid) {
printk(KERN_WARNING PREFIX "Device does not support D%d\n", state);
printk(KERN_WARNING PREFIX "Device does not support %s\n",
state_string(state));
return -ENODEV;
}
if (device->parent && (state < device->parent->power.state)) {
Expand Down Expand Up @@ -294,13 +313,13 @@ static int __acpi_bus_set_power(struct acpi_device *device, int state)
end:
if (result)
printk(KERN_WARNING PREFIX
"Device [%s] failed to transition to D%d\n",
device->pnp.bus_id, state);
"Device [%s] failed to transition to %s\n",
device->pnp.bus_id, state_string(state));
else {
device->power.state = state;
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
"Device [%s] transitioned to D%d\n",
device->pnp.bus_id, state));
"Device [%s] transitioned to %s\n",
device->pnp.bus_id, state_string(state)));
}

return result;
Expand Down

0 comments on commit 0e80f73

Please sign in to comment.