stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] thermal: exynos: Propagate error value from tmu_read()
       [not found] <CGME20180227151408eucas1p20dc5f0974dda96b4ebaff7948eda766a@eucas1p2.samsung.com>
@ 2018-02-27 15:14 ` Marek Szyprowski
  2018-02-27 15:25   ` Bartlomiej Zolnierkiewicz
  0 siblings, 1 reply; 2+ messages in thread
From: Marek Szyprowski @ 2018-02-27 15:14 UTC (permalink / raw)
  To: linux-samsung-soc, linux-pm
  Cc: stable, Marek Szyprowski, Krzysztof Kozlowski,
	Bartlomiej Zolnierkiewicz, Eduardo Valentin, Zhang Rui

tmu_read() in case of Exynos4210 might return error for out of bound
values. Current code ignores such value, what leads to reporting critical
temperature value. Add proper error code propagation to exynos_get_temp()
function.

Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
CC: stable@vger.kernel.org # v4.6+
---
This patch is prepared on top of "thermal: exynos: Reading temperature
makes sense only when TMU is turned on" patch. Both are required
to finally fix thermal support on Exynos4210 based boards.

This patch only applies cleanly together with the mentioned "thermal:
exynos: Reading temperature makes sense only when TMU is turned on"
patch on v4.6+ kernels.
---
 drivers/thermal/samsung/exynos_tmu.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
index 986cbd01aaaa..74adeb1d2daf 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -892,6 +892,7 @@ static void exynos7_tmu_control(struct platform_device *pdev, bool on)
 static int exynos_get_temp(void *p, int *temp)
 {
 	struct exynos_tmu_data *data = p;
+	int value, ret = 0;
 
 	if (!data || !data->tmu_read || !data->enabled)
 		return -EINVAL;
@@ -899,12 +900,16 @@ static int exynos_get_temp(void *p, int *temp)
 	mutex_lock(&data->lock);
 	clk_enable(data->clk);
 
-	*temp = code_to_temp(data, data->tmu_read(data)) * MCELSIUS;
+	value = data->tmu_read(data);
+	if (value < 0)
+		ret = value;
+	else
+		*temp = code_to_temp(data, value) * MCELSIUS;
 
 	clk_disable(data->clk);
 	mutex_unlock(&data->lock);
 
-	return 0;
+	return ret;
 }
 
 #ifdef CONFIG_THERMAL_EMULATION
-- 
2.15.0

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

* Re: [PATCH] thermal: exynos: Propagate error value from tmu_read()
  2018-02-27 15:14 ` [PATCH] thermal: exynos: Propagate error value from tmu_read() Marek Szyprowski
@ 2018-02-27 15:25   ` Bartlomiej Zolnierkiewicz
  0 siblings, 0 replies; 2+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2018-02-27 15:25 UTC (permalink / raw)
  To: Marek Szyprowski
  Cc: linux-samsung-soc, linux-pm, stable, Krzysztof Kozlowski,
	Eduardo Valentin, Zhang Rui

On Tuesday, February 27, 2018 04:14:05 PM Marek Szyprowski wrote:
> tmu_read() in case of Exynos4210 might return error for out of bound
> values. Current code ignores such value, what leads to reporting critical
> temperature value. Add proper error code propagation to exynos_get_temp()
> function.
> 
> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
> CC: stable@vger.kernel.org # v4.6+

Thanks for fixing this.

Acked-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>

> ---
> This patch is prepared on top of "thermal: exynos: Reading temperature
> makes sense only when TMU is turned on" patch. Both are required
> to finally fix thermal support on Exynos4210 based boards.
> 
> This patch only applies cleanly together with the mentioned "thermal:
> exynos: Reading temperature makes sense only when TMU is turned on"
> patch on v4.6+ kernels.

You may also add:

Fixes: 3b6a1a805f34 ("thermal: samsung: core: Exynos TMU rework to use device tree for configuration")

to the patch description.

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics

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

end of thread, other threads:[~2018-02-27 15:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <CGME20180227151408eucas1p20dc5f0974dda96b4ebaff7948eda766a@eucas1p2.samsung.com>
2018-02-27 15:14 ` [PATCH] thermal: exynos: Propagate error value from tmu_read() Marek Szyprowski
2018-02-27 15:25   ` Bartlomiej Zolnierkiewicz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).