From patchwork Tue Apr 24 14:05:36 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 8084 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 5D1CC23E1D for ; Tue, 24 Apr 2012 14:06:12 +0000 (UTC) Received: from mail-iy0-f180.google.com (mail-iy0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id 2711BA1895C for ; Tue, 24 Apr 2012 14:06:12 +0000 (UTC) Received: by mail-iy0-f180.google.com with SMTP id e36so1457668iag.11 for ; Tue, 24 Apr 2012 07:06:12 -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=x6VG+KGK4w0PcFYRtmA/tPdSwEhcthvdBeV3errXQ2c=; b=hJt81lN2GfcJHaLyiOZG/Ht8SC61jsp/kuMYZH3DfhdR1x/sl1YD5bSbYktLYUppsc uFi1f1CH3bzNxvG71L0Pk5fUKbyGcv3JcDhT7x3guUdaP4wk747sazTLz79fLySwmXb2 zcPwnrao+Menfln958iuKd6clCrnbMXalk+TPgmNBSGjxZMuD9w5/zHyGPB0yq/TTuZP eLOFtxzKzFehgWzUMY+OGJOl+0HpEY1e8LL0W75kXc6OXTHspByLlXbR7WNu8rTX6K/C jwGT7drT5C3dO72/fsRZu5iISB1k461AnG442Z0M1G36NvrU7ZJEau1vlHYkyRTZpvzK rz+A== Received: by 10.50.154.167 with SMTP id vp7mr10275306igb.55.1335276371903; Tue, 24 Apr 2012 07:06:11 -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.137.198 with SMTP id x6csp184010ibt; Tue, 24 Apr 2012 07:06:11 -0700 (PDT) Received: by 10.180.81.135 with SMTP id a7mr31785187wiy.16.1335276370218; Tue, 24 Apr 2012 07:06:10 -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 bt8si13302092wib.40.2012.04.24.07.06.09 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 24 Apr 2012 07:06:10 -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 ds12so684920wgb.31 for ; Tue, 24 Apr 2012 07:06:09 -0700 (PDT) Received: by 10.180.107.104 with SMTP id hb8mr31566590wib.8.1335276369782; Tue, 24 Apr 2012 07:06:09 -0700 (PDT) Received: from localhost.localdomain (AToulouse-159-1-17-225.w92-134.abo.wanadoo.fr. [92.134.64.225]) by mx.google.com with ESMTPS id fl2sm47121222wib.2.2012.04.24.07.06.08 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 24 Apr 2012 07:06:09 -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, linaro-dev@lists.linaro.org, linux-arm-kernel@lists.infradead.org, patches@linaro.org Subject: [PATCH 15/18][V3] ARM: OMAP3: cpuidle - simplify next_valid_state Date: Tue, 24 Apr 2012 16:05:36 +0200 Message-Id: <1335276339-11135-16-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1335276339-11135-1-git-send-email-daniel.lezcano@linaro.org> References: <1335276339-11135-1-git-send-email-daniel.lezcano@linaro.org> X-Gm-Message-State: ALoCoQniE46N5UBfhRKLed1fCFE/UUeIug8fuub23grigvadfL13s9fJ7lFIQJt/Zi8MSixrAirl 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 242f77d..e7599e7 100644 --- a/arch/arm/mach-omap2/cpuidle34xx.c +++ b/arch/arm/mach-omap2/cpuidle34xx.c @@ -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) { @@ -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; }