diff options
author | Wang Dongsheng <dongsheng.wang@freescale.com> | 2014-01-06 05:23:31 (GMT) |
---|---|---|
committer | Jose Rivera <German.Rivera@freescale.com> | 2014-03-28 13:47:48 (GMT) |
commit | 0f29c61a33d2832e770d5e8b0849e4a76b58a91e (patch) | |
tree | 9d807d3414809cb1a3a11c753b7fab1646889bd8 /arch | |
parent | 3efc8d30ebd3f5138d5940dbc6bbc75e6bceed52 (diff) | |
download | linux-fsl-qoriq-0f29c61a33d2832e770d5e8b0849e4a76b58a91e.tar.xz |
powerpc/mpic_timer: fix convert ticks to time subtraction overflow
In some cases tmp_sec may be greater than ticks, because in the process
of calculation ticks and tmp_sec will be rounded.
Signed-off-by: Wang Dongsheng <dongsheng.wang@freescale.com>
Signed-off-by: Scott Wood <scottwood@freescale.com>
Change-Id: I9bad7ea037144da4e1b3a00e6af52f8687f01ffe
Reviewed-on: http://git.am.freescale.net:8181/10341
Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com>
Reviewed-by: Jose Rivera <German.Rivera@freescale.com>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/powerpc/sysdev/mpic_timer.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/arch/powerpc/sysdev/mpic_timer.c b/arch/powerpc/sysdev/mpic_timer.c index 70dcf9c..9d9b062 100644 --- a/arch/powerpc/sysdev/mpic_timer.c +++ b/arch/powerpc/sysdev/mpic_timer.c @@ -97,8 +97,11 @@ static void convert_ticks_to_time(struct timer_group_priv *priv, time->tv_sec = (__kernel_time_t)div_u64(ticks, priv->timerfreq); tmp_sec = (u64)time->tv_sec * (u64)priv->timerfreq; - time->tv_usec = (__kernel_suseconds_t) - div_u64((ticks - tmp_sec) * 1000000, priv->timerfreq); + time->tv_usec = 0; + + if (tmp_sec <= ticks) + time->tv_usec = (__kernel_suseconds_t) + div_u64((ticks - tmp_sec) * 1000000, priv->timerfreq); return; } |