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 <[email protected]>
CC: [email protected] # v4.6+
Signed-off-by: Bartlomiej Zolnierkiewicz <[email protected]>
Signed-off-by: Eduardo Valentin <[email protected]>
  • Loading branch information
mszyprow authored and Eduardo Valentin committed May 6, 2018
1 parent 0eb875d commit 08d725c
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 08d725c

Please sign in to comment.