Skip to content

Commit 60abce9

Browse files
committed
Merge branch 'thermal-soc' into next
2 parents 13b86f5 + c8da6cd commit 60abce9

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

drivers/thermal/samsung/exynos_tmu.c

Lines changed: 11 additions & 3 deletions
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
}
@@ -889,19 +892,24 @@ static void exynos7_tmu_control(struct platform_device *pdev, bool on)
889892
static int exynos_get_temp(void *p, int *temp)
890893
{
891894
struct exynos_tmu_data *data = p;
895+
int value, ret = 0;
892896

893-
if (!data || !data->tmu_read)
897+
if (!data || !data->tmu_read || !data->enabled)
894898
return -EINVAL;
895899

896900
mutex_lock(&data->lock);
897901
clk_enable(data->clk);
898902

899-
*temp = code_to_temp(data, data->tmu_read(data)) * MCELSIUS;
903+
value = data->tmu_read(data);
904+
if (value < 0)
905+
ret = value;
906+
else
907+
*temp = code_to_temp(data, value) * MCELSIUS;
900908

901909
clk_disable(data->clk);
902910
mutex_unlock(&data->lock);
903911

904-
return 0;
912+
return ret;
905913
}
906914

907915
#ifdef CONFIG_THERMAL_EMULATION

0 commit comments

Comments
 (0)