@@ -573,11 +573,11 @@ int iwl_mvm_send_temp_report_ths_cmd(struct iwl_mvm *mvm)
573
573
* and uncompressed, the FW should get it compressed and sorted
574
574
*/
575
575
576
- /* compress temp_trips to cmd array, remove uninitialized values*/
576
+ /* compress trips to cmd array, remove uninitialized values*/
577
577
for (i = 0 ; i < IWL_MAX_DTS_TRIPS ; i ++ ) {
578
- if (mvm -> tz_device .temp_trips [i ] != S16_MIN ) {
578
+ if (mvm -> tz_device .trips [i ]. temperature != INT_MIN ) {
579
579
cmd .thresholds [idx ++ ] =
580
- cpu_to_le16 (mvm -> tz_device .temp_trips [i ]);
580
+ cpu_to_le16 (( s16 )( mvm -> tz_device .trips [i ]. temperature / 1000 ) );
581
581
}
582
582
}
583
583
cmd .num_temps = cpu_to_le32 (idx );
@@ -593,8 +593,8 @@ int iwl_mvm_send_temp_report_ths_cmd(struct iwl_mvm *mvm)
593
593
*/
594
594
for (i = 0 ; i < idx ; i ++ ) {
595
595
for (j = 0 ; j < IWL_MAX_DTS_TRIPS ; j ++ ) {
596
- if (le16_to_cpu (cmd .thresholds [i ]) ==
597
- mvm -> tz_device .temp_trips [j ])
596
+ if (( int )( le16_to_cpu (cmd .thresholds [i ]) * 1000 ) ==
597
+ mvm -> tz_device .trips [j ]. temperature )
598
598
mvm -> tz_device .fw_trips_index [i ] = j ;
599
599
}
600
600
}
@@ -638,37 +638,12 @@ static int iwl_mvm_tzone_get_temp(struct thermal_zone_device *device,
638
638
return ret ;
639
639
}
640
640
641
- static int iwl_mvm_tzone_get_trip_temp (struct thermal_zone_device * device ,
642
- int trip , int * temp )
643
- {
644
- struct iwl_mvm * mvm = (struct iwl_mvm * )device -> devdata ;
645
-
646
- if (trip < 0 || trip >= IWL_MAX_DTS_TRIPS )
647
- return - EINVAL ;
648
-
649
- * temp = mvm -> tz_device .temp_trips [trip ] * 1000 ;
650
-
651
- return 0 ;
652
- }
653
-
654
- static int iwl_mvm_tzone_get_trip_type (struct thermal_zone_device * device ,
655
- int trip , enum thermal_trip_type * type )
656
- {
657
- if (trip < 0 || trip >= IWL_MAX_DTS_TRIPS )
658
- return - EINVAL ;
659
-
660
- * type = THERMAL_TRIP_PASSIVE ;
661
-
662
- return 0 ;
663
- }
664
-
665
641
static int iwl_mvm_tzone_set_trip_temp (struct thermal_zone_device * device ,
666
642
int trip , int temp )
667
643
{
668
644
struct iwl_mvm * mvm = (struct iwl_mvm * )device -> devdata ;
669
645
struct iwl_mvm_thermal_device * tzone ;
670
- int i , ret ;
671
- s16 temperature ;
646
+ int ret ;
672
647
673
648
mutex_lock (& mvm -> mutex );
674
649
@@ -678,40 +653,17 @@ static int iwl_mvm_tzone_set_trip_temp(struct thermal_zone_device *device,
678
653
goto out ;
679
654
}
680
655
681
- if (trip < 0 || trip >= IWL_MAX_DTS_TRIPS ) {
682
- ret = - EINVAL ;
683
- goto out ;
684
- }
685
-
686
656
if ((temp / 1000 ) > S16_MAX ) {
687
657
ret = - EINVAL ;
688
658
goto out ;
689
659
}
690
660
691
- temperature = (s16 )(temp / 1000 );
692
661
tzone = & mvm -> tz_device ;
693
-
694
662
if (!tzone ) {
695
663
ret = - EIO ;
696
664
goto out ;
697
665
}
698
666
699
- /* no updates*/
700
- if (tzone -> temp_trips [trip ] == temperature ) {
701
- ret = 0 ;
702
- goto out ;
703
- }
704
-
705
- /* already existing temperature */
706
- for (i = 0 ; i < IWL_MAX_DTS_TRIPS ; i ++ ) {
707
- if (tzone -> temp_trips [i ] == temperature ) {
708
- ret = - EINVAL ;
709
- goto out ;
710
- }
711
- }
712
-
713
- tzone -> temp_trips [trip ] = temperature ;
714
-
715
667
ret = iwl_mvm_send_temp_report_ths_cmd (mvm );
716
668
out :
717
669
mutex_unlock (& mvm -> mutex );
@@ -720,8 +672,6 @@ static int iwl_mvm_tzone_set_trip_temp(struct thermal_zone_device *device,
720
672
721
673
static struct thermal_zone_device_ops tzone_ops = {
722
674
.get_temp = iwl_mvm_tzone_get_temp ,
723
- .get_trip_temp = iwl_mvm_tzone_get_trip_temp ,
724
- .get_trip_type = iwl_mvm_tzone_get_trip_type ,
725
675
.set_trip_temp = iwl_mvm_tzone_set_trip_temp ,
726
676
};
727
677
@@ -743,7 +693,8 @@ static void iwl_mvm_thermal_zone_register(struct iwl_mvm *mvm)
743
693
BUILD_BUG_ON (ARRAY_SIZE (name ) >= THERMAL_NAME_LENGTH );
744
694
745
695
sprintf (name , "iwlwifi_%u" , atomic_inc_return (& counter ) & 0xFF );
746
- mvm -> tz_device .tzone = thermal_zone_device_register (name ,
696
+ mvm -> tz_device .tzone = thermal_zone_device_register_with_trips (name ,
697
+ mvm -> tz_device .trips ,
747
698
IWL_MAX_DTS_TRIPS ,
748
699
IWL_WRITABLE_TRIPS_MSK ,
749
700
mvm , & tzone_ops ,
@@ -766,8 +717,10 @@ static void iwl_mvm_thermal_zone_register(struct iwl_mvm *mvm)
766
717
/* 0 is a valid temperature,
767
718
* so initialize the array with S16_MIN which invalid temperature
768
719
*/
769
- for (i = 0 ; i < IWL_MAX_DTS_TRIPS ; i ++ )
770
- mvm -> tz_device .temp_trips [i ] = S16_MIN ;
720
+ for (i = 0 ; i < IWL_MAX_DTS_TRIPS ; i ++ ) {
721
+ mvm -> tz_device .trips [i ].temperature = INT_MIN ;
722
+ mvm -> tz_device .trips [i ].type = THERMAL_TRIP_PASSIVE ;
723
+ }
771
724
}
772
725
773
726
static int iwl_mvm_tcool_get_max_state (struct thermal_cooling_device * cdev ,
0 commit comments