@@ -477,37 +477,31 @@ static void handle_thermal_trip(struct thermal_zone_device *tz, int trip)
477
477
int thermal_zone_get_temp (struct thermal_zone_device * tz , int * temp )
478
478
{
479
479
int ret = - EINVAL ;
480
- #ifdef CONFIG_THERMAL_EMULATION
481
480
int count ;
482
481
int crit_temp = INT_MAX ;
483
482
enum thermal_trip_type type ;
484
- #endif
485
483
486
484
if (!tz || IS_ERR (tz ) || !tz -> ops -> get_temp )
487
485
goto exit ;
488
486
489
487
mutex_lock (& tz -> lock );
490
488
491
489
ret = tz -> ops -> get_temp (tz , temp );
492
- #ifdef CONFIG_THERMAL_EMULATION
493
- if (!tz -> emul_temperature )
494
- goto skip_emul ;
495
-
496
- for (count = 0 ; count < tz -> trips ; count ++ ) {
497
- ret = tz -> ops -> get_trip_type (tz , count , & type );
498
- if (!ret && type == THERMAL_TRIP_CRITICAL ) {
499
- ret = tz -> ops -> get_trip_temp (tz , count , & crit_temp );
500
- break ;
501
- }
502
- }
503
490
504
- if (ret )
505
- goto skip_emul ;
491
+ if (IS_ENABLED (CONFIG_THERMAL_EMULATION ) && tz -> emul_temperature ) {
492
+ for (count = 0 ; count < tz -> trips ; count ++ ) {
493
+ ret = tz -> ops -> get_trip_type (tz , count , & type );
494
+ if (!ret && type == THERMAL_TRIP_CRITICAL ) {
495
+ ret = tz -> ops -> get_trip_temp (tz , count ,
496
+ & crit_temp );
497
+ break ;
498
+ }
499
+ }
506
500
507
- if (* temp < crit_temp )
508
- * temp = tz -> emul_temperature ;
509
- skip_emul :
510
- #endif
501
+ if (! ret && * temp < crit_temp )
502
+ * temp = tz -> emul_temperature ;
503
+ }
504
+
511
505
mutex_unlock (& tz -> lock );
512
506
exit :
513
507
return ret ;
@@ -866,7 +860,6 @@ available_policies_show(struct device *dev, struct device_attribute *devattr,
866
860
return count ;
867
861
}
868
862
869
- #ifdef CONFIG_THERMAL_EMULATION
870
863
static ssize_t
871
864
emul_temp_store (struct device * dev , struct device_attribute * attr ,
872
865
const char * buf , size_t count )
@@ -892,7 +885,6 @@ emul_temp_store(struct device *dev, struct device_attribute *attr,
892
885
return ret ? ret : count ;
893
886
}
894
887
static DEVICE_ATTR (emul_temp , S_IWUSR , NULL, emul_temp_store ) ;
895
- #endif /*CONFIG_THERMAL_EMULATION*/
896
888
897
889
static ssize_t
898
890
sustainable_power_show (struct device * dev , struct device_attribute * devattr ,
@@ -1822,11 +1814,12 @@ struct thermal_zone_device *thermal_zone_device_register(const char *type,
1822
1814
goto unregister ;
1823
1815
}
1824
1816
1825
- #ifdef CONFIG_THERMAL_EMULATION
1826
- result = device_create_file (& tz -> device , & dev_attr_emul_temp );
1827
- if (result )
1828
- goto unregister ;
1829
- #endif
1817
+ if (IS_ENABLED (CONFIG_THERMAL_EMULATION )) {
1818
+ result = device_create_file (& tz -> device , & dev_attr_emul_temp );
1819
+ if (result )
1820
+ goto unregister ;
1821
+ }
1822
+
1830
1823
/* Create policy attribute */
1831
1824
result = device_create_file (& tz -> device , & dev_attr_policy );
1832
1825
if (result )
0 commit comments