@@ -688,53 +688,10 @@ static void acpi_thermal_zone_sysfs_remove(struct acpi_thermal *tz)
688
688
}
689
689
690
690
static int acpi_thermal_register_thermal_zone (struct acpi_thermal * tz ,
691
- unsigned int trip_count )
691
+ unsigned int trip_count ,
692
+ int passive_delay )
692
693
{
693
- struct acpi_thermal_trip * acpi_trip ;
694
- struct thermal_trip * trip ;
695
- int passive_delay = 0 ;
696
694
int result ;
697
- int i ;
698
-
699
- trip = kcalloc (trip_count , sizeof (* trip ), GFP_KERNEL );
700
- if (!trip )
701
- return - ENOMEM ;
702
-
703
- tz -> trip_table = trip ;
704
-
705
- if (tz -> trips .critical .valid ) {
706
- trip -> type = THERMAL_TRIP_CRITICAL ;
707
- trip -> temperature = acpi_thermal_temp (tz , tz -> trips .critical .temperature );
708
- trip ++ ;
709
- }
710
-
711
- if (tz -> trips .hot .valid ) {
712
- trip -> type = THERMAL_TRIP_HOT ;
713
- trip -> temperature = acpi_thermal_temp (tz , tz -> trips .hot .temperature );
714
- trip ++ ;
715
- }
716
-
717
- acpi_trip = & tz -> trips .passive .trip ;
718
- if (acpi_trip -> valid ) {
719
- passive_delay = tz -> trips .passive .tsp * 100 ;
720
-
721
- trip -> type = THERMAL_TRIP_PASSIVE ;
722
- trip -> temperature = acpi_thermal_temp (tz , acpi_trip -> temperature );
723
- trip -> priv = acpi_trip ;
724
- trip ++ ;
725
- }
726
-
727
- for (i = 0 ; i < ACPI_THERMAL_MAX_ACTIVE ; i ++ ) {
728
- acpi_trip = & tz -> trips .active [i ].trip ;
729
-
730
- if (!acpi_trip -> valid )
731
- break ;
732
-
733
- trip -> type = THERMAL_TRIP_ACTIVE ;
734
- trip -> temperature = acpi_thermal_temp (tz , acpi_trip -> temperature );
735
- trip -> priv = acpi_trip ;
736
- trip ++ ;
737
- }
738
695
739
696
tz -> thermal_zone = thermal_zone_device_register_with_trips ("acpitz" ,
740
697
tz -> trip_table ,
@@ -744,10 +701,8 @@ static int acpi_thermal_register_thermal_zone(struct acpi_thermal *tz,
744
701
NULL ,
745
702
passive_delay ,
746
703
tz -> polling_frequency * 100 );
747
- if (IS_ERR (tz -> thermal_zone )) {
748
- result = PTR_ERR (tz -> thermal_zone );
749
- goto free_trip_table ;
750
- }
704
+ if (IS_ERR (tz -> thermal_zone ))
705
+ return PTR_ERR (tz -> thermal_zone );
751
706
752
707
result = acpi_thermal_zone_sysfs_add (tz );
753
708
if (result )
@@ -766,8 +721,6 @@ static int acpi_thermal_register_thermal_zone(struct acpi_thermal *tz,
766
721
acpi_thermal_zone_sysfs_remove (tz );
767
722
unregister_tzd :
768
723
thermal_zone_device_unregister (tz -> thermal_zone );
769
- free_trip_table :
770
- kfree (tz -> trip_table );
771
724
772
725
return result ;
773
726
}
@@ -886,9 +839,13 @@ static void acpi_thermal_check_fn(struct work_struct *work)
886
839
887
840
static int acpi_thermal_add (struct acpi_device * device )
888
841
{
842
+ struct acpi_thermal_trip * acpi_trip ;
843
+ struct thermal_trip * trip ;
889
844
struct acpi_thermal * tz ;
890
845
unsigned int trip_count ;
846
+ int passive_delay = 0 ;
891
847
int result ;
848
+ int i ;
892
849
893
850
if (!device )
894
851
return - EINVAL ;
@@ -930,9 +887,49 @@ static int acpi_thermal_add(struct acpi_device *device)
930
887
931
888
acpi_thermal_guess_offset (tz );
932
889
933
- result = acpi_thermal_register_thermal_zone (tz , trip_count );
890
+ trip = kcalloc (trip_count , sizeof (* trip ), GFP_KERNEL );
891
+ if (!trip )
892
+ return - ENOMEM ;
893
+
894
+ tz -> trip_table = trip ;
895
+
896
+ if (tz -> trips .critical .valid ) {
897
+ trip -> type = THERMAL_TRIP_CRITICAL ;
898
+ trip -> temperature = acpi_thermal_temp (tz , tz -> trips .critical .temperature );
899
+ trip ++ ;
900
+ }
901
+
902
+ if (tz -> trips .hot .valid ) {
903
+ trip -> type = THERMAL_TRIP_HOT ;
904
+ trip -> temperature = acpi_thermal_temp (tz , tz -> trips .hot .temperature );
905
+ trip ++ ;
906
+ }
907
+
908
+ acpi_trip = & tz -> trips .passive .trip ;
909
+ if (acpi_trip -> valid ) {
910
+ passive_delay = tz -> trips .passive .tsp * 100 ;
911
+
912
+ trip -> type = THERMAL_TRIP_PASSIVE ;
913
+ trip -> temperature = acpi_thermal_temp (tz , acpi_trip -> temperature );
914
+ trip -> priv = acpi_trip ;
915
+ trip ++ ;
916
+ }
917
+
918
+ for (i = 0 ; i < ACPI_THERMAL_MAX_ACTIVE ; i ++ ) {
919
+ acpi_trip = & tz -> trips .active [i ].trip ;
920
+
921
+ if (!acpi_trip -> valid )
922
+ break ;
923
+
924
+ trip -> type = THERMAL_TRIP_ACTIVE ;
925
+ trip -> temperature = acpi_thermal_temp (tz , acpi_trip -> temperature );
926
+ trip -> priv = acpi_trip ;
927
+ trip ++ ;
928
+ }
929
+
930
+ result = acpi_thermal_register_thermal_zone (tz , trip_count , passive_delay );
934
931
if (result )
935
- goto free_memory ;
932
+ goto free_trips ;
936
933
937
934
refcount_set (& tz -> thermal_check_count , 3 );
938
935
mutex_init (& tz -> thermal_check_lock );
@@ -951,6 +948,8 @@ static int acpi_thermal_add(struct acpi_device *device)
951
948
flush_wq :
952
949
flush_workqueue (acpi_thermal_pm_queue );
953
950
acpi_thermal_unregister_thermal_zone (tz );
951
+ free_trips :
952
+ kfree (tz -> trip_table );
954
953
free_memory :
955
954
kfree (tz );
956
955
0 commit comments