Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 117281
b: refs/heads/master
c: a51e145
h: refs/heads/master
i:
  117279: 68e3a8e
v: v3
  • Loading branch information
Zhao Yakui authored and Len Brown committed Oct 22, 2008
1 parent 4121be8 commit 129a030
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 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: 08237974af22a97da59869979ef1a515524d5cc3
refs/heads/master: a51e145f379ae48003129610922595893e8efde0
30 changes: 16 additions & 14 deletions trunk/drivers/acpi/power.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,45 +128,47 @@ acpi_power_get_context(acpi_handle handle,
return 0;
}

static int acpi_power_get_state(struct acpi_power_resource *resource, int *state)
static int acpi_power_get_state(acpi_handle handle, int *state)
{
acpi_status status = AE_OK;
unsigned long sta = 0;


if (!resource || !state)
if (!handle || !state)
return -EINVAL;

status = acpi_evaluate_integer(resource->device->handle, "_STA", NULL, &sta);
status = acpi_evaluate_integer(handle, "_STA", NULL, &sta);
if (ACPI_FAILURE(status))
return -ENODEV;

*state = (sta & 0x01)?ACPI_POWER_RESOURCE_STATE_ON:
ACPI_POWER_RESOURCE_STATE_OFF;

ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] is %s\n",
resource->name, state ? "on" : "off"));
acpi_ut_get_node_name(handle), state ? "on" : "off"));

return 0;
}

static int acpi_power_get_list_state(struct acpi_handle_list *list, int *state)
{
int result = 0, state1;
struct acpi_power_resource *resource = NULL;
u32 i = 0;


if (!list || !state)
return -EINVAL;

/* The state of the list is 'on' IFF all resources are 'on'. */
/* */

for (i = 0; i < list->count; i++) {
result = acpi_power_get_context(list->handles[i], &resource);
if (result)
return result;
result = acpi_power_get_state(resource, &state1);
/*
* The state of the power resource can be obtained by
* using the ACPI handle. In such case it is unnecessary to
* get the Power resource first and then get its state again.
*/
result = acpi_power_get_state(list->handles[i], &state1);
if (result)
return result;

Expand Down Expand Up @@ -226,7 +228,7 @@ static int acpi_power_on(acpi_handle handle, struct acpi_device *dev)
if (ACPI_FAILURE(status))
return -ENODEV;

result = acpi_power_get_state(resource, &state);
result = acpi_power_get_state(resource->device->handle, &state);
if (result)
return result;
if (state != ACPI_POWER_RESOURCE_STATE_ON)
Expand Down Expand Up @@ -277,7 +279,7 @@ static int acpi_power_off_device(acpi_handle handle, struct acpi_device *dev)
if (ACPI_FAILURE(status))
return -ENODEV;

result = acpi_power_get_state(resource, &state);
result = acpi_power_get_state(handle, &state);
if (result)
return result;
if (state != ACPI_POWER_RESOURCE_STATE_OFF)
Expand Down Expand Up @@ -555,7 +557,7 @@ static int acpi_power_seq_show(struct seq_file *seq, void *offset)
if (!resource)
goto end;

result = acpi_power_get_state(resource, &state);
result = acpi_power_get_state(resource->device->handle, &state);
if (result)
goto end;

Expand Down Expand Up @@ -668,7 +670,7 @@ static int acpi_power_add(struct acpi_device *device)
resource->system_level = acpi_object.power_resource.system_level;
resource->order = acpi_object.power_resource.resource_order;

result = acpi_power_get_state(resource, &state);
result = acpi_power_get_state(device->handle, &state);
if (result)
goto end;

Expand Down Expand Up @@ -735,7 +737,7 @@ static int acpi_power_resume(struct acpi_device *device)

resource = (struct acpi_power_resource *)acpi_driver_data(device);

result = acpi_power_get_state(resource, &state);
result = acpi_power_get_state(device->handle, &state);
if (result)
return result;

Expand Down
1 change: 1 addition & 0 deletions trunk/drivers/acpi/scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,7 @@ static int acpi_bus_get_power_flags(struct acpi_device *device)
/* TBD: System wake support and resource requirements. */

device->power.state = ACPI_STATE_UNKNOWN;
acpi_bus_get_power(device->handle, &(device->power.state));

return 0;
}
Expand Down

0 comments on commit 129a030

Please sign in to comment.