@@ -776,8 +776,8 @@ int cpufreq_frequency_table_verify(struct cpufreq_policy_data *policy,
776
776
int cpufreq_generic_frequency_table_verify (struct cpufreq_policy_data * policy );
777
777
778
778
int cpufreq_table_index_unsorted (struct cpufreq_policy * policy ,
779
- unsigned int target_freq ,
780
- unsigned int relation );
779
+ unsigned int target_freq , unsigned int min ,
780
+ unsigned int max , unsigned int relation );
781
781
int cpufreq_frequency_table_get_index (struct cpufreq_policy * policy ,
782
782
unsigned int freq );
783
783
@@ -840,12 +840,12 @@ static inline int cpufreq_table_find_index_dl(struct cpufreq_policy *policy,
840
840
return best ;
841
841
}
842
842
843
- /* Works only on sorted freq-tables */
844
- static inline int cpufreq_table_find_index_l ( struct cpufreq_policy * policy ,
845
- unsigned int target_freq ,
846
- bool efficiencies )
843
+ static inline int find_index_l ( struct cpufreq_policy * policy ,
844
+ unsigned int target_freq ,
845
+ unsigned int min , unsigned int max ,
846
+ bool efficiencies )
847
847
{
848
- target_freq = clamp_val (target_freq , policy -> min , policy -> max );
848
+ target_freq = clamp_val (target_freq , min , max );
849
849
850
850
if (policy -> freq_table_sorted == CPUFREQ_TABLE_SORTED_ASCENDING )
851
851
return cpufreq_table_find_index_al (policy , target_freq ,
@@ -855,6 +855,14 @@ static inline int cpufreq_table_find_index_l(struct cpufreq_policy *policy,
855
855
efficiencies );
856
856
}
857
857
858
+ /* Works only on sorted freq-tables */
859
+ static inline int cpufreq_table_find_index_l (struct cpufreq_policy * policy ,
860
+ unsigned int target_freq ,
861
+ bool efficiencies )
862
+ {
863
+ return find_index_l (policy , target_freq , policy -> min , policy -> max , efficiencies );
864
+ }
865
+
858
866
/* Find highest freq at or below target in a table in ascending order */
859
867
static inline int cpufreq_table_find_index_ah (struct cpufreq_policy * policy ,
860
868
unsigned int target_freq ,
@@ -908,12 +916,12 @@ static inline int cpufreq_table_find_index_dh(struct cpufreq_policy *policy,
908
916
return best ;
909
917
}
910
918
911
- /* Works only on sorted freq-tables */
912
- static inline int cpufreq_table_find_index_h ( struct cpufreq_policy * policy ,
913
- unsigned int target_freq ,
914
- bool efficiencies )
919
+ static inline int find_index_h ( struct cpufreq_policy * policy ,
920
+ unsigned int target_freq ,
921
+ unsigned int min , unsigned int max ,
922
+ bool efficiencies )
915
923
{
916
- target_freq = clamp_val (target_freq , policy -> min , policy -> max );
924
+ target_freq = clamp_val (target_freq , min , max );
917
925
918
926
if (policy -> freq_table_sorted == CPUFREQ_TABLE_SORTED_ASCENDING )
919
927
return cpufreq_table_find_index_ah (policy , target_freq ,
@@ -923,6 +931,14 @@ static inline int cpufreq_table_find_index_h(struct cpufreq_policy *policy,
923
931
efficiencies );
924
932
}
925
933
934
+ /* Works only on sorted freq-tables */
935
+ static inline int cpufreq_table_find_index_h (struct cpufreq_policy * policy ,
936
+ unsigned int target_freq ,
937
+ bool efficiencies )
938
+ {
939
+ return find_index_h (policy , target_freq , policy -> min , policy -> max , efficiencies );
940
+ }
941
+
926
942
/* Find closest freq to target in a table in ascending order */
927
943
static inline int cpufreq_table_find_index_ac (struct cpufreq_policy * policy ,
928
944
unsigned int target_freq ,
@@ -993,12 +1009,12 @@ static inline int cpufreq_table_find_index_dc(struct cpufreq_policy *policy,
993
1009
return best ;
994
1010
}
995
1011
996
- /* Works only on sorted freq-tables */
997
- static inline int cpufreq_table_find_index_c ( struct cpufreq_policy * policy ,
998
- unsigned int target_freq ,
999
- bool efficiencies )
1012
+ static inline int find_index_c ( struct cpufreq_policy * policy ,
1013
+ unsigned int target_freq ,
1014
+ unsigned int min , unsigned int max ,
1015
+ bool efficiencies )
1000
1016
{
1001
- target_freq = clamp_val (target_freq , policy -> min , policy -> max );
1017
+ target_freq = clamp_val (target_freq , min , max );
1002
1018
1003
1019
if (policy -> freq_table_sorted == CPUFREQ_TABLE_SORTED_ASCENDING )
1004
1020
return cpufreq_table_find_index_ac (policy , target_freq ,
@@ -1008,7 +1024,17 @@ static inline int cpufreq_table_find_index_c(struct cpufreq_policy *policy,
1008
1024
efficiencies );
1009
1025
}
1010
1026
1011
- static inline bool cpufreq_is_in_limits (struct cpufreq_policy * policy , int idx )
1027
+ /* Works only on sorted freq-tables */
1028
+ static inline int cpufreq_table_find_index_c (struct cpufreq_policy * policy ,
1029
+ unsigned int target_freq ,
1030
+ bool efficiencies )
1031
+ {
1032
+ return find_index_c (policy , target_freq , policy -> min , policy -> max , efficiencies );
1033
+ }
1034
+
1035
+ static inline bool cpufreq_is_in_limits (struct cpufreq_policy * policy ,
1036
+ unsigned int min , unsigned int max ,
1037
+ int idx )
1012
1038
{
1013
1039
unsigned int freq ;
1014
1040
@@ -1017,11 +1043,13 @@ static inline bool cpufreq_is_in_limits(struct cpufreq_policy *policy, int idx)
1017
1043
1018
1044
freq = policy -> freq_table [idx ].frequency ;
1019
1045
1020
- return freq == clamp_val (freq , policy -> min , policy -> max );
1046
+ return freq == clamp_val (freq , min , max );
1021
1047
}
1022
1048
1023
1049
static inline int cpufreq_frequency_table_target (struct cpufreq_policy * policy ,
1024
1050
unsigned int target_freq ,
1051
+ unsigned int min ,
1052
+ unsigned int max ,
1025
1053
unsigned int relation )
1026
1054
{
1027
1055
bool efficiencies = policy -> efficiencies_available &&
@@ -1032,29 +1060,26 @@ static inline int cpufreq_frequency_table_target(struct cpufreq_policy *policy,
1032
1060
relation &= ~CPUFREQ_RELATION_E ;
1033
1061
1034
1062
if (unlikely (policy -> freq_table_sorted == CPUFREQ_TABLE_UNSORTED ))
1035
- return cpufreq_table_index_unsorted (policy , target_freq ,
1036
- relation );
1063
+ return cpufreq_table_index_unsorted (policy , target_freq , min ,
1064
+ max , relation );
1037
1065
retry :
1038
1066
switch (relation ) {
1039
1067
case CPUFREQ_RELATION_L :
1040
- idx = cpufreq_table_find_index_l (policy , target_freq ,
1041
- efficiencies );
1068
+ idx = find_index_l (policy , target_freq , min , max , efficiencies );
1042
1069
break ;
1043
1070
case CPUFREQ_RELATION_H :
1044
- idx = cpufreq_table_find_index_h (policy , target_freq ,
1045
- efficiencies );
1071
+ idx = find_index_h (policy , target_freq , min , max , efficiencies );
1046
1072
break ;
1047
1073
case CPUFREQ_RELATION_C :
1048
- idx = cpufreq_table_find_index_c (policy , target_freq ,
1049
- efficiencies );
1074
+ idx = find_index_c (policy , target_freq , min , max , efficiencies );
1050
1075
break ;
1051
1076
default :
1052
1077
WARN_ON_ONCE (1 );
1053
1078
return 0 ;
1054
1079
}
1055
1080
1056
- /* Limit frequency index to honor policy-> min/ max */
1057
- if (!cpufreq_is_in_limits (policy , idx ) && efficiencies ) {
1081
+ /* Limit frequency index to honor min and max */
1082
+ if (!cpufreq_is_in_limits (policy , min , max , idx ) && efficiencies ) {
1058
1083
efficiencies = false;
1059
1084
goto retry ;
1060
1085
}
0 commit comments