From a2b468f094846bca51c49c28c071accb46a18daa Mon Sep 17 00:00:00 2001 From: Zhang Zhuoyu Date: Wed, 21 May 2014 14:25:32 +0800 Subject: cpufreq/powerpc: Fix overflow on 32-bit OS and rounding errors 12*NSEC_PER_SEC will overflow on 32-bit OS. Besides, The transition latency is "12 internal platform clocks", rounding errors might lead to a result that it is shorter than 12 platform clocks which is not we expected. Signed-off-by: Zhang Zhuoyu Change-Id: Ic8627f70abb70e964abdec0a5b4d86aa15833a7d Reviewed-on: http://git.am.freescale.net:8181/12555 Tested-by: Review Code-CDREVIEW Reviewed-by: Yuantian Tang Reviewed-by: Jose Rivera diff --git a/drivers/cpufreq/ppc-corenet-cpufreq.c b/drivers/cpufreq/ppc-corenet-cpufreq.c index 79173af..4937dd3 100644 --- a/drivers/cpufreq/ppc-corenet-cpufreq.c +++ b/drivers/cpufreq/ppc-corenet-cpufreq.c @@ -217,7 +217,7 @@ static int corenet_cpufreq_cpu_init(struct cpufreq_policy *policy) per_cpu(cpu_data, i) = data; policy->cpuinfo.transition_latency = - (12 * NSEC_PER_SEC) / fsl_get_sys_freq(); + 12U * (NSEC_PER_SEC / fsl_get_sys_freq() + 1); policy->cur = corenet_cpufreq_get_speed(policy->cpu); cpufreq_frequency_table_get_attr(table, cpu); -- cgit v0.10.2