lkml.org 
[lkml]   [2008]   [Mar]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH 2/4] convert a few do_div user
Date
zippel@linux-m68k.org wrote:
> This converts a few users of do_div to div_[su]64 and this demonstrates
> nicely how it can reduce some expressions to one-liners.
>
> Signed-off-by: Roman Zippel <zippel@linux-m68k.org>
>
> ---
> kernel/time.c | 29 +++++++++--------------------
> kernel/time/ntp.c | 25 ++++++-------------------
> 2 files changed, 15 insertions(+), 39 deletions(-)
>
<snip>
> Index: linux-2.6/kernel/time/ntp.c
> ===================================================================
> --- linux-2.6.orig/kernel/time/ntp.c 2008-03-11 17:15:14.000000000 +0100
> +++ linux-2.6/kernel/time/ntp.c 2008-03-12 21:21:20.000000000 +0100
<snip>
> /*
> @@ -53,10 +53,8 @@ static void ntp_update_frequency(void)
>
> tick_length_base = second_length;
>
> - do_div(second_length, HZ);
> - tick_nsec = second_length >> TICK_LENGTH_SHIFT;
> -
> - do_div(tick_length_base, NTP_INTERVAL_FREQ);
> + tick_nsec = div_u64(second_length, HZ) >> TICK_LENGTH_SHIFT;
> + tick_length_base = div_u64(tick_length_base, NTP_INTERVAL_FREQ);
> }
>

Probably the compiler would optimize it, but maybe its clearer to change it this
way:

- tick_length_base = second_length;

- do_div(second_length, HZ);
- tick_nsec = second_length >> TICK_LENGTH_SHIFT;
-
- do_div(tick_length_base, NTP_INTERVAL_FREQ);
+ tick_nsec = div_u64(second_length, HZ) >> TICK_LENGTH_SHIFT;
+ tick_length_base = div_u64(second_length, NTP_INTERVAL_FREQ);

--
Regards,
Jörg-Volker.



<snip>

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2008-03-19 22:57    [W:0.079 / U:0.316 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site