From patchwork Wed Apr 4 20:12:48 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 7646 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id E94D823E47 for ; Wed, 4 Apr 2012 20:13:22 +0000 (UTC) Received: from mail-gy0-f180.google.com (mail-gy0-f180.google.com [209.85.160.180]) by fiordland.canonical.com (Postfix) with ESMTP id B8C2AA189CA for ; Wed, 4 Apr 2012 20:13:22 +0000 (UTC) Received: by mail-gy0-f180.google.com with SMTP id z12so544217ghb.11 for ; Wed, 04 Apr 2012 13:13:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=fr+IrEj6R06KBg9P8Jbf8LIFIWD/WkZ8K/f64zm7Se0=; b=eGxIgvuJKNmlY8ZcbE4BdrrOcsVvN2Vncq55QPcjusZHfQZdYtlvfXGM1NIgodkdNd Lb4cYcMmewhzlRU31T3Zytj0mQLdLKl7burLg43PTuXCH3e4lKCZUEeMNrkNhKrZplH9 kmuEz1T9i0ddgpQrBeLAb6IeJjoWeqIM2W9eFRjoxFnqutClynFw8Q7WReWhmvWrej6k EIyN/9iAZS9z6wXKxNN3tiWqb/vTaYT73rSfs666WamW3Z9CHcTWYg5hvpuQjbQKgsgo QdvEqUbo/qkF9i8YMU/dwYkb4wFJpQZ8Gq2vgsR4c6NeU2T9ne2VtIQPTG/UMeNMZ06J fzwg== Received: by 10.50.51.197 with SMTP id m5mr2838001igo.38.1333570402342; Wed, 04 Apr 2012 13:13:22 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.164.217 with SMTP id f25csp56489iby; Wed, 4 Apr 2012 13:13:21 -0700 (PDT) Received: by 10.213.13.195 with SMTP id d3mr49221eba.55.1333570400986; Wed, 04 Apr 2012 13:13:20 -0700 (PDT) Received: from mail-wg0-f50.google.com (mail-wg0-f50.google.com [74.125.82.50]) by mx.google.com with ESMTPS id b5si3520588wix.10.2012.04.04.13.13.20 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 04 Apr 2012 13:13:20 -0700 (PDT) Received-SPF: neutral (google.com: 74.125.82.50 is neither permitted nor denied by best guess record for domain of daniel.lezcano@linaro.org) client-ip=74.125.82.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 74.125.82.50 is neither permitted nor denied by best guess record for domain of daniel.lezcano@linaro.org) smtp.mail=daniel.lezcano@linaro.org Received: by mail-wg0-f50.google.com with SMTP id ds12so645094wgb.31 for ; Wed, 04 Apr 2012 13:13:20 -0700 (PDT) Received: by 10.216.144.223 with SMTP id n73mr1165470wej.65.1333570400369; Wed, 04 Apr 2012 13:13:20 -0700 (PDT) Received: from localhost.localdomain (AToulouse-159-1-7-136.w90-60.abo.wanadoo.fr. [90.60.242.136]) by mx.google.com with ESMTPS id gd4sm6869495wib.6.2012.04.04.13.13.18 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 04 Apr 2012 13:13:19 -0700 (PDT) From: Daniel Lezcano To: santosh.shilimkar@ti.com, jean.pihet@newoldbits.com, khilman@ti.com, tony@atomide.com Cc: linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org, rob.lee@linaro.org, linaro-dev@lists.linaro.org, patches@linaro.org Subject: [PATCH 14/17][V2] ARM: OMAP3 : cpuidle - simplify next_valid_state Date: Wed, 4 Apr 2012 22:12:48 +0200 Message-Id: <1333570371-1389-15-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1333570371-1389-1-git-send-email-daniel.lezcano@linaro.org> References: <1333570371-1389-1-git-send-email-daniel.lezcano@linaro.org> X-Gm-Message-State: ALoCoQl60hKz3scga/rOx2jHk07sspc1l16q9gaK+HsjGUf2fKRNB3vs7t6Bkn4orX7d4iKtFVyn 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 Reviewed-by: Jean Pihet --- arch/arm/mach-omap2/cpuidle34xx.c | 53 +++++++++++++----------------------- 1 files changed, 19 insertions(+), 34 deletions(-) diff --git a/arch/arm/mach-omap2/cpuidle34xx.c b/arch/arm/mach-omap2/cpuidle34xx.c index e4738eb..35a1471 100644 --- a/arch/arm/mach-omap2/cpuidle34xx.c +++ b/arch/arm/mach-omap2/cpuidle34xx.c @@ -174,13 +174,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) { @@ -196,42 +195,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 = OMAP3_NUM_STATES - 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; }