Skip to content

Commit

Permalink
ARM: OMAP3: cpuidle - simplify next_valid_state
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Daniel Lezcano authored and Kevin Hilman committed May 3, 2012
1 parent 6622ac5 commit e92a458
Showing 1 changed file with 19 additions and 34 deletions.
53 changes: 19 additions & 34 deletions arch/arm/mach-omap2/cpuidle34xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,12 @@ static inline int omap3_enter_idle(struct cpuidle_device *dev,
* if it satisfies the enable_off_mode condition.
*/
static int next_valid_state(struct cpuidle_device *dev,
struct cpuidle_driver *drv,
int index)
struct cpuidle_driver *drv, int index)
{
struct cpuidle_state *curr = &drv->states[index];
struct omap3_idle_statedata *cx = &omap3_idle_data[index];
u32 mpu_deepest_state = PWRDM_POWER_RET;
u32 core_deepest_state = PWRDM_POWER_RET;
int idx;
int next_index = -1;

if (enable_off_mode) {
Expand All @@ -194,42 +193,28 @@ static int next_valid_state(struct cpuidle_device *dev,

/* Check if current state is valid */
if ((cx->mpu_state >= mpu_deepest_state) &&
(cx->core_state >= core_deepest_state)) {
(cx->core_state >= core_deepest_state))
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.
* Start search from the next (lower) state.
*/
idx--;
for (; idx >= 0; idx--) {
cx = &omap3_idle_data[idx];
if ((cx->mpu_state >= mpu_deepest_state) &&
(cx->core_state >= core_deepest_state)) {
next_index = idx;
break;
}
/*
* Drop to next valid state.
* Start search from the next (lower) state.
*/
for (idx = index - 1; idx >= 0; idx--) {
cx = &omap3_idle_data[idx];
if ((cx->mpu_state >= mpu_deepest_state) &&
(cx->core_state >= core_deepest_state)) {
next_index = idx;
break;
}
/*
* C1 is always valid.
* So, no need to check for 'next_index == -1' outside
* this loop.
*/
}

/*
* C1 is always valid.
* So, no need to check for 'next_index == -1' outside
* this loop.
*/

return next_index;
}

Expand Down

0 comments on commit e92a458

Please sign in to comment.