diff mbox series

[v4,7/9] cpufreq: qoriq: Use auto-registration of thermal cooling device

Message ID f33f279a20f9125ffbec96bfbf1aa9153baebab8.1548654899.git.amit.kucheria@linaro.org
State Accepted
Commit 17170ec17109bdcd26bf542392a5bafcb6a5732f
Headers show
Series [v4,1/9] thermal: cpu_cooling: Require thermal core to be compiled in | expand

Commit Message

Amit Kucheria Jan. 28, 2019, 6:41 a.m. UTC
Use the CPUFREQ_AUTO_REGISTER_COOLING_DEV flag to allow cpufreq core to
automatically register as a thermal cooling device.

This allows removal of boiler plate code from the driver.

Signed-off-by: Amit Kucheria <amit.kucheria@linaro.org>

---
 drivers/cpufreq/qoriq-cpufreq.c | 15 ++-------------
 1 file changed, 2 insertions(+), 13 deletions(-)

-- 
2.17.1

Comments

Daniel Lezcano Jan. 28, 2019, 8:37 a.m. UTC | #1
On 28/01/2019 07:41, Amit Kucheria wrote:
> Use the CPUFREQ_AUTO_REGISTER_COOLING_DEV flag to allow cpufreq core to

> automatically register as a thermal cooling device.

> 

> This allows removal of boiler plate code from the driver.

> 

> Signed-off-by: Amit Kucheria <amit.kucheria@linaro.org>


Reviewed-by: Daniel Lezcano <daniel.lezcano@linaro.org>



> ---

>  drivers/cpufreq/qoriq-cpufreq.c | 15 ++-------------

>  1 file changed, 2 insertions(+), 13 deletions(-)

> 

> diff --git a/drivers/cpufreq/qoriq-cpufreq.c b/drivers/cpufreq/qoriq-cpufreq.c

> index 3d773f64b4df..b206e6cb55f0 100644

> --- a/drivers/cpufreq/qoriq-cpufreq.c

> +++ b/drivers/cpufreq/qoriq-cpufreq.c

> @@ -13,7 +13,6 @@

>  #include <linux/clk.h>

>  #include <linux/clk-provider.h>

>  #include <linux/cpufreq.h>

> -#include <linux/cpu_cooling.h>

>  #include <linux/errno.h>

>  #include <linux/init.h>

>  #include <linux/kernel.h>

> @@ -31,7 +30,6 @@

>  struct cpu_data {

>  	struct clk **pclk;

>  	struct cpufreq_frequency_table *table;

> -	struct thermal_cooling_device *cdev;

>  };

>  

>  /*

> @@ -239,7 +237,6 @@ static int qoriq_cpufreq_cpu_exit(struct cpufreq_policy *policy)

>  {

>  	struct cpu_data *data = policy->driver_data;

>  

> -	cpufreq_cooling_unregister(data->cdev);

>  	kfree(data->pclk);

>  	kfree(data->table);

>  	kfree(data);

> @@ -258,23 +255,15 @@ static int qoriq_cpufreq_target(struct cpufreq_policy *policy,

>  	return clk_set_parent(policy->clk, parent);

>  }

>  

> -

> -static void qoriq_cpufreq_ready(struct cpufreq_policy *policy)

> -{

> -	struct cpu_data *cpud = policy->driver_data;

> -

> -	cpud->cdev = of_cpufreq_cooling_register(policy);

> -}

> -

>  static struct cpufreq_driver qoriq_cpufreq_driver = {

>  	.name		= "qoriq_cpufreq",

> -	.flags		= CPUFREQ_CONST_LOOPS,

> +	.flags		= CPUFREQ_CONST_LOOPS |

> +			  CPUFREQ_AUTO_REGISTER_COOLING_DEV,

>  	.init		= qoriq_cpufreq_cpu_init,

>  	.exit		= qoriq_cpufreq_cpu_exit,

>  	.verify		= cpufreq_generic_frequency_table_verify,

>  	.target_index	= qoriq_cpufreq_target,

>  	.get		= cpufreq_generic_get,

> -	.ready		= qoriq_cpufreq_ready,

>  	.attr		= cpufreq_generic_attr,

>  };

>  

> 



-- 
 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
diff mbox series

Patch

diff --git a/drivers/cpufreq/qoriq-cpufreq.c b/drivers/cpufreq/qoriq-cpufreq.c
index 3d773f64b4df..b206e6cb55f0 100644
--- a/drivers/cpufreq/qoriq-cpufreq.c
+++ b/drivers/cpufreq/qoriq-cpufreq.c
@@ -13,7 +13,6 @@ 
 #include <linux/clk.h>
 #include <linux/clk-provider.h>
 #include <linux/cpufreq.h>
-#include <linux/cpu_cooling.h>
 #include <linux/errno.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
@@ -31,7 +30,6 @@ 
 struct cpu_data {
 	struct clk **pclk;
 	struct cpufreq_frequency_table *table;
-	struct thermal_cooling_device *cdev;
 };
 
 /*
@@ -239,7 +237,6 @@  static int qoriq_cpufreq_cpu_exit(struct cpufreq_policy *policy)
 {
 	struct cpu_data *data = policy->driver_data;
 
-	cpufreq_cooling_unregister(data->cdev);
 	kfree(data->pclk);
 	kfree(data->table);
 	kfree(data);
@@ -258,23 +255,15 @@  static int qoriq_cpufreq_target(struct cpufreq_policy *policy,
 	return clk_set_parent(policy->clk, parent);
 }
 
-
-static void qoriq_cpufreq_ready(struct cpufreq_policy *policy)
-{
-	struct cpu_data *cpud = policy->driver_data;
-
-	cpud->cdev = of_cpufreq_cooling_register(policy);
-}
-
 static struct cpufreq_driver qoriq_cpufreq_driver = {
 	.name		= "qoriq_cpufreq",
-	.flags		= CPUFREQ_CONST_LOOPS,
+	.flags		= CPUFREQ_CONST_LOOPS |
+			  CPUFREQ_AUTO_REGISTER_COOLING_DEV,
 	.init		= qoriq_cpufreq_cpu_init,
 	.exit		= qoriq_cpufreq_cpu_exit,
 	.verify		= cpufreq_generic_frequency_table_verify,
 	.target_index	= qoriq_cpufreq_target,
 	.get		= cpufreq_generic_get,
-	.ready		= qoriq_cpufreq_ready,
 	.attr		= cpufreq_generic_attr,
 };