From patchwork Mon Jun 24 13:17:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 167566 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp4218970ilk; Mon, 24 Jun 2019 06:17:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqxkh+Pr2hxdsliZnBikXew4OsJVIwDwhpLBveMmzJmoHpy6DzpaIqRugIXcVq7NnMs2Ztcr X-Received: by 2002:a63:1657:: with SMTP id 23mr30776385pgw.98.1561382251826; Mon, 24 Jun 2019 06:17:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561382251; cv=none; d=google.com; s=arc-20160816; b=qPNzOWOMCFPXqB6A9ICanXqhXbbhAJJ3Zj0cT9q+BH8Q4lPiLgQhTuEDrVgP+M1teF NmReQ5BrlFwdspamE83x+AMDzS/b40/MHxDGvzs4uOzqJ3aNVKyFoSYvyxTuKt6/iJfi c4/8HLsfFY7tP8tygQU+JqUCyCk8RU5JyNo266IyAse+iASpxHybD/932ATMED9XULhE SCeBZk4WUS8zstVxe4A5jrnuGRa2DffB/Tp8rh0yReFGeGAfoNJCk3KtRvvYot3O7Wnn dwEgR4ZhumMOloSb6/3ji1FXFDgTUxb0oTWDqu2nbBBZzZOnq85RC0aflcU0IYUJ6qPS rkZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=efC80koaOeT2KpDCiZsg2W4r8KMOQMdu6ewHJAqZM1c=; b=tnHivR13fm7WSP3jSr+mAvF6SgZzHUnrfhF7kRHW9zEDucHUsMveRBbuY6/VJFqNfA IbXTG8aqOF1aPAuxmB/ypXtceyDlZrTXWW8nOslE10o1YsSsOwy1q/yC5yoseiTxIThl PH49aTNCptjS9nriMZ+zvaEuuFVqZNveKLqLzPelOpvlwqAhh8Vy656Hfn2E+sTu3MHK t8FtnAsc2HclDjC7O0TB/DtD7pSo4pY620ZM4nk7fZAjCD+rP8L3jTEaDkxxBmzJOFsU YDa9+7cxCh4fKOY5mptiabo8IjacpBTKPeJIpBafGYU+UeU4fgmNSCHl5fa8ubqJjJvR jKnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qQXz36bU; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t10si9997655plo.297.2019.06.24.06.17.31; Mon, 24 Jun 2019 06:17:31 -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 header.s=google header.b=qQXz36bU; 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 S1728665AbfFXNRa (ORCPT + 11 others); Mon, 24 Jun 2019 09:17:30 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:36449 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728646AbfFXNRa (ORCPT ); Mon, 24 Jun 2019 09:17:30 -0400 Received: by mail-wr1-f68.google.com with SMTP id n4so12688639wrs.3 for ; Mon, 24 Jun 2019 06:17:29 -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; bh=efC80koaOeT2KpDCiZsg2W4r8KMOQMdu6ewHJAqZM1c=; b=qQXz36bUWSjMxGO1GiOAaRejTpoS188FGJ60lh8ehW1GwnXUxUcrf3WMswMNMA17tb 3JquDEdlsoGOtjCi0/v4qOs3ui/yQT0oPyKTBDUoiqwBJEUm9yMu/KvmtN4HK0w/yBqj 3CEm1JupxSoMH5rqYw1OGPLRFG6g87EwCghEOwSFkWwUsd5QWDv5lOmlWsdFtjeWqPK0 8Ywz6hqkZJNj2i5+OaCQFVA8Y+T4z3KyqiY7MSUSZbGNmxvm4Tb0b0el9ngNS50RdYu5 3Ia4trUgcm5P92NadSlDdWPClvjXlTPr+UBrP1bTgtAx7vTV1H6kzGQ2rJruDkTKWyWB 06ag== 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; bh=efC80koaOeT2KpDCiZsg2W4r8KMOQMdu6ewHJAqZM1c=; b=VGCQD7ai/cmWldbuFtvbZmTnbU/qFcYfTtAB4I59dz91E7tsAV0WExwDcHhytYu59l wA5QEgTzJV3tF+QHcfIfWEWra+Hml5IEo9a4mYLQyiaLstqyowli/UEf1Y5Mv61shsB9 oVBJkxhTr7E9kndnQx6FFFykDxSmePwFYxLgk7FIE5Mt4M3yORV1M3au6R3kAS9wzMc8 iQtM6wZPcOH9E+kFaDL374xzYWDQiXUgAftkABE5h9owTOKoz7MY2J0n1o317ZwMVzOG vv6xDlbaCp2Rh3QkbxdGPDA4ti+CQ+UclGeZcTH19jBuIkstj5w2D7T6+0LnmEpPhh70 LX/w== X-Gm-Message-State: APjAAAUpG7SUFsKj8oKBAqIRiiRxfUJz2tRb/BjWJNKNRey88xX+VeY0 IWKzKdO0xNZ4zhBbhEwrFPGfrKLXxrQ= X-Received: by 2002:adf:fc91:: with SMTP id g17mr20193129wrr.194.1561382249035; Mon, 24 Jun 2019 06:17:29 -0700 (PDT) Received: from clegane.local (209.94.129.77.rev.sfr.net. [77.129.94.209]) by smtp.gmail.com with ESMTPSA id x8sm24952817wre.73.2019.06.24.06.17.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 24 Jun 2019 06:17:28 -0700 (PDT) From: Daniel Lezcano To: viresh.kumar@linaro.org Cc: rjw@rjwysocki.net, edubezval@gmail.com, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org (open list:CPU FREQUENCY SCALING FRAMEWORK) Subject: [PATCH v2 1/2] cpufreq: Move the IS_ENABLED(CPU_THERMAL) macro in a stub Date: Mon, 24 Jun 2019 15:17:14 +0200 Message-Id: <20190624131715.1857-1-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.17.1 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The cpufreq_online and the cpufreq_offline [un]register the driver as a cooling device. This is done if the driver is flagged as a cooling device in addition with a IS_ENABLED macro to compile out the branching code. Group this test in a stub function added in the cpufreq header instead of having the IS_ENABLED in the code path. Signed-off-by: Daniel Lezcano --- drivers/cpufreq/cpufreq.c | 6 ++---- include/linux/cpufreq.h | 5 +++++ 2 files changed, 7 insertions(+), 4 deletions(-) -- 2.17.1 diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 85ff958e01f1..aee024e42618 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1378,8 +1378,7 @@ static int cpufreq_online(unsigned int cpu) if (cpufreq_driver->ready) cpufreq_driver->ready(policy); - if (IS_ENABLED(CONFIG_CPU_THERMAL) && - cpufreq_driver->flags & CPUFREQ_IS_COOLING_DEV) + if (cpufreq_thermal_control_enabled(cpufreq_driver)) policy->cdev = of_cpufreq_cooling_register(policy); pr_debug("initialization complete\n"); @@ -1469,8 +1468,7 @@ static int cpufreq_offline(unsigned int cpu) goto unlock; } - if (IS_ENABLED(CONFIG_CPU_THERMAL) && - cpufreq_driver->flags & CPUFREQ_IS_COOLING_DEV) { + if (cpufreq_thermal_control_enabled(cpufreq_driver)) { cpufreq_cooling_unregister(policy->cdev); policy->cdev = NULL; } diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index d01a74fbc4db..53ec82d75565 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -409,6 +409,11 @@ int cpufreq_unregister_driver(struct cpufreq_driver *driver_data); const char *cpufreq_get_current_driver(void); void *cpufreq_get_driver_data(void); +static inline int cpufreq_thermal_control_enabled(struct cpufreq_driver *drv) +{ + return IS_ENABLED(CPU_THERMAL) && (drv->flags & CPUFREQ_IS_COOLING_DEV); +} + static inline void cpufreq_verify_within_limits(struct cpufreq_policy *policy, unsigned int min, unsigned int max) { From patchwork Mon Jun 24 13:17:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 167567 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp4219067ilk; Mon, 24 Jun 2019 06:17:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqwaNxXR56MWcBcoCPC8+JR9o1U0IWnTfUGwQ1si1D6BoqdAujLKQs/t2HFX6+zlJs0TF026 X-Received: by 2002:a63:1322:: with SMTP id i34mr33471693pgl.424.1561382256989; Mon, 24 Jun 2019 06:17:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561382256; cv=none; d=google.com; s=arc-20160816; b=tTgPpp+o7XYYsGNzQ2/PqxnvfXFs095lIyMmK44qMHxFHCQuJ9/c5xbh1MA//CRQf3 qTVM9UGgV/D6BQeljA3sL6FDAx9Ve8kYgL+nlB6mGceWdcKozJSSvW6fXqejEW3FjxEP dNKtVsj10rI6ZOdSDVFoxD7f4NbbriMitUYe8agR1Q1A8pB0peaocqDKDXAbC09W7Ajd xx8Reb+azSsOnDM69CYgoddMXhNIPkfT58IuUrOwlvECCf1TIBW5ba20KDGnH8HgDuqv 3wNx7FqfTZp8To66MECOhCgM0+GRGscHhjAHUXtwdX75VSzTZOhnMMqfsewcEMexC2iW r3Kg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=YOp9UlrO2iQdo6ODR2oXUxAGINvR8zXAFEfOibWr2to=; b=miOUmr4bLikUll1RuzuTScsdOvRUjH/D9MIat8tOJFK5h34AAoXHLaoj5cPnbU6U48 06itLEsJd5tGl6lp7A32ql/WN2bLtrqn369hMgd7ImpnAerukhBgf+zPHrr+T1lEgsLE p7l22S469cpQsxL5o1fYVrjHMglRyVwejA1rfBYVTwlxD5x9ILFgguZXecJ87xfIgXM3 Jj2673ACK2OG5dupeny7Tl6konyy/1LeJK+tuZxSpzNOgqaMDjIhd6hcmwLFVzeToKlX IOwmK3vPDKExOGJQyOl5We/KGFJ9L+NDMpNiR9zLdO7y/ea9CCevkn7KhJ0EomR5y4FM 4p5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zjJ9WS4z; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n10si9766772pgp.481.2019.06.24.06.17.36; Mon, 24 Jun 2019 06:17:36 -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 header.s=google header.b=zjJ9WS4z; 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 S1729123AbfFXNRg (ORCPT + 11 others); Mon, 24 Jun 2019 09:17:36 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:35811 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728655AbfFXNRg (ORCPT ); Mon, 24 Jun 2019 09:17:36 -0400 Received: by mail-wm1-f66.google.com with SMTP id c6so13388760wml.0 for ; Mon, 24 Jun 2019 06:17:33 -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; bh=YOp9UlrO2iQdo6ODR2oXUxAGINvR8zXAFEfOibWr2to=; b=zjJ9WS4za1awOHlFI3g63fhC+7TiJ1ChOUnYDuQCbYoQ1MQSrN6WsDNUY/GP1+mkw1 5LLgjsfjxlkYbZraaRsQUbm9cHX1c4U/rxORWREm0F+Tj3qhF/XGDG8VlJPF3vM76maa nD1wdDufRbYQoCMwUAI7rxUItw7gAGy6MMuOnJ5cDa54YIleu0JKBvR+admMzSXHY2Se iLil1a7G+i5GL4QYSwAQebZbAgg2avnr3cra4rMRR1EpLJtd8n1QVQKv9w2lYNy8q8NF 5FYey1EBhB82QHYW1NhXHoSJTkndNLlsIcG5BMrkdUqpaw/xlyGs4kAcUck5XtVe3EJn uDbw== 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; bh=YOp9UlrO2iQdo6ODR2oXUxAGINvR8zXAFEfOibWr2to=; b=Uxh+4VBqDFK60TeSDJSmmLbj6oh2+Y/etdRpumzOIUg1y/Xk9tcIocUKxA+8FZVe9W mPNZ/nEvfLZLcTqD9Oae4KgUCZZye2WuThDP/5T/n2o2FSH58fSXR0otLsRQeIZ1pFSH 91Ebq5fLtQBCAyfnFfshQDIbRAtCrbzWcmzQ3AyWwSwv1rnWOgEos81zSpe58BpTIHKA MjAKkCLY4zvN/ebPIPDEq2V46Iab169VCWLfm9T6k5WKkhTR0Tuo3JeP1mZV/kAqlAXo 8h4AqjeniEcgEBBPpXUJWSU0GC/8pPvsN0Zbm8tD08Ms84rauGUxMLNb7r/HEiM9lBS0 E7CA== X-Gm-Message-State: APjAAAUKHFm79jgWtylPQNLfnWLwP4zCxoY+a+d//ZLBC01zFNDB6+J2 hcyQziZZ04apd46xayF/nESN5Q== X-Received: by 2002:a1c:ac81:: with SMTP id v123mr16604748wme.145.1561382252593; Mon, 24 Jun 2019 06:17:32 -0700 (PDT) Received: from clegane.local (209.94.129.77.rev.sfr.net. [77.129.94.209]) by smtp.gmail.com with ESMTPSA id x8sm24952817wre.73.2019.06.24.06.17.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 24 Jun 2019 06:17:31 -0700 (PDT) From: Daniel Lezcano To: viresh.kumar@linaro.org Cc: rjw@rjwysocki.net, edubezval@gmail.com, linux-kernel@vger.kernel.org, Sudeep Holla , Amit Daniel Kachhap , Javi Merino , Zhang Rui , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Keerthy , linux-pm@vger.kernel.org (open list:CPU FREQUENCY DRIVERS - ARM BIG LITTLE), linux-arm-kernel@lists.infradead.org (moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE), linux-omap@vger.kernel.org (open list:TI BANDGAP AND THERMAL DRIVER) Subject: [PATCH v2 2/2] thermal/drivers/cpu_cooling: Unregister with the policy Date: Mon, 24 Jun 2019 15:17:15 +0200 Message-Id: <20190624131715.1857-2-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190624131715.1857-1-daniel.lezcano@linaro.org> References: <20190624131715.1857-1-daniel.lezcano@linaro.org> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Currently the function cpufreq_cooling_register() returns a cooling device pointer which is used back as a pointer to call the function cpufreq_cooling_unregister(). Even if it is correct, it would make sense to not leak the structure inside a cpufreq driver and keep the code thermal code self-encapsulate. Moreover, that forces to add an extra variable in each driver using this function. Instead of passing the cooling device to unregister, pass the policy. Because the cpufreq_cooling_unregister() function uses the policy to unregister itself. The only purpose of the cooling device pointer is to unregister the cpu cooling device. As there is no more need of this pointer, remove it. Signed-off-by: Daniel Lezcano Acked-by: Viresh Kumar --- drivers/cpufreq/arm_big_little.c | 9 +++------ drivers/cpufreq/cpufreq.c | 10 ++++------ drivers/thermal/cpu_cooling.c | 18 ++++++++++-------- drivers/thermal/imx_thermal.c | 12 ++++++------ .../thermal/ti-soc-thermal/ti-thermal-common.c | 10 +++++----- include/linux/cpu_cooling.h | 6 +++--- include/linux/cpufreq.h | 3 --- 7 files changed, 31 insertions(+), 37 deletions(-) -- 2.17.1 diff --git a/drivers/cpufreq/arm_big_little.c b/drivers/cpufreq/arm_big_little.c index 7fe52fcddcf1..718c63231e66 100644 --- a/drivers/cpufreq/arm_big_little.c +++ b/drivers/cpufreq/arm_big_little.c @@ -56,7 +56,6 @@ static bool bL_switching_enabled; #define ACTUAL_FREQ(cluster, freq) ((cluster == A7_CLUSTER) ? freq << 1 : freq) #define VIRT_FREQ(cluster, freq) ((cluster == A7_CLUSTER) ? freq >> 1 : freq) -static struct thermal_cooling_device *cdev[MAX_CLUSTERS]; static const struct cpufreq_arm_bL_ops *arm_bL_ops; static struct clk *clk[MAX_CLUSTERS]; static struct cpufreq_frequency_table *freq_table[MAX_CLUSTERS + 1]; @@ -501,10 +500,8 @@ static int bL_cpufreq_exit(struct cpufreq_policy *policy) struct device *cpu_dev; int cur_cluster = cpu_to_cluster(policy->cpu); - if (cur_cluster < MAX_CLUSTERS) { - cpufreq_cooling_unregister(cdev[cur_cluster]); - cdev[cur_cluster] = NULL; - } + if (cur_cluster < MAX_CLUSTERS) + cpufreq_cooling_unregister(policy); cpu_dev = get_cpu_device(policy->cpu); if (!cpu_dev) { @@ -527,7 +524,7 @@ static void bL_cpufreq_ready(struct cpufreq_policy *policy) if (cur_cluster >= MAX_CLUSTERS) return; - cdev[cur_cluster] = of_cpufreq_cooling_register(policy); + of_cpufreq_cooling_register(policy); } static struct cpufreq_driver bL_cpufreq_driver = { diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index aee024e42618..f07454249fbc 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1379,8 +1379,8 @@ static int cpufreq_online(unsigned int cpu) cpufreq_driver->ready(policy); if (cpufreq_thermal_control_enabled(cpufreq_driver)) - policy->cdev = of_cpufreq_cooling_register(policy); - + of_cpufreq_cooling_register(policy); + pr_debug("initialization complete\n"); return 0; @@ -1468,10 +1468,8 @@ static int cpufreq_offline(unsigned int cpu) goto unlock; } - if (cpufreq_thermal_control_enabled(cpufreq_driver)) { - cpufreq_cooling_unregister(policy->cdev); - policy->cdev = NULL; - } + if (cpufreq_thermal_control_enabled(cpufreq_driver)) + cpufreq_cooling_unregister(policy); if (cpufreq_driver->stop_cpu) cpufreq_driver->stop_cpu(policy); diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index 83486775e593..007c7c6bf845 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -78,6 +78,7 @@ struct cpufreq_cooling_device { struct cpufreq_policy *policy; struct list_head node; struct time_in_idle *idle_time; + struct thermal_cooling_device *cdev; }; static DEFINE_IDA(cpufreq_ida); @@ -606,6 +607,7 @@ __cpufreq_cooling_register(struct device_node *np, goto remove_ida; cpufreq_cdev->clipped_freq = get_state_freq(cpufreq_cdev, 0); + cpufreq_cdev->cdev = cdev; mutex_lock(&cooling_list_lock); /* Register the notifier for first cpufreq cooling device */ @@ -699,18 +701,18 @@ EXPORT_SYMBOL_GPL(of_cpufreq_cooling_register); * * This interface function unregisters the "thermal-cpufreq-%x" cooling device. */ -void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev) +void cpufreq_cooling_unregister(struct cpufreq_policy *policy) { struct cpufreq_cooling_device *cpufreq_cdev; bool last; - if (!cdev) - return; - - cpufreq_cdev = cdev->devdata; - mutex_lock(&cooling_list_lock); - list_del(&cpufreq_cdev->node); + list_for_each_entry(cpufreq_cdev, &cpufreq_cdev_list, node) { + if (cpufreq_cdev->policy == policy) { + list_del(&cpufreq_cdev->node); + break; + } + } /* Unregister the notifier for the last cpufreq cooling device */ last = list_empty(&cpufreq_cdev_list); mutex_unlock(&cooling_list_lock); @@ -719,7 +721,7 @@ void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev) cpufreq_unregister_notifier(&thermal_cpufreq_notifier_block, CPUFREQ_POLICY_NOTIFIER); - thermal_cooling_device_unregister(cdev); + thermal_cooling_device_unregister(cpufreq_cdev->cdev); ida_simple_remove(&cpufreq_ida, cpufreq_cdev->id); kfree(cpufreq_cdev->idle_time); kfree(cpufreq_cdev); diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c index bb6754a5342c..021c0948b740 100644 --- a/drivers/thermal/imx_thermal.c +++ b/drivers/thermal/imx_thermal.c @@ -203,7 +203,6 @@ static struct thermal_soc_data thermal_imx7d_data = { struct imx_thermal_data { struct cpufreq_policy *policy; struct thermal_zone_device *tz; - struct thermal_cooling_device *cdev; enum thermal_device_mode mode; struct regmap *tempmon; u32 c1, c2; /* See formula in imx_init_calib() */ @@ -656,6 +655,7 @@ MODULE_DEVICE_TABLE(of, of_imx_thermal_match); static int imx_thermal_register_legacy_cooling(struct imx_thermal_data *data) { struct device_node *np; + struct thermal_cooling_device *cdev; int ret; data->policy = cpufreq_cpu_get(0); @@ -667,9 +667,9 @@ static int imx_thermal_register_legacy_cooling(struct imx_thermal_data *data) np = of_get_cpu_node(data->policy->cpu, NULL); if (!np || !of_find_property(np, "#cooling-cells", NULL)) { - data->cdev = cpufreq_cooling_register(data->policy); - if (IS_ERR(data->cdev)) { - ret = PTR_ERR(data->cdev); + cdev = cpufreq_cooling_register(data->policy); + if (IS_ERR(cdev)) { + ret = PTR_ERR(cdev); cpufreq_cpu_put(data->policy); return ret; } @@ -680,7 +680,7 @@ static int imx_thermal_register_legacy_cooling(struct imx_thermal_data *data) static void imx_thermal_unregister_legacy_cooling(struct imx_thermal_data *data) { - cpufreq_cooling_unregister(data->cdev); + cpufreq_cooling_unregister(data->policy); cpufreq_cpu_put(data->policy); } @@ -872,7 +872,7 @@ static int imx_thermal_remove(struct platform_device *pdev) clk_disable_unprepare(data->thermal_clk); thermal_zone_device_unregister(data->tz); - cpufreq_cooling_unregister(data->cdev); + cpufreq_cooling_unregister(data->policy); cpufreq_cpu_put(data->policy); return 0; diff --git a/drivers/thermal/ti-soc-thermal/ti-thermal-common.c b/drivers/thermal/ti-soc-thermal/ti-thermal-common.c index b4f981daeaf2..170b70b6ec61 100644 --- a/drivers/thermal/ti-soc-thermal/ti-thermal-common.c +++ b/drivers/thermal/ti-soc-thermal/ti-thermal-common.c @@ -41,7 +41,6 @@ struct ti_thermal_data { struct cpufreq_policy *policy; struct thermal_zone_device *ti_thermal; struct thermal_zone_device *pcb_tz; - struct thermal_cooling_device *cool_dev; struct ti_bandgap *bgp; enum thermal_device_mode mode; struct work_struct thermal_wq; @@ -233,6 +232,7 @@ int ti_thermal_register_cpu_cooling(struct ti_bandgap *bgp, int id) { struct ti_thermal_data *data; struct device_node *np = bgp->dev->of_node; + struct thermal_cooling_device *cdev; /* * We are assuming here that if one deploys the zone @@ -256,9 +256,9 @@ int ti_thermal_register_cpu_cooling(struct ti_bandgap *bgp, int id) } /* Register cooling device */ - data->cool_dev = cpufreq_cooling_register(data->policy); - if (IS_ERR(data->cool_dev)) { - int ret = PTR_ERR(data->cool_dev); + cdev = cpufreq_cooling_register(data->policy); + if (IS_ERR(cdev)) { + int ret = PTR_ERR(cdev); dev_err(bgp->dev, "Failed to register cpu cooling device %d\n", ret); cpufreq_cpu_put(data->policy); @@ -277,7 +277,7 @@ int ti_thermal_unregister_cpu_cooling(struct ti_bandgap *bgp, int id) data = ti_bandgap_get_sensor_data(bgp, id); if (data) { - cpufreq_cooling_unregister(data->cool_dev); + cpufreq_cooling_unregister(data->policy); if (data->policy) cpufreq_cpu_put(data->policy); } diff --git a/include/linux/cpu_cooling.h b/include/linux/cpu_cooling.h index bae54bb7c048..89f469ee4be4 100644 --- a/include/linux/cpu_cooling.h +++ b/include/linux/cpu_cooling.h @@ -29,9 +29,9 @@ cpufreq_cooling_register(struct cpufreq_policy *policy); /** * cpufreq_cooling_unregister - function to remove cpufreq cooling device. - * @cdev: thermal cooling device pointer. + * @policy: cpufreq policy */ -void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev); +void cpufreq_cooling_unregister(struct cpufreq_policy *policy); #else /* !CONFIG_CPU_THERMAL */ static inline struct thermal_cooling_device * @@ -41,7 +41,7 @@ cpufreq_cooling_register(struct cpufreq_policy *policy) } static inline -void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev) +void cpufreq_cooling_unregister(struct cpufreq_policy *policy) { return; } diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index 53ec82d75565..81ac78353f79 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -144,9 +144,6 @@ struct cpufreq_policy { /* For cpufreq driver's internal use */ void *driver_data; - - /* Pointer to the cooling device if used for thermal mitigation */ - struct thermal_cooling_device *cdev; }; struct cpufreq_freqs {