@@ -107,10 +107,10 @@ struct acpi_thermal_active {
107
107
};
108
108
109
109
struct acpi_thermal_trips {
110
- struct acpi_thermal_trip critical ;
111
- struct acpi_thermal_trip hot ;
112
110
struct acpi_thermal_passive passive ;
113
111
struct acpi_thermal_active active [ACPI_THERMAL_MAX_ACTIVE ];
112
+ bool critical_valid ;
113
+ bool hot_valid ;
114
114
};
115
115
116
116
struct acpi_thermal {
@@ -391,7 +391,7 @@ static void acpi_thermal_trips_update(struct acpi_thermal *tz, u32 event)
391
391
dev_name (& adev -> dev ), event , 0 );
392
392
}
393
393
394
- static void acpi_thermal_get_critical_trip (struct acpi_thermal * tz )
394
+ static long acpi_thermal_get_critical_trip (struct acpi_thermal * tz )
395
395
{
396
396
unsigned long long tmp ;
397
397
acpi_status status ;
@@ -420,52 +420,40 @@ static void acpi_thermal_get_critical_trip(struct acpi_thermal *tz)
420
420
}
421
421
422
422
set :
423
- tz -> trips .critical .valid = true;
424
- tz -> trips .critical .temperature = tmp ;
425
- acpi_handle_debug (tz -> device -> handle , "Critical threshold [%lu]\n" ,
426
- tz -> trips .critical .temperature );
427
- return ;
423
+ tz -> trips .critical_valid = true;
424
+ acpi_handle_debug (tz -> device -> handle , "Critical threshold [%llu]\n" , tmp );
425
+ return tmp ;
428
426
429
427
fail :
430
- tz -> trips .critical . valid = false;
431
- tz -> trips . critical . temperature = THERMAL_TEMP_INVALID ;
428
+ tz -> trips .critical_valid = false;
429
+ return THERMAL_TEMP_INVALID ;
432
430
}
433
431
434
- static void acpi_thermal_get_hot_trip (struct acpi_thermal * tz )
432
+ static long acpi_thermal_get_hot_trip (struct acpi_thermal * tz )
435
433
{
436
434
unsigned long long tmp ;
437
435
acpi_status status ;
438
436
439
437
status = acpi_evaluate_integer (tz -> device -> handle , "_HOT" , NULL , & tmp );
440
438
if (ACPI_FAILURE (status )) {
441
- tz -> trips .hot .valid = false;
442
- tz -> trips .hot .temperature = THERMAL_TEMP_INVALID ;
439
+ tz -> trips .hot_valid = false;
443
440
acpi_handle_debug (tz -> device -> handle , "No hot threshold\n" );
444
- return ;
441
+ return THERMAL_TEMP_INVALID ;
445
442
}
446
443
447
- tz -> trips .hot .valid = true;
448
- tz -> trips .hot .temperature = tmp ;
449
- acpi_handle_debug (tz -> device -> handle , "Hot threshold [%lu]\n" ,
450
- tz -> trips .hot .temperature );
444
+ tz -> trips .hot_valid = true;
445
+ acpi_handle_debug (tz -> device -> handle , "Hot threshold [%llu]\n" , tmp );
446
+ return tmp ;
451
447
}
452
448
453
449
static int acpi_thermal_get_trip_points (struct acpi_thermal * tz )
454
450
{
455
451
unsigned int count = 0 ;
456
452
int i ;
457
453
458
- acpi_thermal_get_critical_trip (tz );
459
- acpi_thermal_get_hot_trip (tz );
460
454
/* Passive and active trip points (optional). */
461
455
__acpi_thermal_trips_update (tz , ACPI_TRIPS_INIT );
462
456
463
- if (tz -> trips .critical .valid )
464
- count ++ ;
465
-
466
- if (tz -> trips .hot .valid )
467
- count ++ ;
468
-
469
457
if (tz -> trips .passive .trip .valid )
470
458
count ++ ;
471
459
@@ -578,10 +566,10 @@ static int acpi_thermal_cooling_device_cb(struct thermal_zone_device *thermal,
578
566
int trip = -1 ;
579
567
int result = 0 ;
580
568
581
- if (tz -> trips .critical . valid )
569
+ if (tz -> trips .critical_valid )
582
570
trip ++ ;
583
571
584
- if (tz -> trips .hot . valid )
572
+ if (tz -> trips .hot_valid )
585
573
trip ++ ;
586
574
587
575
if (tz -> trips .passive .trip .valid ) {
@@ -803,10 +791,9 @@ static void acpi_thermal_aml_dependency_fix(struct acpi_thermal *tz)
803
791
* The heuristic below should work for all ACPI thermal zones which have a
804
792
* critical trip point with a value being a multiple of 0.5 degree Celsius.
805
793
*/
806
- static void acpi_thermal_guess_offset (struct acpi_thermal * tz )
794
+ static void acpi_thermal_guess_offset (struct acpi_thermal * tz , long crit_temp )
807
795
{
808
- if (tz -> trips .critical .valid &&
809
- (tz -> trips .critical .temperature % 5 ) == 1 )
796
+ if (tz -> trips .critical_valid && crit_temp % 5 == 1 )
810
797
tz -> kelvin_offset = 273100 ;
811
798
else
812
799
tz -> kelvin_offset = 273200 ;
@@ -843,6 +830,7 @@ static int acpi_thermal_add(struct acpi_device *device)
843
830
struct thermal_trip * trip ;
844
831
struct acpi_thermal * tz ;
845
832
unsigned int trip_count ;
833
+ int crit_temp , hot_temp ;
846
834
int passive_delay = 0 ;
847
835
int result ;
848
836
int i ;
@@ -864,6 +852,15 @@ static int acpi_thermal_add(struct acpi_device *device)
864
852
865
853
/* Get trip points [_CRT, _PSV, etc.] (required). */
866
854
trip_count = acpi_thermal_get_trip_points (tz );
855
+
856
+ crit_temp = acpi_thermal_get_critical_trip (tz );
857
+ if (tz -> trips .critical_valid )
858
+ trip_count ++ ;
859
+
860
+ hot_temp = acpi_thermal_get_hot_trip (tz );
861
+ if (tz -> trips .hot_valid )
862
+ trip_count ++ ;
863
+
867
864
if (!trip_count ) {
868
865
pr_warn (FW_BUG "No valid trip points!\n" );
869
866
result = - ENODEV ;
@@ -885,23 +882,23 @@ static int acpi_thermal_add(struct acpi_device *device)
885
882
else
886
883
acpi_thermal_get_polling_frequency (tz );
887
884
888
- acpi_thermal_guess_offset (tz );
885
+ acpi_thermal_guess_offset (tz , crit_temp );
889
886
890
887
trip = kcalloc (trip_count , sizeof (* trip ), GFP_KERNEL );
891
888
if (!trip )
892
889
return - ENOMEM ;
893
890
894
891
tz -> trip_table = trip ;
895
892
896
- if (tz -> trips .critical . valid ) {
893
+ if (tz -> trips .critical_valid ) {
897
894
trip -> type = THERMAL_TRIP_CRITICAL ;
898
- trip -> temperature = acpi_thermal_temp (tz , tz -> trips . critical . temperature );
895
+ trip -> temperature = acpi_thermal_temp (tz , crit_temp );
899
896
trip ++ ;
900
897
}
901
898
902
- if (tz -> trips .hot . valid ) {
899
+ if (tz -> trips .hot_valid ) {
903
900
trip -> type = THERMAL_TRIP_HOT ;
904
- trip -> temperature = acpi_thermal_temp (tz , tz -> trips . hot . temperature );
901
+ trip -> temperature = acpi_thermal_temp (tz , hot_temp );
905
902
trip ++ ;
906
903
}
907
904
0 commit comments