From patchwork Wed Feb 6 04:30:05 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhang, Rui" X-Patchwork-Id: 2101631 X-Patchwork-Delegate: rui.zhang@intel.com Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 631C5DFE75 for ; Wed, 6 Feb 2013 04:30:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757013Ab3BFEaT (ORCPT ); Tue, 5 Feb 2013 23:30:19 -0500 Received: from mga02.intel.com ([134.134.136.20]:19511 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757000Ab3BFEaT (ORCPT ); Tue, 5 Feb 2013 23:30:19 -0500 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP; 05 Feb 2013 20:30:18 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.84,612,1355126400"; d="scan'208";a="281525730" Received: from unknown (HELO rzhang1-mobl4.ccr.corp.intel.com) ([10.255.20.57]) by orsmga002.jf.intel.com with ESMTP; 05 Feb 2013 20:30:16 -0800 From: Zhang Rui To: linux-pm@vger.kernel.org Cc: amit.daniel@samsung.com, gu1@aeroxteam.fr, hongbo.zhang@linaro.org, Zhang Rui Subject: [PATCH 4/5] Thermal: Get max cpu cooling states via cpu cooling table Date: Wed, 6 Feb 2013 12:30:05 +0800 Message-Id: <1360125006-25018-5-git-send-email-rui.zhang@intel.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1360125006-25018-1-git-send-email-rui.zhang@intel.com> References: <1360125006-25018-1-git-send-email-rui.zhang@intel.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Signed-off-by: Zhang Rui --- drivers/thermal/cpu_cooling.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index 57bb669..784be30 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -277,26 +277,22 @@ static int cpufreq_get_max_state(struct thermal_cooling_device *cdev, { struct cpufreq_cooling_device *cpufreq_device = cdev->devdata; struct cpumask *maskPtr = &cpufreq_device->allowed_cpus; - unsigned int cpu; struct cpufreq_frequency_table *table; - unsigned long count = 0; + unsigned int cpu; int i = 0; cpu = cpumask_any(maskPtr); - table = cpufreq_frequency_get_table(cpu); - if (!table) { - *state = 0; - return 0; - } + table = get_cpu_cooling_table(cpu); + if (IS_ERR(table)) + return -EINVAL; - for (i = 0; (table[i].frequency != CPUFREQ_TABLE_END); i++) { - if (table[i].frequency == CPUFREQ_ENTRY_INVALID) - continue; - count++; - } + while (table[i].frequency != CPUFREQ_TABLE_END) + i++; + + kfree(table); - if (count > 0) { - *state = --count; + if (i > 0) { + *state = --i; return 0; }