LKML Archive on lore.kernel.org
 help / Atom feed
* [PATCH V5 1/2] thermal: imx: fix for dependency on cpu-freq
@ 2018-11-21  5:49 Anson Huang
  2018-11-21  5:49 ` [PATCH V5 2/2] thermal: imx: save one condition block for normal case of nvmem initialization Anson Huang
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Anson Huang @ 2018-11-21  5:49 UTC (permalink / raw)
  To: rui.zhang, edubezval, daniel.lezcano, linux-pm, linux-kernel,
	viresh.kumar, l.stach
  Cc: dl-linux-imx

The thermal driver is a standalone driver for monitoring SoC temperature
by enabling thermal sensor, so it can be enabled even when CONFIG_CPU_FREQ
is NOT set. So remove the dependency with CPU_THERMAL.

Introduce dummy function of legacy cooling register/unregister to make
thermal driver probe successfully when CONFIG_CPU_FREQ is NOT set.

Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
---
 drivers/thermal/Kconfig       |  2 +-
 drivers/thermal/imx_thermal.c | 47 ++++++++++++++++++++++++++++++++-----------
 2 files changed, 36 insertions(+), 13 deletions(-)

diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig
index 5422523..93bd3bb 100644
--- a/drivers/thermal/Kconfig
+++ b/drivers/thermal/Kconfig
@@ -212,7 +212,7 @@ config HISI_THERMAL
 
 config IMX_THERMAL
 	tristate "Temperature sensor driver for Freescale i.MX SoCs"
-	depends on (ARCH_MXC && CPU_THERMAL) || COMPILE_TEST
+	depends on ARCH_MXC || COMPILE_TEST
 	depends on NVMEM || !NVMEM
 	depends on MFD_SYSCON
 	depends on OF
diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c
index 1566154..c924396 100644
--- a/drivers/thermal/imx_thermal.c
+++ b/drivers/thermal/imx_thermal.c
@@ -648,15 +648,24 @@ static const struct of_device_id of_imx_thermal_match[] = {
 };
 MODULE_DEVICE_TABLE(of, of_imx_thermal_match);
 
+#ifdef CONFIG_CPU_FREQ
 /*
  * Create cooling device in case no #cooling-cells property is available in
  * CPU node
  */
 static int imx_thermal_register_legacy_cooling(struct imx_thermal_data *data)
 {
-	struct device_node *np = of_get_cpu_node(data->policy->cpu, NULL);
+	struct device_node *np;
 	int ret;
 
+	data->policy = cpufreq_cpu_get(0);
+	if (!data->policy) {
+		pr_debug("%s: CPUFreq policy not found\n", __func__);
+		return -EPROBE_DEFER;
+	}
+
+	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)) {
@@ -669,6 +678,24 @@ static int imx_thermal_register_legacy_cooling(struct imx_thermal_data *data)
 	return 0;
 }
 
+static void imx_thermal_unregister_legacy_cooling(struct imx_thermal_data *data)
+{
+	cpufreq_cooling_unregister(data->cdev);
+	cpufreq_cpu_put(data->policy);
+}
+
+#else
+
+static inline int imx_thermal_register_legacy_cooling(struct imx_thermal_data *data)
+{
+	return 0;
+}
+
+static inline void imx_thermal_unregister_legacy_cooling(struct imx_thermal_data *data)
+{
+}
+#endif
+
 static int imx_thermal_probe(struct platform_device *pdev)
 {
 	struct imx_thermal_data *data;
@@ -743,14 +770,11 @@ static int imx_thermal_probe(struct platform_device *pdev)
 	regmap_write(map, data->socdata->sensor_ctrl + REG_SET,
 		     data->socdata->power_down_mask);
 
-	data->policy = cpufreq_cpu_get(0);
-	if (!data->policy) {
-		pr_debug("%s: CPUFreq policy not found\n", __func__);
-		return -EPROBE_DEFER;
-	}
-
 	ret = imx_thermal_register_legacy_cooling(data);
 	if (ret) {
+		if (ret == -EPROBE_DEFER)
+			return ret;
+
 		dev_err(&pdev->dev,
 			"failed to register cpufreq cooling device: %d\n", ret);
 		return ret;
@@ -762,7 +786,7 @@ static int imx_thermal_probe(struct platform_device *pdev)
 		if (ret != -EPROBE_DEFER)
 			dev_err(&pdev->dev,
 				"failed to get thermal clk: %d\n", ret);
-		goto cpufreq_put;
+		goto legacy_cleanup;
 	}
 
 	/*
@@ -775,7 +799,7 @@ static int imx_thermal_probe(struct platform_device *pdev)
 	ret = clk_prepare_enable(data->thermal_clk);
 	if (ret) {
 		dev_err(&pdev->dev, "failed to enable thermal clk: %d\n", ret);
-		goto cpufreq_put;
+		goto legacy_cleanup;
 	}
 
 	data->tz = thermal_zone_device_register("imx_thermal_zone",
@@ -829,9 +853,8 @@ static int imx_thermal_probe(struct platform_device *pdev)
 	thermal_zone_device_unregister(data->tz);
 clk_disable:
 	clk_disable_unprepare(data->thermal_clk);
-cpufreq_put:
-	cpufreq_cooling_unregister(data->cdev);
-	cpufreq_cpu_put(data->policy);
+legacy_cleanup:
+	imx_thermal_unregister_legacy_cooling(data);
 
 	return ret;
 }
-- 
2.7.4


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH V5 2/2] thermal: imx: save one condition block for normal case of nvmem initialization
  2018-11-21  5:49 [PATCH V5 1/2] thermal: imx: fix for dependency on cpu-freq Anson Huang
@ 2018-11-21  5:49 ` Anson Huang
  2018-11-21  5:53   ` Viresh Kumar
  2018-11-21  8:30   ` Daniel Lezcano
  2018-11-21  5:53 ` [PATCH V5 1/2] thermal: imx: fix for dependency on cpu-freq Viresh Kumar
  2018-11-21  8:30 ` Daniel Lezcano
  2 siblings, 2 replies; 7+ messages in thread
