Skip to content

Commit

Permalink
ACPI / PM: Check device state before refcounting power resources
Browse files Browse the repository at this point in the history
Commit 3e384ee (ACPI / PM: Fix
reference counting of power resources) introduced a regression by
causing fan power resources to be turned on and reference counted
unnecessarily during resume, so on some boxes fans are always on
after resume.

Fix the problem by checking if the current device state is different
from the new state before reference counting and turning on power
resources in acpi_power_transition().

Addresses https://bugzilla.kernel.org/show_bug.cgi?id=22932 .

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Reported-and-tested-by: Maciej Rutecki <maciej.rutecki@gmail.com>
Signed-off-by: Len Brown <len.brown@intel.com>
  • Loading branch information
Rafael J. Wysocki authored and Len Brown committed Dec 1, 2010
1 parent e8a7e48 commit 212967c
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions drivers/acpi/power.c
Original file line number Diff line number Diff line change
Expand Up @@ -465,10 +465,12 @@ int acpi_power_transition(struct acpi_device *device, int state)
struct acpi_handle_list *tl = NULL; /* Target Resources */
int i = 0;


if (!device || (state < ACPI_STATE_D0) || (state > ACPI_STATE_D3))
return -EINVAL;

if (device->power.state == state)
return 0;

if ((device->power.state < ACPI_STATE_D0)
|| (device->power.state > ACPI_STATE_D3))
return -ENODEV;
Expand All @@ -488,10 +490,6 @@ int acpi_power_transition(struct acpi_device *device, int state)
goto end;
}

if (device->power.state == state) {
goto end;
}

/*
* Then we dereference all power resources used in the current list.
*/
Expand Down

0 comments on commit 212967c

Please sign in to comment.