From patchwork Mon Apr 17 06:02:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 97504 Delivered-To: patch@linaro.org Received: by 10.140.109.52 with SMTP id k49csp1212768qgf; Sun, 16 Apr 2017 23:03:56 -0700 (PDT) X-Received: by 10.84.218.2 with SMTP id q2mr13871940pli.141.1492409036771; Sun, 16 Apr 2017 23:03:56 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g26si10020227pge.96.2017.04.16.23.03.56; Sun, 16 Apr 2017 23:03:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 S933011AbdDQGDo (ORCPT + 14 others); Mon, 17 Apr 2017 02:03:44 -0400 Received: from mail-pf0-f174.google.com ([209.85.192.174]:36509 "EHLO mail-pf0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932993AbdDQGDf (ORCPT ); Mon, 17 Apr 2017 02:03:35 -0400 Received: by mail-pf0-f174.google.com with SMTP id 194so22274297pfv.3 for ; Sun, 16 Apr 2017 23:03: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=3b5/gFGu1T1cUj/XIJu+OysWJ2RKOCNAhxQzWVf19nk=; b=atUcdKEJdtGkMDqVx88kaA2r6WjsjA460XTHD34FptMlICxyoJAL8nTMZmaOqVz8tQ hjPKhTzvy3r1r9z1YJM3jRAACBDySZ5eMCqEU5wH/c7EWtkUB81ggHWgzxlV7mpyFveM IaQZqF6gXblvjGzh5sdDVEsevdRQri4BKFtaQ= 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=3b5/gFGu1T1cUj/XIJu+OysWJ2RKOCNAhxQzWVf19nk=; b=Dzp959kQVz9I07KyYtiqRYkOYIaZhv8qFsO307Ki+RT/N4CXkLJaVkErXIJ7TDFFCj 8wV5V7muhdrSehRqkDnq2W9FZHh2Tbr/llP+Mr3651IjjrGU3UXYiJuMTBIrlMJUk8pi OirZsGJ4S8gnM6dDejbogWM4WgZPywVe1vY3YCxEFn0aHa8nLt1eRULnR+IKCYXwTBgu 73WaLc2aaroC7e1VxyR1noVPXj6D6+BUdJNd7pPmuXJEg7xhU3ZO8ELv95LoeKK+aaw6 6esROMKL0mUsXQUS+JzgE/nKVZqMm1UilRYJfCXOx7/9jzLyW6YMAEpfX30w+5sGCKKb 78xw== X-Gm-Message-State: AN3rC/5ix1aEi1TZLpHG2gT/P8K0wcrB76PuXfWom2GD0abbRhQKgtQq wFE6ayg1OqloQceH X-Received: by 10.98.157.11 with SMTP id i11mr9871735pfd.166.1492409014814; Sun, 16 Apr 2017 23:03:34 -0700 (PDT) Received: from localhost ([122.172.121.5]) by smtp.gmail.com with ESMTPSA id u66sm15402547pgc.52.2017.04.16.23.03.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 16 Apr 2017 23:03:34 -0700 (PDT) From: Viresh Kumar To: Javi Merino , Zhang Rui , Eduardo Valentin , 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 Subject: [PATCH V2 15/17] thermal: cpu_cooling: don't store cpu_dev in cpufreq_cdev Date: Mon, 17 Apr 2017 11:32:00 +0530 Message-Id: <8cdf0093d3f28b0d2fff15578fff5548c9976649.1492408342.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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 4ec9234488c6..1e4c5d13afbf 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; }