public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Jörg-Volker Peetz" <jvpeetz@web.de>
To: linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/4] convert a few do_div user
Date: Tue, 18 Mar 2008 21:10:33 +0100	[thread overview]
Message-ID: <47E021B9.7030502@web.de> (raw)
In-Reply-To: <20080313004902.866970953@linux-m68k.org>

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>


  reply	other threads:[~2008-03-19 21:53 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-13  0:22 [PATCH 0/4] [RFC] cleanup 64bit divide API zippel
2008-03-13  0:22 ` [PATCH 1/4] introduce explicit signed/unsigned 64bit divide zippel
2008-03-13 10:13   ` Geert Uytterhoeven
2008-03-13 14:59     ` Roman Zippel
2008-03-13 20:34       ` Andrew Morton
2008-03-14 17:45         ` Roman Zippel
2008-03-13  0:22 ` [PATCH 2/4] convert a few do_div user zippel
2008-03-18 20:10   ` Jörg-Volker Peetz [this message]
2008-03-13  0:22 ` [PATCH 3/4] rename div64_64 to div64_u64 zippel
2008-03-13  0:22 ` [PATCH 4/4] remove div_long_long_rem zippel
2008-03-13  0:22 ` [PATCH 5/4] 2.6.25-rc5-mm1 specifc div64_u64 fixes zippel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=47E021B9.7030502@web.de \
    --to=jvpeetz@web.de \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox