Skip to content

Commit 44295af

Browse files
Sanjay Chandrashekararafaeljw
authored andcommitted
cpufreq: use correct unit when verify cur freq
cpufreq_verify_current_freq checks() if the frequency returned by the hardware has a slight delta with the valid frequency value last set and returns "policy->cur" if the delta is within "1 MHz". In the comparison, "policy->cur" is in "kHz" but it's compared against HZ_PER_MHZ. So, the comparison range becomes "1 GHz". Fix this by comparing against KHZ_PER_MHZ instead of HZ_PER_MHZ. Fixes: f55ae08 ("cpufreq: Avoid unnecessary frequency updates due to mismatch") Signed-off-by: Sanjay Chandrashekara <sanjayc@nvidia.com> [ sumit gupta: Commit message update ] Signed-off-by: Sumit Gupta <sumitg@nvidia.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 6849522 commit 44295af

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

drivers/cpufreq/cpufreq.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1732,7 +1732,7 @@ static unsigned int cpufreq_verify_current_freq(struct cpufreq_policy *policy, b
17321732
* MHz. In such cases it is better to avoid getting into
17331733
* unnecessary frequency updates.
17341734
*/
1735-
if (abs(policy->cur - new_freq) < HZ_PER_MHZ)
1735+
if (abs(policy->cur - new_freq) < KHZ_PER_MHZ)
17361736
return policy->cur;
17371737

17381738
cpufreq_out_of_sync(policy, new_freq);

0 commit comments

Comments
 (0)