Skip to content

Commit 88fc6f7

Browse files
mszyprowEduardo Valentin
authored andcommitted
thermal: exynos: Reading temperature makes sense only when TMU is turned on
When thermal sensor is not yet enabled, reading temperature might return random value. This might even result in stopping system booting when such temperature is higher than the critical value. Fix this by checking if TMU has been actually enabled before reading the temperature. This change fixes booting of Exynos4210-based board with TMU enabled (for example Samsung Trats board), which was broken since v4.4 kernel release. Signed-off-by: Marek Szyprowski <[email protected]> Fixes: 9e4249b ("thermal: exynos: Fix first temperature read after registering sensor") CC: [email protected] # v4.6+ Signed-off-by: Bartlomiej Zolnierkiewicz <[email protected]> Signed-off-by: Eduardo Valentin <[email protected]>
1 parent 6d08b06 commit 88fc6f7

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

drivers/thermal/samsung/exynos_tmu.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@
185185
* @regulator: pointer to the TMU regulator structure.
186186
* @reg_conf: pointer to structure to register with core thermal.
187187
* @ntrip: number of supported trip points.
188+
* @enabled: current status of TMU device
188189
* @tmu_initialize: SoC specific TMU initialization method
189190
* @tmu_control: SoC specific TMU control method
190191
* @tmu_read: SoC specific TMU temperature read method
@@ -205,6 +206,7 @@ struct exynos_tmu_data {
205206
struct regulator *regulator;
206207
struct thermal_zone_device *tzd;
207208
unsigned int ntrip;
209+
bool enabled;
208210

209211
int (*tmu_initialize)(struct platform_device *pdev);
210212
void (*tmu_control)(struct platform_device *pdev, bool on);
@@ -398,6 +400,7 @@ static void exynos_tmu_control(struct platform_device *pdev, bool on)
398400
mutex_lock(&data->lock);
399401
clk_enable(data->clk);
400402
data->tmu_control(pdev, on);
403+
data->enabled = on;
401404
clk_disable(data->clk);
402405
mutex_unlock(&data->lock);
403406
}
@@ -890,7 +893,7 @@ static int exynos_get_temp(void *p, int *temp)
890893
{
891894
struct exynos_tmu_data *data = p;
892895

893-
if (!data || !data->tmu_read)
896+
if (!data || !data->tmu_read || !data->enabled)
894897
return -EINVAL;
895898

896899
mutex_lock(&data->lock);

0 commit comments

Comments
 (0)