From patchwork Tue Oct 30 16:48:58 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hongbo Zhang X-Patchwork-Id: 12595 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 0474423EF7 for ; Tue, 30 Oct 2012 16:50:01 +0000 (UTC) Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by fiordland.canonical.com (Postfix) with ESMTP id 7DF11A18502 for ; Tue, 30 Oct 2012 16:50:00 +0000 (UTC) Received: by mail-ie0-f180.google.com with SMTP id e10so688763iej.11 for ; Tue, 30 Oct 2012 09:50:00 -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=AzGBQ23jl0wFyKEHey5PqdgLIieRnJr66f68FH6Un48=; b=F57Q5FqFa5QO7FKN+vGdendcHZv+UT9dLZRMwGCy95S21pJTACVj/PA0JwTg/F5LcX fQxlCAeNIVWYmZD+1GCHptxXuOq50I8GD57aw5Xqc+ZlHWA7NM9NBPb/sJIw5BHCz24K 06Pdxp5H6bRHpvL3bMgEe5cLs7n+8lVrqsd+p0EiqnQOX5pNPwxsQ0ymNrU06SEBxcJu 3bjQ3c1mdqUYrDr7URGz1t7RsdcxOZ5b8SKcJFTVutGuq+e5iqwsZKqT3rc813IbfYn2 HrO0axHSU1C4Fz/NhDtdRwrksU9qjENABnMLItd6qhHePrP4yDXGL/nnP8rEc1trTVTO gwVQ== Received: by 10.42.57.10 with SMTP id b10mr29215384ich.54.1351615800267; Tue, 30 Oct 2012 09:50:00 -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.50.67.148 with SMTP id n20csp448792igt; Tue, 30 Oct 2012 09:49:59 -0700 (PDT) Received: by 10.204.6.17 with SMTP id 17mr10200271bkx.129.1351615799024; Tue, 30 Oct 2012 09:49:59 -0700 (PDT) Received: from mail-bk0-f50.google.com (mail-bk0-f50.google.com [209.85.214.50]) by mx.google.com with ESMTPS id hs7si1723269bkc.18.2012.10.30.09.49.58 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 30 Oct 2012 09:49:59 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.214.50 is neither permitted nor denied by best guess record for domain of hongbo.zhang@linaro.org) client-ip=209.85.214.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.214.50 is neither permitted nor denied by best guess record for domain of hongbo.zhang@linaro.org) smtp.mail=hongbo.zhang@linaro.org Received: by mail-bk0-f50.google.com with SMTP id q16so298514bkw.37 for ; Tue, 30 Oct 2012 09:49:58 -0700 (PDT) Received: by 10.204.148.21 with SMTP id n21mr10613870bkv.124.1351615798318; Tue, 30 Oct 2012 09:49:58 -0700 (PDT) Received: from localhost.localdomain ([91.224.175.20]) by mx.google.com with ESMTPS id v14sm1673891bkv.10.2012.10.30.09.49.56 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 30 Oct 2012 09:49:57 -0700 (PDT) From: "hongbo.zhang" To: linaro-dev@lists.linaro.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, rui.zhang@intel.com, amit.kachhap@linaro.org Cc: patches@linaro.org, linaro-kernel@lists.linaro.org, STEricsson_nomadik_linux@list.st.com, kernel@igloocommunity.org, "hongbo.zhang" Subject: [PATCH V3 2/5] Thermal: fix bug of counting cpu frequencies. Date: Tue, 30 Oct 2012 17:48:58 +0100 Message-Id: <1351615741-24134-3-git-send-email-hongbo.zhang@linaro.com> X-Mailer: git-send-email 1.7.11.3 In-Reply-To: <1351615741-24134-1-git-send-email-hongbo.zhang@linaro.com> References: <1351079900-32236-1-git-send-email-hongbo.zhang@linaro.com> <1351615741-24134-1-git-send-email-hongbo.zhang@linaro.com> X-Gm-Message-State: ALoCoQkC60KaUJvG9K2APyJsgQ3isuPfSGmdLS6TaqQE/9jHd1eW/r+aFKERS10Spd30n4QdpmI5 From: "hongbo.zhang" In the while loop for counting cpu frequencies, if table[i].frequency equals CPUFREQ_ENTRY_INVALID, index i won't be increased, so this leads to an endless loop, what's more the index i cannot be referred as cpu frequencies number if there is CPUFREQ_ENTRY_INVALID case. Signed-off-by: hongbo.zhang Reviewed-by: Viresh Kumar Reviewed-by: Amit Daniel Kachhap --- drivers/thermal/cpu_cooling.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index b6b4c2a..bfd62b7 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -245,6 +245,7 @@ static int cpufreq_get_max_state(struct thermal_cooling_device *cdev, struct cpumask *maskPtr; unsigned int cpu; struct cpufreq_frequency_table *table; + unsigned long count = 0; mutex_lock(&cooling_cpufreq_lock); list_for_each_entry(cpufreq_device, &cooling_cpufreq_list, node) { @@ -263,13 +264,14 @@ static int cpufreq_get_max_state(struct thermal_cooling_device *cdev, goto return_get_max_state; } - while (table[i].frequency != CPUFREQ_TABLE_END) { + for (i = 0; (table[i].frequency != CPUFREQ_TABLE_END); i++) { if (table[i].frequency == CPUFREQ_ENTRY_INVALID) continue; - i++; + count++; } - if (i > 0) { - *state = --i; + + if (count > 0) { + *state = --count; ret = 0; }