From patchwork Thu Mar 16 05:29:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 95383 Delivered-To: patch@linaro.org Received: by 10.140.89.134 with SMTP id v6csp660844qgd; Wed, 15 Mar 2017 22:31:09 -0700 (PDT) X-Received: by 10.84.129.67 with SMTP id 61mr9858150plb.16.1489642269424; Wed, 15 Mar 2017 22:31:09 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d2si2965884pfk.113.2017.03.15.22.31.09; Wed, 15 Mar 2017 22:31:09 -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 S1751787AbdCPFa6 (ORCPT + 13 others); Thu, 16 Mar 2017 01:30:58 -0400 Received: from mail-pg0-f45.google.com ([74.125.83.45]:36202 "EHLO mail-pg0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751286AbdCPFa4 (ORCPT ); Thu, 16 Mar 2017 01:30:56 -0400 Received: by mail-pg0-f45.google.com with SMTP id g2so19548198pge.3 for ; Wed, 15 Mar 2017 22:30:51 -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=SUCE7hhGNTwZbcdP8Jf8Sn1cZJamsaSV6A82ICsj63U=; b=Sycr/gUMrJMvKn3c5WTBiMYeXCapaAWyTZkCprd7gkkKHDk0Va0M2JBv5CIiaNLC4v 0sS/hNLMgxSRfYvH/Bw4oVd/aKaDTLq7VGULm6ERQwNdysiWMabYofa9Fg1+suKeQNUt +2F9GybXZEApr4zrCt04auRsMmVLDe8AECzcg= 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=SUCE7hhGNTwZbcdP8Jf8Sn1cZJamsaSV6A82ICsj63U=; b=UY6KzGsjokf+X63r9fBcslE0QMYOVmRGgKcQfCi4ltjzoLSJlC2TMEGsRNDLrYCoZ/ lCVR/Iwd0zC3qrFP97SbW7humXe8OnmJnh6A8+kEjRMQxnoOHsw6fx1AdYTAaxC78VzW yKzKVox7etu18rWQWfxQHvkEiMqKU9zkTRljsp3PVNJI6O2LNCmH38KsxBu0EsnDNn8H QyqVGMoghA7sKtrfLhCmapYKgR6NUt+YR8q1pWR1+lzw0nQpPrt/1NNqnBU6obformbJ hS6dYwv337Hv+xisYptLcgtERpM+op5MH/bcndwgM4QMmn3rHRremc774yLFzAbpK70p wnkg== X-Gm-Message-State: AFeK/H3WoPAcZxbm5xhQKNcGjPwVrwV6ZBmzKKbonyFsdts7rnyleDTaRJCRb8AYIavZOaBt X-Received: by 10.99.241.21 with SMTP id f21mr7855117pgi.16.1489642245575; Wed, 15 Mar 2017 22:30:45 -0700 (PDT) Received: from localhost ([122.171.239.200]) by smtp.gmail.com with ESMTPSA id u69sm7400606pfg.121.2017.03.15.22.30.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Mar 2017 22:30:44 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki , Javi Merino , Zhang Rui , Eduardo Valentin , Amit Daniel Kachhap , Viresh Kumar Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Vincent Guittot Subject: [PATCH 15/17] thermal: cpu_cooling: don't store cpu_dev in cpufreq_dev Date: Thu, 16 Mar 2017 10:59:50 +0530 Message-Id: X-Mailer: git-send-email 2.7.1.410.g6faf27b 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.7.1.410.g6faf27b diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index fd84802d2e8e..fb535fd5aa12 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; }; @@ -256,8 +254,6 @@ static int update_freq_table(struct cpufreq_cooling_device *cpufreq_dev, freq_table[i].power = power; } - cpufreq_dev->cpu_dev = dev; - return 0; } @@ -339,19 +335,22 @@ static int get_static_power(struct cpufreq_cooling_device *cpufreq_dev, { struct dev_pm_opp *opp; unsigned long voltage; - struct cpumask *cpumask = cpufreq_dev->policy->related_cpus; + struct cpufreq_policy *policy = cpufreq_dev->policy; + struct cpumask *cpumask = policy->related_cpus; unsigned long freq_hz = freq * 1000; + struct device *dev; - if (!cpufreq_dev->plat_get_static_power || !cpufreq_dev->cpu_dev) { + if (!cpufreq_dev->plat_get_static_power) { *power = 0; return 0; } - opp = dev_pm_opp_find_freq_exact(cpufreq_dev->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_dev->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; } @@ -360,8 +359,7 @@ static int get_static_power(struct cpufreq_cooling_device *cpufreq_dev, dev_pm_opp_put(opp); if (voltage == 0) { - dev_err_ratelimited(cpufreq_dev->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; }