[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <47E021B9.7030502@web.de>
Date: Tue, 18 Mar 2008 21:10:33 +0100
From: Jörg-Volker Peetz <jvpeetz@....de>
To: linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/4] convert a few do_div user
zippel@...ux-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@...ux-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@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists