ARM: OMAP3: cpuidle - simplify next_valid_state

Simplify the indentation by removing the useless 'else' statement.
Remove the first loop for the 'idx' search as we have it already
with the 'index' passed as parameter.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Reviewed-by: Jean Pihet <j-pihet@ti.com>
Reviewed-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
Tested-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
Tested-by: Kevin Hilman <khilman@ti.com>
Signed-off-by: Kevin Hilman <khilman@ti.com>
This commit is contained in:
Daniel Lezcano 2012-04-24 16:05:36 +02:00 committed by Kevin Hilman
parent 6622ac55a6
commit e92a458681
1 changed files with 19 additions and 34 deletions

View File

@ -172,13 +172,12 @@ static inline int omap3_enter_idle(struct cpuidle_device *dev,
* if it satisfies the enable_off_mode condition. * if it satisfies the enable_off_mode condition.
*/ */
static int next_valid_state(struct cpuidle_device *dev, static int next_valid_state(struct cpuidle_device *dev,
struct cpuidle_driver *drv, struct cpuidle_driver *drv, int index)
int index)
{ {
struct cpuidle_state *curr = &drv->states[index];
struct omap3_idle_statedata *cx = &omap3_idle_data[index]; struct omap3_idle_statedata *cx = &omap3_idle_data[index];
u32 mpu_deepest_state = PWRDM_POWER_RET; u32 mpu_deepest_state = PWRDM_POWER_RET;
u32 core_deepest_state = PWRDM_POWER_RET; u32 core_deepest_state = PWRDM_POWER_RET;
int idx;
int next_index = -1; int next_index = -1;
if (enable_off_mode) { if (enable_off_mode) {
@ -194,28 +193,14 @@ static int next_valid_state(struct cpuidle_device *dev,
/* Check if current state is valid */ /* Check if current state is valid */
if ((cx->mpu_state >= mpu_deepest_state) && if ((cx->mpu_state >= mpu_deepest_state) &&
(cx->core_state >= core_deepest_state)) { (cx->core_state >= core_deepest_state))
return index; return index;
} else {
int idx = ARRAY_SIZE(omap3_idle_data) - 1;
/* Reach the current state starting at highest C-state */
for (; idx >= 0; idx--) {
if (&drv->states[idx] == curr) {
next_index = idx;
break;
}
}
/* Should never hit this condition */
WARN_ON(next_index == -1);
/* /*
* Drop to next valid state. * Drop to next valid state.
* Start search from the next (lower) state. * Start search from the next (lower) state.
*/ */
idx--; for (idx = index - 1; idx >= 0; idx--) {
for (; idx >= 0; idx--) {
cx = &omap3_idle_data[idx]; cx = &omap3_idle_data[idx];
if ((cx->mpu_state >= mpu_deepest_state) && if ((cx->mpu_state >= mpu_deepest_state) &&
(cx->core_state >= core_deepest_state)) { (cx->core_state >= core_deepest_state)) {
@ -223,12 +208,12 @@ static int next_valid_state(struct cpuidle_device *dev,
break; break;
} }
} }
/* /*
* C1 is always valid. * C1 is always valid.
* So, no need to check for 'next_index == -1' outside * So, no need to check for 'next_index == -1' outside
* this loop. * this loop.
*/ */
}
return next_index; return next_index;
} }