185
185
* @regulator: pointer to the TMU regulator structure.
186
186
* @reg_conf: pointer to structure to register with core thermal.
187
187
* @ntrip: number of supported trip points.
188
+ * @enabled: current status of TMU device
188
189
* @tmu_initialize: SoC specific TMU initialization method
189
190
* @tmu_control: SoC specific TMU control method
190
191
* @tmu_read: SoC specific TMU temperature read method
@@ -205,6 +206,7 @@ struct exynos_tmu_data {
205
206
struct regulator * regulator ;
206
207
struct thermal_zone_device * tzd ;
207
208
unsigned int ntrip ;
209
+ bool enabled ;
208
210
209
211
int (* tmu_initialize )(struct platform_device * pdev );
210
212
void (* tmu_control )(struct platform_device * pdev , bool on );
@@ -398,6 +400,7 @@ static void exynos_tmu_control(struct platform_device *pdev, bool on)
398
400
mutex_lock (& data -> lock );
399
401
clk_enable (data -> clk );
400
402
data -> tmu_control (pdev , on );
403
+ data -> enabled = on ;
401
404
clk_disable (data -> clk );
402
405
mutex_unlock (& data -> lock );
403
406
}
@@ -889,19 +892,24 @@ static void exynos7_tmu_control(struct platform_device *pdev, bool on)
889
892
static int exynos_get_temp (void * p , int * temp )
890
893
{
891
894
struct exynos_tmu_data * data = p ;
895
+ int value , ret = 0 ;
892
896
893
- if (!data || !data -> tmu_read )
897
+ if (!data || !data -> tmu_read || ! data -> enabled )
894
898
return - EINVAL ;
895
899
896
900
mutex_lock (& data -> lock );
897
901
clk_enable (data -> clk );
898
902
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 ;
900
908
901
909
clk_disable (data -> clk );
902
910
mutex_unlock (& data -> lock );
903
911
904
- return 0 ;
912
+ return ret ;
905
913
}
906
914
907
915
#ifdef CONFIG_THERMAL_EMULATION
0 commit comments