Skip to content

Commit

Permalink
thermal: exynos: Propagate error value from tmu_read()
Browse files Browse the repository at this point in the history
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+
Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
  • Loading branch information
Marek Szyprowski authored and Eduardo Valentin committed Apr 27, 2018
1 parent 88fc6f7 commit c8da6cd
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions drivers/thermal/samsung/exynos_tmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -892,19 +892,24 @@ 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;

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

0 comments on commit c8da6cd

Please sign in to comment.