Re: [PATCH 2/4] convert a few do_div user

From: Jörg-Volker Peetz
Date: Wed Mar 19 2008 - 17:53:38 EST


zippel@xxxxxxxxxxxxxx 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@xxxxxxxxxxxxxx>

---
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@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/