x86: tsc: use div64_u64() instead of do_div()
PATCH 1/1 x86: tsc: use div64_u64() instead of do_div()
From: Wang Qing <[email protected]>
do_div() does a 64-by-32 division.
When the divisor is u64, do_div() truncates it to 32 bits, this means it can test non-zero and be truncated to zero for division.
fix do_div.cocci warning:do_div() does a 64-by-32 division, please consider using div64_u64 instead.
Signed-off-by Wang Qing <[email protected]>
--- arch/x86/kernel/tsc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/tsc.c +1 -1
@@ -365,7 +365,7 @@ static unsigned long calc_pmtimer_ref(u64 deltatsc, u64 pm1, u64 pm2) pm2 -= pm1; tmp = pm2 *1000000000LL ;do_div (tmp,PMTMR_TICKS_PER_SEC ); -do_div (deltatsc, tmp); +div64_u64 (deltatsc, tmp);return (unsigned long ) deltatsc; }
Signature · 1 line
2.7.4