[PATCH 2/2] cpuidle: Initialize power_usage for all C-states

From: Thomas Schlichter
Date: Sat Jan 12 2013 - 09:30:43 EST


By now, only the power_usage values of currently available C-states are
initialized in the function set_power_states(). But if the number of C-states
increases later (e.g. when using acpi_idle and unplugging the AC power from the
laptop) the power_usage values of the new C-states stay uninitialized.

Fix this by initializing all CPUIDLE_STATE_MAX C-stages in the first place.

Signed-off-by: Thomas Schlichter <thomas.schlichter@xxxxxx>
---
drivers/cpuidle/driver.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/cpuidle/driver.c b/drivers/cpuidle/driver.c
index c2b281a..960d98d 100644
--- a/drivers/cpuidle/driver.c
+++ b/drivers/cpuidle/driver.c
@@ -37,7 +37,7 @@ static void set_power_states(struct cpuidle_driver *drv)
* an power value of -1. So we use -2, -3, etc, for other
* c-states.
*/
- for (i = CPUIDLE_DRIVER_STATE_START; i < drv->state_count; i++)
+ for (i = CPUIDLE_DRIVER_STATE_START; i < CPUIDLE_STATE_MAX; i++)
drv->states[i].power_usage = -1 - i;
}

--
1.7.10.4

--nextPart1794952.WA51hkzRQo--

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/