[U-Boot] [PATCH] lib/time - fix "usec_to_tick" calculation for hi freq system timers
Alexey Brodkin
Alexey.Brodkin at synopsys.com
Fri Dec 13 08:01:07 CET 2013
Hi Tom,
On Mon, 2013-12-09 at 16:57 +0400, Alexey Brodkin wrote:
> Current implementation works fine if "usec * get_tbclk()" fits in 32
> bits. Otherwise result will be cut down to 32-bit.
>
> Fix is obvious - first extend data type of either operand.
>
> Signed-off-by: Alexey Brodkin <abrodkin at synopsys.com>
>
> Cc: Rob Herring <rob.herring at calxeda.com>
> Cc: Mischa Jonker <mjonker at synopsys.com>
> ---
> lib/time.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/time.c b/lib/time.c
> index 09bb05a..80003c3 100644
> --- a/lib/time.c
> +++ b/lib/time.c
> @@ -71,7 +71,7 @@ unsigned long __weak notrace timer_get_us(void)
> }
> static unsigned long long usec_to_tick(unsigned long usec)
> {
> - uint64_t tick = usec * get_tbclk();
> + uint64_t tick = (uint64_t)usec * get_tbclk();
> usec *= get_tbclk();
> do_div(tick, 1000000);
> return tick;
Any chance to get it applied?
Regards,
Alexey
More information about the U-Boot
mailing list