public inbox for linuxppc-dev@ozlabs.org 
 help / color / mirror / Atom feed
From: Anton Blanchard <anton@samba•org>
To: benh@kernel•crashing.org, paulus@samba•org, johnstul@us•ibm.com
Cc: linuxppc-dev@lists•ozlabs.org
Subject: [PATCH 1/4] powerpc/time: Use clockevents_calc_mult_shift
Date: Thu, 03 Nov 2011 11:59:23 +1100	[thread overview]
Message-ID: <20111103010111.868598561@samba.org> (raw)
In-Reply-To: 20111103005922.854058953@samba.org

We can use clockevents_calc_mult_shift instead of doing all
the work ourselves.

Signed-off-by: Anton Blanchard <anton@samba•org>
---

Index: linux-build/arch/powerpc/kernel/time.c
===================================================================
--- linux-build.orig/arch/powerpc/kernel/time.c	2011-11-03 10:19:55.225606490 +1100
+++ linux-build/arch/powerpc/kernel/time.c	2011-11-03 10:19:59.493679032 +1100
@@ -112,8 +112,6 @@ static void decrementer_set_mode(enum cl
 static struct clock_event_device decrementer_clockevent = {
        .name           = "decrementer",
        .rating         = 200,
-       .shift          = 0,	/* To be filled in */
-       .mult           = 0,	/* To be filled in */
        .irq            = 0,
        .set_next_event = decrementer_set_next_event,
        .set_mode       = decrementer_set_mode,
@@ -904,31 +902,6 @@ static void decrementer_set_mode(enum cl
 		decrementer_set_next_event(DECREMENTER_MAX, dev);
 }
 
-static inline uint64_t div_sc64(unsigned long ticks, unsigned long nsec,
-				int shift)
-{
-	uint64_t tmp = ((uint64_t)ticks) << shift;
-
-	do_div(tmp, nsec);
-	return tmp;
-}
-
-static void __init setup_clockevent_multiplier(unsigned long hz)
-{
-	u64 mult, shift = 32;
-
-	while (1) {
-		mult = div_sc64(hz, NSEC_PER_SEC, shift);
-		if (mult && (mult >> 32UL) == 0UL)
-			break;
-
-		shift--;
-	}
-
-	decrementer_clockevent.shift = shift;
-	decrementer_clockevent.mult = mult;
-}
-
 static void register_decrementer_clockevent(int cpu)
 {
 	struct clock_event_device *dec = &per_cpu(decrementers, cpu).event;
@@ -946,7 +919,8 @@ static void __init init_decrementer_cloc
 {
 	int cpu = smp_processor_id();
 
-	setup_clockevent_multiplier(ppc_tb_freq);
+	clockevents_calc_mult_shift(&decrementer_clockevent, ppc_tb_freq, 4);
+
 	decrementer_clockevent.max_delta_ns =
 		clockevent_delta2ns(DECREMENTER_MAX, &decrementer_clockevent);
 	decrementer_clockevent.min_delta_ns =

  reply	other threads:[~2011-11-03  0:59 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-03  0:59 [PATCH 0/4] PowerPC time fixes Anton Blanchard
2011-11-03  0:59 ` Anton Blanchard [this message]
2011-11-03  0:59 ` [PATCH 2/4] powerpc/time: Use clocksource_register_hz Anton Blanchard
2011-11-03 13:14   ` John Stultz
2011-11-05  0:55     ` Paul Mackerras
2011-11-07 18:26       ` john stultz
2011-11-03  0:59 ` [PATCH 3/4] powerpc/time: Remove unnecessary sanity check of decrementer expiration Anton Blanchard
2011-11-03  0:59 ` [PATCH 4/4] powerpc/time: Fix some style issues Anton Blanchard

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=20111103010111.868598561@samba.org \
    --to=anton@samba$(echo .)org \
    --cc=benh@kernel$(echo .)crashing.org \
    --cc=johnstul@us$(echo .)ibm.com \
    --cc=linuxppc-dev@lists$(echo .)ozlabs.org \
    --cc=paulus@samba$(echo .)org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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