Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 350942
b: refs/heads/master
c: 660b111
h: refs/heads/master
v: v3
  • Loading branch information
Rafael J. Wysocki committed Jan 25, 2013
1 parent 6aa0ab6 commit 8fc5fd4
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 12 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: 18a387099b3e3fd901cc706f708b163aa45347b6
refs/heads/master: 660b1113e0f33a476952cb2cbcb5c9831e7ff4cd
37 changes: 26 additions & 11 deletions trunk/drivers/acpi/power.c
Original file line number Diff line number Diff line change
Expand Up @@ -299,9 +299,22 @@ static int acpi_power_on(struct acpi_power_resource *resource)
return result;
}

static int __acpi_power_off(struct acpi_power_resource *resource)
{
acpi_status status;

status = acpi_evaluate_object(resource->device.handle, "_OFF",
NULL, NULL);
if (ACPI_FAILURE(status))
return -ENODEV;

ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Power resource [%s] turned off\n",
resource->name));
return 0;
}

static int acpi_power_off(struct acpi_power_resource *resource)
{
acpi_status status = AE_OK;
int result = 0;

mutex_lock(&resource->resource_lock);
Expand All @@ -317,17 +330,12 @@ static int acpi_power_off(struct acpi_power_resource *resource)
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
"Power resource [%s] still in use\n",
resource->name));
goto unlock;
} else {
result = __acpi_power_off(resource);
if (result)
resource->ref_count++;
}

status = acpi_evaluate_object(resource->device.handle, "_OFF", NULL, NULL);
if (ACPI_FAILURE(status))
result = -ENODEV;
else
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
"Power resource [%s] turned off\n",
resource->name));

unlock:
mutex_unlock(&resource->resource_lock);

Expand Down Expand Up @@ -851,10 +859,17 @@ void acpi_resume_power_resources(void)
mutex_lock(&resource->resource_lock);

result = acpi_power_get_state(resource->device.handle, &state);
if (!result && state == ACPI_POWER_RESOURCE_STATE_OFF
if (result)
continue;

if (state == ACPI_POWER_RESOURCE_STATE_OFF
&& resource->ref_count) {
dev_info(&resource->device.dev, "Turning ON\n");
__acpi_power_on(resource);
} else if (state == ACPI_POWER_RESOURCE_STATE_ON
&& !resource->ref_count) {
dev_info(&resource->device.dev, "Turning OFF\n");
__acpi_power_off(resource);
}

mutex_unlock(&resource->resource_lock);
Expand Down

0 comments on commit 8fc5fd4

Please sign in to comment.