From patchwork Wed Apr 19 05:29:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 97601 Delivered-To: patch@linaro.org Received: by 10.140.109.52 with SMTP id k49csp159504qgf; Tue, 18 Apr 2017 22:32:10 -0700 (PDT) X-Received: by 10.99.115.30 with SMTP id o30mr1161083pgc.155.1492579930553; Tue, 18 Apr 2017 22:32:10 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f35si1321610plh.40.2017.04.18.22.32.10; Tue, 18 Apr 2017 22:32:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760043AbdDSFcI (ORCPT + 12 others); Wed, 19 Apr 2017 01:32:08 -0400 Received: from mail-pg0-f48.google.com ([74.125.83.48]:36785 "EHLO mail-pg0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760005AbdDSFbg (ORCPT ); Wed, 19 Apr 2017 01:31:36 -0400 Received: by mail-pg0-f48.google.com with SMTP id g2so7364269pge.3 for ; Tue, 18 Apr 2017 22:31:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=TYewOflp+ZgeCPWZpNGFTuIIdeUnYo2pm6AtvbKhHRY=; b=jXUtNX3PA4/ukMC6WD2oMA1JHs0guz6w2tSQtILmMoyKQhuQqECo/2EZyyPLyWMX/S hU3I5AVddsfZZ88Qx+d4s1fGopdVZjCTPTp6oSedrgXOr1Xg41hG3rRYLB/A9XHXf6GR MFRcnvjpHJNWvbXMD3OCe/84qsNNvg1oynbto= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=TYewOflp+ZgeCPWZpNGFTuIIdeUnYo2pm6AtvbKhHRY=; b=Sw/RWPaBYjcekTj51yg2prqE2lSKnnJSCmqd75nWPPjAeZqLDPyEAVkjsqd/4WYc4s amXD3S0dZhNOMP5ZNbwVGshqiKDMFg6wYdn3kZwgEzvJ1k649EmmNy6z+0EY+vOSRmeX GoCj71+OrJuSr7CSN2CzhLc/+Y9HbhQG9I/sLp3T2ZhsPP42p684el/b5OPjg5W3TWX4 BIYi8hRHwN24zPmfUI66nM68WNCPhyKleTgWHOPlNBeGaqa6Kvucc86wEPClHBk6/D3q 9V8KJ+nUWnq4V4d12GuJjsZvtj2mJ7PPWLFhJkUxm2TWcKEWSunfKTOOyaZ/mZO63DXv ritg== X-Gm-Message-State: AN3rC/4+xZAgj7NdBC5y8daGY95g+4zSUMu338x5OOcyhsiPxLoJmT0t oyAbniGaVhrQbVX7 X-Received: by 10.98.201.72 with SMTP id k69mr1218189pfg.74.1492579890324; Tue, 18 Apr 2017 22:31:30 -0700 (PDT) Received: from localhost ([122.172.121.5]) by smtp.gmail.com with ESMTPSA id j125sm1660073pgc.53.2017.04.18.22.31.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 18 Apr 2017 22:31:29 -0700 (PDT) From: Viresh Kumar To: Javi Merino , Zhang Rui , Eduardo Valentin , Lukasz Luba , Amit Daniel Kachhap , Viresh Kumar Cc: linaro-kernel@lists.linaro.org, Rafael Wysocki , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Vincent Guittot , Punit Agrawal Subject: [PATCH V3 15/17] thermal: cpu_cooling: don't store cpu_dev in cpufreq_cdev Date: Wed, 19 Apr 2017 10:59:10 +0530 Message-Id: <6b094de5e95d0d9c0d699a91fdb50847b379b955.1492579345.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.12.0.432.g71c3a4f4ba37 In-Reply-To: References: In-Reply-To: References: Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org 'cpu_dev' is used by only one function, get_static_power(), and it wouldn't be time consuming to get the cpu device structure within it. This would help removing cpu_dev from struct cpufreq_cooling_device. Signed-off-by: Viresh Kumar --- drivers/thermal/cpu_cooling.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) -- 2.12.0.432.g71c3a4f4ba37 diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index 762ddfc4e654..c85b217d16c8 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -87,7 +87,6 @@ struct time_in_idle { * @node: list_head to link all cpufreq_cooling_device together. * @last_load: load measured by the latest call to cpufreq_get_requested_power() * @idle_time: idle time stats - * @cpu_dev: the cpu_device of policy->cpu. * @plat_get_static_power: callback to calculate the static power * * This structure is required for keeping information of each registered @@ -104,7 +103,6 @@ struct cpufreq_cooling_device { struct list_head node; u32 last_load; struct time_in_idle *idle_time; - struct device *cpu_dev; get_static_t plat_get_static_power; }; @@ -255,8 +253,6 @@ static int update_freq_table(struct cpufreq_cooling_device *cpufreq_cdev, freq_table[i].power = power; } - cpufreq_cdev->cpu_dev = dev; - return 0; } @@ -338,19 +334,22 @@ static int get_static_power(struct cpufreq_cooling_device *cpufreq_cdev, { struct dev_pm_opp *opp; unsigned long voltage; - struct cpumask *cpumask = cpufreq_cdev->policy->related_cpus; + struct cpufreq_policy *policy = cpufreq_cdev->policy; + struct cpumask *cpumask = policy->related_cpus; unsigned long freq_hz = freq * 1000; + struct device *dev; - if (!cpufreq_cdev->plat_get_static_power || !cpufreq_cdev->cpu_dev) { + if (!cpufreq_cdev->plat_get_static_power) { *power = 0; return 0; } - opp = dev_pm_opp_find_freq_exact(cpufreq_cdev->cpu_dev, freq_hz, - true); + dev = get_cpu_device(policy->cpu); + WARN_ON(!dev); + + opp = dev_pm_opp_find_freq_exact(dev, freq_hz, true); if (IS_ERR(opp)) { - dev_warn_ratelimited(cpufreq_cdev->cpu_dev, - "Failed to find OPP for frequency %lu: %ld\n", + dev_warn_ratelimited(dev, "Failed to find OPP for frequency %lu: %ld\n", freq_hz, PTR_ERR(opp)); return -EINVAL; } @@ -359,8 +358,7 @@ static int get_static_power(struct cpufreq_cooling_device *cpufreq_cdev, dev_pm_opp_put(opp); if (voltage == 0) { - dev_err_ratelimited(cpufreq_cdev->cpu_dev, - "Failed to get voltage for frequency %lu\n", + dev_err_ratelimited(dev, "Failed to get voltage for frequency %lu\n", freq_hz); return -EINVAL; }