From patchwork Wed Apr 4 09:42:16 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 7611 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 90AED23E4C for ; Wed, 4 Apr 2012 09:42:47 +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 53EEBA1801E for ; Wed, 4 Apr 2012 09:42:47 +0000 (UTC) Received: by mail-iy0-f180.google.com with SMTP id e36so109604iag.11 for ; Wed, 04 Apr 2012 02:42:47 -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=VSBLFNctm0nuJYZCWjTxXT9Ioplw0/gusxnWOKiLYOc=; b=Jol/m+/qOKwMQjF0PcfLO852U0No/rj8mjd3wCAyJ8WXiIwQCHB1KNxFST4Ufbjehv dvhCFiQHfW8TOtnL3ntjBU57H8o3FpTITo2OaaP+SJ4UQQor40QKSwQ3TKQMPKEAFsgZ vLIKUjz4X9wHvHbeQc51AJzOm3OhThazoc8c5DBfvH/woGYKSad9ZEG1wAprNKj/qCSs tLX+1gsimkZ3E4+UFxlZ2McakegLwyioqk5e8xfq9lU5634vTX3+U/bxTAm/lWad9Dgq ol5EJkruox87uFri8+3Jm7U7ohWeWXWytIbfFEsgeeviTjOzjo2zZzj7iIDy0680Dz0J MYyQ== Received: by 10.50.173.35 with SMTP id bh3mr920071igc.38.1333532567130; Wed, 04 Apr 2012 02:42:47 -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 f25csp31261iby; Wed, 4 Apr 2012 02:42:46 -0700 (PDT) Received: by 10.180.20.47 with SMTP id k15mr3610570wie.19.1333532565838; Wed, 04 Apr 2012 02:42:45 -0700 (PDT) Received: from mail-we0-f178.google.com (mail-we0-f178.google.com [74.125.82.178]) by mx.google.com with ESMTPS id u74si113573weq.74.2012.04.04.02.42.45 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 04 Apr 2012 02:42:45 -0700 (PDT) Received-SPF: neutral (google.com: 74.125.82.178 is neither permitted nor denied by best guess record for domain of daniel.lezcano@linaro.org) client-ip=74.125.82.178; Authentication-Results: mx.google.com; spf=neutral (google.com: 74.125.82.178 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-we0-f178.google.com with SMTP id a13so62988wer.37 for ; Wed, 04 Apr 2012 02:42:45 -0700 (PDT) Received: by 10.180.94.33 with SMTP id cz1mr3664237wib.13.1333532565401; Wed, 04 Apr 2012 02:42:45 -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 bx13sm3462265wib.10.2012.04.04.02.42.44 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 04 Apr 2012 02:42:44 -0700 (PDT) From: Daniel Lezcano To: tony@atomide.com, khilman@ti.com Cc: j-pihet@ti.com, santosh.shilimkar@ti.com, rob.lee@linaro.org, linaro-dev@lists.linaro.org, patches@linaro.org Subject: [PATCH 14/17] ARM: OMAP3 : cpuidle - simplify next_valid_state Date: Wed, 4 Apr 2012 11:42:16 +0200 Message-Id: <1333532539-10298-15-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1333532539-10298-1-git-send-email-daniel.lezcano@linaro.org> References: <1333532539-10298-1-git-send-email-daniel.lezcano@linaro.org> X-Gm-Message-State: ALoCoQktY40NIttPlXGbgxjEX8LYhHYdeWjWD7DbaJU5sq3v9F2mEt7FWaHeEaCMhx8GiBREcnpK 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 --- 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; }