@@ -776,8 +776,8 @@ int cpufreq_frequency_table_verify(struct cpufreq_policy_data *policy,
776776int cpufreq_generic_frequency_table_verify (struct cpufreq_policy_data * policy );
777777
778778int 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 );
781781int cpufreq_frequency_table_get_index (struct cpufreq_policy * policy ,
782782 unsigned int freq );
783783
@@ -840,12 +840,12 @@ static inline int cpufreq_table_find_index_dl(struct cpufreq_policy *policy,
840840 return best ;
841841}
842842
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 )
847847{
848- target_freq = clamp_val (target_freq , policy -> min , policy -> max );
848+ target_freq = clamp_val (target_freq , min , max );
849849
850850 if (policy -> freq_table_sorted == CPUFREQ_TABLE_SORTED_ASCENDING )
851851 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,
855855 efficiencies );
856856}
857857
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+
858866/* Find highest freq at or below target in a table in ascending order */
859867static inline int cpufreq_table_find_index_ah (struct cpufreq_policy * policy ,
860868 unsigned int target_freq ,
@@ -908,12 +916,12 @@ static inline int cpufreq_table_find_index_dh(struct cpufreq_policy *policy,
908916 return best ;
909917}
910918
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 )
915923{
916- target_freq = clamp_val (target_freq , policy -> min , policy -> max );
924+ target_freq = clamp_val (target_freq , min , max );
917925
918926 if (policy -> freq_table_sorted == CPUFREQ_TABLE_SORTED_ASCENDING )
919927 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,
923931 efficiencies );
924932}
925933
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+
926942/* Find closest freq to target in a table in ascending order */
927943static inline int cpufreq_table_find_index_ac (struct cpufreq_policy * policy ,
928944 unsigned int target_freq ,
@@ -993,12 +1009,12 @@ static inline int cpufreq_table_find_index_dc(struct cpufreq_policy *policy,
9931009 return best ;
9941010}
9951011
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 )
10001016{
1001- target_freq = clamp_val (target_freq , policy -> min , policy -> max );
1017+ target_freq = clamp_val (target_freq , min , max );
10021018
10031019 if (policy -> freq_table_sorted == CPUFREQ_TABLE_SORTED_ASCENDING )
10041020 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,
10081024 efficiencies );
10091025}
10101026
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 )
10121038{
10131039 unsigned int freq ;
10141040
@@ -1017,11 +1043,13 @@ static inline bool cpufreq_is_in_limits(struct cpufreq_policy *policy, int idx)
10171043
10181044 freq = policy -> freq_table [idx ].frequency ;
10191045
1020- return freq == clamp_val (freq , policy -> min , policy -> max );
1046+ return freq == clamp_val (freq , min , max );
10211047}
10221048
10231049static inline int cpufreq_frequency_table_target (struct cpufreq_policy * policy ,
10241050 unsigned int target_freq ,
1051+ unsigned int min ,
1052+ unsigned int max ,
10251053 unsigned int relation )
10261054{
10271055 bool efficiencies = policy -> efficiencies_available &&
@@ -1032,29 +1060,26 @@ static inline int cpufreq_frequency_table_target(struct cpufreq_policy *policy,
10321060 relation &= ~CPUFREQ_RELATION_E ;
10331061
10341062 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 );
10371065retry :
10381066 switch (relation ) {
10391067 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 );
10421069 break ;
10431070 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 );
10461072 break ;
10471073 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 );
10501075 break ;
10511076 default :
10521077 WARN_ON_ONCE (1 );
10531078 return 0 ;
10541079 }
10551080
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 ) {
10581083 efficiencies = false;
10591084 goto retry ;
10601085 }
0 commit comments