From patchwork Tue Oct 16 11:44:47 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hongbo Zhang X-Patchwork-Id: 12275 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 35DAD214A95 for ; Tue, 16 Oct 2012 11:46:43 +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 88623A1996E for ; Tue, 16 Oct 2012 11:46:42 +0000 (UTC) Received: by mail-ie0-f180.google.com with SMTP id e10so9294192iej.11 for ; Tue, 16 Oct 2012 04:46:42 -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=g3oOPhs0FKOf4mHjesLiy1aQcpQe6Wj3ecZ7LJN24/Q=; b=pzkjgp+zJc66/d4g62twxEo/11yLnBw/2NcMWjnbwSRJMnbGJ80UfC5bGmSSvm1gVw mVen6ZV6t+kTd+wxzLGgxhnE71VyZL8Oou1cPod1gzUtAPZUOA29KMNustyraCTf0afM mC7q4iXJjSp/IqkPGOnxjNf0nL4dgdcWO35SR8+XoGtcWbZgQBEje10MzfnMUm385XO0 U1ptrzzKZ6hP6Frp6iBTgpoG5JJpPaKLGIw3UvVS/VTvpabj1bEuY2SE9YvHkgxrXVe5 CFRlfkLvtc6ZfgVz/RLrwykrcl5nBAXM/0wbdtamzjDr0/8FqX+3w4xuEps+j9/TzOy7 pKYw== Received: by 10.50.194.169 with SMTP id hx9mr2846011igc.70.1350388002309; Tue, 16 Oct 2012 04:46:42 -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 n20csp714085igt; Tue, 16 Oct 2012 04:46:41 -0700 (PDT) Received: by 10.68.230.232 with SMTP id tb8mr46200151pbc.19.1350388001774; Tue, 16 Oct 2012 04:46:41 -0700 (PDT) Received: from mail-pa0-f50.google.com (mail-pa0-f50.google.com [209.85.220.50]) by mx.google.com with ESMTPS id c5si26017677paz.157.2012.10.16.04.46.41 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 16 Oct 2012 04:46:41 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.50 is neither permitted nor denied by best guess record for domain of hongbo.zhang@linaro.org) client-ip=209.85.220.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.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-pa0-f50.google.com with SMTP id hz11so6474153pad.37 for ; Tue, 16 Oct 2012 04:46:41 -0700 (PDT) Received: by 10.68.130.198 with SMTP id og6mr45696517pbb.163.1350388001554; Tue, 16 Oct 2012 04:46:41 -0700 (PDT) Received: from stebjsxu0148.bjs.st.com ([124.127.135.94]) by mx.google.com with ESMTPS id pv9sm10667709pbb.67.2012.10.16.04.46.33 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 16 Oct 2012 04:46:41 -0700 (PDT) From: "hongbo.zhang" To: linaro-dev@lists.linaro.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org Cc: patches@linaro.org, linaro-kernel@lists.linaro.org, STEricsson_nomadik_linux@list.st.com, kernel@igloocommunity.org, "hongbo.zhang" Subject: [PATCH 3/5] Thermal: fix empty list checking method. Date: Tue, 16 Oct 2012 19:44:47 +0800 Message-Id: <1350387889-15324-4-git-send-email-hongbo.zhang@linaro.com> X-Mailer: git-send-email 1.7.11.3 In-Reply-To: <1350387889-15324-1-git-send-email-hongbo.zhang@linaro.com> References: <1350387889-15324-1-git-send-email-hongbo.zhang@linaro.com> X-Gm-Message-State: ALoCoQmQ+fo1Gwim28gnmwV7oWgHAJDa/IyFGU8OGATSra+a1lbgDjqz1idF8BgRaEtWtB69hnqX From: "hongbo.zhang" Is is not reliable to check the list entry pointer after list_for_each_entry loop, list_empty should be used instead. Signed-off-by: hongbo.zhang Reviewed-by: Viresh Kumar --- drivers/thermal/cpu_cooling.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index b6b4c2a..d196230 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -247,12 +247,13 @@ static int cpufreq_get_max_state(struct thermal_cooling_device *cdev, struct cpufreq_frequency_table *table; mutex_lock(&cooling_cpufreq_lock); + if (list_empty(&cooling_cpufreq_list)) + goto return_get_max_state; + list_for_each_entry(cpufreq_device, &cooling_cpufreq_list, node) { if (cpufreq_device && cpufreq_device->cool_dev == cdev) break; } - if (cpufreq_device == NULL) - goto return_get_max_state; maskPtr = &cpufreq_device->allowed_cpus; cpu = cpumask_any(maskPtr);