From: Anson Huang @ 2018-11-21  5:49 UTC (permalink / raw)
  To: rui.zhang, edubezval, daniel.lezcano, linux-pm, linux-kernel,
	viresh.kumar, l.stach
  Cc: dl-linux-imx

Put return value checks of calling imx_init_from_nvmem_cells()
into one block to save one condition block for normal case.

Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
---
 drivers/thermal/imx_thermal.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c
index c924396..bb6754a 100644
--- a/drivers/thermal/imx_thermal.c
+++ b/drivers/thermal/imx_thermal.c
@@ -742,9 +742,10 @@ static int imx_thermal_probe(struct platform_device *pdev)
 
 	if (of_find_property(pdev->dev.of_node, "nvmem-cells", NULL)) {
 		ret = imx_init_from_nvmem_cells(pdev);
-		if (ret == -EPROBE_DEFER)
-			return ret;
 		if (ret) {
+			if (ret == -EPROBE_DEFER)
+				return ret;
+
 			dev_err(&pdev->dev, "failed to init from nvmem: %d\n",
 				ret);
 			return ret;
-- 
2.7.4


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH V5 1/2] thermal: imx: fix for dependency on cpu-freq
  2018-11-21  5:49 [PATCH V5 1/2] thermal: imx: fix for dependency on cpu-freq Anson Huang
  2018-11-21  5:49 ` [PATCH V5 2/2] thermal: imx: save one condition block for normal case of nvmem initialization Anson Huang
@ 2018-11-21  5:53 ` Viresh Kumar
  2018-11-21  8:30 ` Daniel Lezcano
  2 siblings, 0 replies; 7+ messages in thread
From: Viresh Kumar @ 2018-11-21  5:53 UTC (permalink / raw)
  To: Anson Huang
  Cc: rui.zhang, edubezval, daniel.lezcano, linux-pm, linux-kernel,
	l.stach, dl-linux-imx

On 21-11-18, 05:49, Anson Huang wrote:
> The thermal driver is a standalone driver for monitoring SoC temperature
> by enabling thermal sensor, so it can be enabled even when CONFIG_CPU_FREQ
> is NOT set. So remove the dependency with CPU_THERMAL.
> 
> Introduce dummy function of legacy cooling register/unregister to make
> thermal driver probe successfully when CONFIG_CPU_FREQ is NOT set.
> 
> Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
> ---
>  drivers/thermal/Kconfig       |  2 +-
>  drivers/thermal/imx_thermal.c | 47 ++++++++++++++++++++++++++++++++-----------
>  2 files changed, 36 insertions(+), 13 deletions(-)

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

-- 
viresh

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH V5 2/2] thermal: imx: save one condition block for normal case of nvmem initialization
  2018-11-21  5:49 ` [PATCH V5 2/2] thermal: imx: save one condition block for normal case of nvmem initialization Anson Huang
@ 2018-11-21  5:53   ` Viresh Kumar
  2018-11-21  8:30   ` Daniel Lezcano
  1 sibling, 0 replies; 7+ messages in thread
From: Viresh Kumar @ 2018-11-21  5:53 UTC (permalink / raw)
  To: Anson Huang
  Cc: rui.zhang, edubezval, daniel.lezcano, linux-pm, linux-kernel,
	l.stach, dl-linux-imx

On 21-11-18, 05:49, Anson Huang wrote:
> Put return value checks of calling imx_init_from_nvmem_cells()
> into one block to save one condition block for normal case.
> 
> Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
> ---
>  drivers/thermal/imx_thermal.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c
> index c924396..bb6754a 100644
> --- a/drivers/thermal/imx_thermal.c
> +++ b/drivers/thermal/imx_thermal.c
> @@ -742,9 +742,10 @@ static int imx_thermal_probe(struct platform_device *pdev)
>  
>  	if (of_find_property(pdev->dev.of_node, "nvmem-cells", NULL)) {
>  		ret = imx_init_from_nvmem_cells(pdev);
> -		if (ret == -EPROBE_DEFER)
> -			return ret;
>  		if (ret) {
> +			if (ret == -EPROBE_DEFER)
> +				return ret;
> +
>  			dev_err(&pdev->dev, "failed to init from nvmem: %d\n",
>  				ret);
>  			return ret;

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

-- 
viresh

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH V5 1/2] thermal: imx: fix for dependency on cpu-freq
  2018-11-21  5:49 [PATCH V5 1/2] thermal: imx: fix for dependency on cpu-freq Anson Huang
  2018-11-21  5:49 ` [PATCH V5 2/2] thermal: imx: save one condition block for normal case of nvmem initialization Anson Huang
  2018-11-21  5:53 ` [PATCH V5 1/2] thermal: imx: fix for dependency on cpu-freq Viresh Kumar
@ 2018-11-21  8:30 ` Daniel Lezcano
  2 siblings, 0 replies; 7+ messages in thread
From: Daniel Lezcano @ 2018-11-21  8:30 UTC (permalink / raw)
  To: Anson Huang, rui.zhang, edubezval, linux-pm, linux-kernel,
	viresh.kumar, l.stach
  Cc: dl-linux-imx

On 21/11/2018 06:49, Anson Huang wrote:
> The thermal driver is a standalone driver for monitoring SoC temperature
> by enabling thermal sensor, so it can be enabled even when CONFIG_CPU_FREQ
> is NOT set. So remove the dependency with CPU_THERMAL.
> 
> Introduce dummy function of legacy cooling register/unregister to make
> thermal driver probe successfully when CONFIG_CPU_FREQ is NOT set.
> 
> Signed-off-by: Anson Huang <Anson.Huang@nxp.com>

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



-- 
 <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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH V5 2/2] thermal: imx: save one condition block for normal case of nvmem initialization
  2018-11-21  5:49 ` [PATCH V5 2/2] thermal: imx: save one condition block for normal case of nvmem initialization Anson Huang
  2018-11-21  5:53   ` Viresh Kumar
@ 2018-11-21  8:30   ` Daniel Lezcano
  2018-12-07  3:11     ` Anson Huang
  1 sibling, 1 reply; 7+ messages in thread
From: Daniel Lezcano @ 2018-11-21  8:30 UTC (permalink / raw)
  To: Anson Huang, rui.zhang, edubezval, linux-pm, linux-kernel,
	viresh.kumar, l.stach
  Cc: dl-linux-imx

On 21/11/2018 06:49, Anson Huang wrote:
> Put return value checks of calling imx_init_from_nvmem_cells()
> into one block to save one condition block for normal case.
> 
> Signed-off-by: Anson Huang <Anson.Huang@nxp.com>

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

> ---
>  drivers/thermal/imx_thermal.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c
> index c924396..bb6754a 100644
> --- a/drivers/thermal/imx_thermal.c
> +++ b/drivers/thermal/imx_thermal.c
> @@ -742,9 +742,10 @@ static int imx_thermal_probe(struct platform_device *pdev)
>  
>  	if (of_find_property(pdev->dev.of_node, "nvmem-cells", NULL)) {
>  		ret = imx_init_from_nvmem_cells(pdev);
> -		if (ret == -EPROBE_DEFER)
> -			return ret;
>  		if (ret) {
> +			if (ret == -EPROBE_DEFER)
> +				return ret;
> +
>  			dev_err(&pdev->dev, "failed to init from nvmem: %d\n",
>  				ret);
>  			return ret;
> 


-- 
 <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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: [PATCH V5 2/2] thermal: imx: save one condition block for normal case of nvmem initialization
  2018-11-21  8:30   ` Daniel Lezcano
@ 2018-12-07  3:11     ` Anson Huang
  0 siblings, 0 replies; 7+ messages in thread
From: Anson Huang @ 2018-12-07  3:11 UTC (permalink / raw)
  To: Daniel Lezcano, rui.zhang, edubezval, linux-pm, linux-kernel,
	viresh.kumar, l.stach
  Cc: dl-linux-imx

Gentle ping..

Best Regards!
Anson Huang

> -----Original Message-----
> From: Daniel Lezcano [mailto:daniel.lezcano@linaro.org]
> Sent: 2018年11月21日 16:31
> To: Anson Huang <anson.huang@nxp.com>; rui.zhang@intel.com;
> edubezval@gmail.com; linux-pm@vger.kernel.org;
> linux-kernel@vger.kernel.org; viresh.kumar@linaro.org;
> l.stach@pengutronix.de
> Cc: dl-linux-imx <linux-imx@nxp.com>
> Subject: Re: [PATCH V5 2/2] thermal: imx: save one condition block for normal
> case of nvmem initialization
> 
> On 21/11/2018 06:49, Anson Huang wrote:
> > Put return value checks of calling imx_init_from_nvmem_cells() into
> > one block to save one condition block for normal case.
> >
> > Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
> 
> Reviewed-by: Daniel Lezcano <daniel.lezcano@linaro.org>
> 
> > ---
> >  drivers/thermal/imx_thermal.c | 5 +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/thermal/imx_thermal.c
> > b/drivers/thermal/imx_thermal.c index c924396..bb6754a 100644
> > --- a/drivers/thermal/imx_thermal.c
> > +++ b/drivers/thermal/imx_thermal.c
> > @@ -742,9 +742,10 @@ static int imx_thermal_probe(struct
> > platform_device *pdev)
> >
> >  	if (of_find_property(pdev->dev.of_node, "nvmem-cells", NULL)) {
> >  		ret = imx_init_from_nvmem_cells(pdev);
> > -		if (ret == -EPROBE_DEFER)
> > -			return ret;
> >  		if (ret) {
> > +			if (ret == -EPROBE_DEFER)
> > +				return ret;
> > +
> >  			dev_err(&pdev->dev, "failed to init from nvmem: %d\n",
> >  				ret);
> >  			return ret;
> >
> 
> 
> --
> 
> <https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww
> .linaro.org%2F&amp;data=02%7C01%7Canson.huang%40nxp.com%7Cfd6043
> 7ee3644bef859308d64f8babfc%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C
> 0%7C0%7C636783858654973865&amp;sdata=BgscGAsKYemJsPxOeWnhK9o7
> 2DnyV%2B5p%2B%2F2FukhcpqM%3D&amp;reserved=0> Linaro.org │ Open
> source software for ARM SoCs
> 
> Follow Linaro:
> <https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww
> .facebook.com%2Fpages%2FLinaro&amp;data=02%7C01%7Canson.huang%40
> nxp.com%7Cfd60437ee3644bef859308d64f8babfc%7C686ea1d3bc2b4c6fa92
> cd99c5c301635%7C0%7C0%7C636783858654973865&amp;sdata=6zA10lW
> wnWoAUK7jqqvsDDMM2Q13AedmeSPABMeR%2Bxc%3D&amp;reserved=0>
> Facebook |
> <https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Ftwitt
> er.com%2F%23!%2Flinaroorg&amp;data=02%7C01%7Canson.huang%40nxp.c
> om%7Cfd60437ee3644bef859308d64f8babfc%7C686ea1d3bc2b4c6fa92cd99
> c5c301635%7C0%7C0%7C636783858654973865&amp;sdata=kuquKEUuvXW
> 88V2QgPQgXYBgv2Htv37GKDqah0VeIJ8%3D&amp;reserved=0> Twitter |
> <https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww
> .linaro.org%2Flinaro-blog%2F&amp;data=02%7C01%7Canson.huang%40nxp.c
> om%7Cfd60437ee3644bef859308d64f8babfc%7C686ea1d3bc2b4c6fa92cd99
> c5c301635%7C0%7C0%7C636783858654973865&amp;sdata=0AiYcj1H1va1n
> mee2tHWWYnmGe5wzFoao4KZbkxsKzo%3D&amp;reserved=0> Blog


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, back to index

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-21  5:49 [PATCH V5 1/2] thermal: imx: fix for dependency on cpu-freq Anson Huang
2018-11-21  5:49 ` [PATCH V5 2/2] thermal: imx: save one condition block for normal case of nvmem initialization Anson Huang
2018-11-21  5:53   ` Viresh Kumar
2018-11-21  8:30   ` Daniel Lezcano
2018-12-07  3:11     ` Anson Huang
2018-11-21  5:53 ` [PATCH V5 1/2] thermal: imx: fix for dependency on cpu-freq Viresh Kumar
2018-11-21  8:30 ` Daniel Lezcano

LKML Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/lkml/0 lkml/git/0.git
	git clone --mirror https://lore.kernel.org/lkml/1 lkml/git/1.git
	git clone --mirror https://lore.kernel.org/lkml/2 lkml/git/2.git
	git clone --mirror https://lore.kernel.org/lkml/3 lkml/git/3.git
	git clone --mirror https://lore.kernel.org/lkml/4 lkml/git/4.git
	git clone --mirror https://lore.kernel.org/lkml/5 lkml/git/5.git
	git clone --mirror https://lore.kernel.org/lkml/6 lkml/git/6.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 lkml lkml/ https://lore.kernel.org/lkml \
		linux-kernel@vger.kernel.org linux-kernel@archiver.kernel.org
	public-inbox-index lkml


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-kernel


AGPL code for this site: git clone https://public-inbox.org/ public-inbox