mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: John Stultz <johnstul@us.ibm.com>
To: lkml <linux-kernel@vger.kernel.org>
Cc: John Stultz <johnstul@us.ibm.com>,
	Mike Frysinger <vapier@gentoo.org>,
	Thomas Gleixner <tglx@linutronix.de>
Subject: [PATCH 08/10] blackfin: convert to clocksource_register_hz
Date: Mon,  1 Nov 2010 13:12:28 -0700	[thread overview]
Message-ID: <1288642350-1599-9-git-send-email-johnstul@us.ibm.com> (raw)
In-Reply-To: <1288642350-1599-1-git-send-email-johnstul@us.ibm.com>

This converts the blackfin clocksource to use clocksource_register_hz.

This is untested, so any assistance in testing would be appreciated!

CC: Mike Frysinger <vapier@gentoo.org>
CC: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: John Stultz <johnstul@us.ibm.com>
---
 arch/blackfin/kernel/time-ts.c |   35 ++---------------------------------
 1 files changed, 2 insertions(+), 33 deletions(-)

diff --git a/arch/blackfin/kernel/time-ts.c b/arch/blackfin/kernel/time-ts.c
index 8c9a43d..4a01371 100644
--- a/arch/blackfin/kernel/time-ts.c
+++ b/arch/blackfin/kernel/time-ts.c
@@ -23,29 +23,6 @@
 #include <asm/gptimers.h>
 #include <asm/nmi.h>
 
-/* Accelerators for sched_clock()
- * convert from cycles(64bits) => nanoseconds (64bits)
- *  basic equation:
- *		ns = cycles / (freq / ns_per_sec)
- *		ns = cycles * (ns_per_sec / freq)
- *		ns = cycles * (10^9 / (cpu_khz * 10^3))
- *		ns = cycles * (10^6 / cpu_khz)
- *
- *	Then we use scaling math (suggested by george@mvista.com) to get:
- *		ns = cycles * (10^6 * SC / cpu_khz) / SC
- *		ns = cycles * cyc2ns_scale / SC
- *
- *	And since SC is a constant power of two, we can convert the div
- *  into a shift.
- *
- *  We can use khz divisor instead of mhz to keep a better precision, since
- *  cyc2ns_scale is limited to 10^6 * 2^10, which fits in 32 bits.
- *  (mathieu.desnoyers@polymtl.ca)
- *
- *			-johnstul@us.ibm.com "math is hard, lets go shopping!"
- */
-
-#define CYC2NS_SCALE_FACTOR 10 /* 2^10, carefully chosen */
 
 #if defined(CONFIG_CYCLES_CLOCKSOURCE)
 
@@ -63,7 +40,6 @@ static struct clocksource bfin_cs_cycles = {
 	.rating		= 400,
 	.read		= bfin_read_cycles,
 	.mask		= CLOCKSOURCE_MASK(64),
-	.shift		= CYC2NS_SCALE_FACTOR,
 	.flags		= CLOCK_SOURCE_IS_CONTINUOUS,
 };
 
@@ -75,10 +51,7 @@ static inline unsigned long long bfin_cs_cycles_sched_clock(void)
 
 static int __init bfin_cs_cycles_init(void)
 {
-	bfin_cs_cycles.mult = \
-		clocksource_hz2mult(get_cclk(), bfin_cs_cycles.shift);
-
-	if (clocksource_register(&bfin_cs_cycles))
+	if (clocksource_register_hz(&bfin_cs_cycles, get_cclk()))
 		panic("failed to register clocksource");
 
 	return 0;
@@ -111,7 +84,6 @@ static struct clocksource bfin_cs_gptimer0 = {
 	.rating		= 350,
 	.read		= bfin_read_gptimer0,
 	.mask		= CLOCKSOURCE_MASK(32),
-	.shift		= CYC2NS_SCALE_FACTOR,
 	.flags		= CLOCK_SOURCE_IS_CONTINUOUS,
 };
 
@@ -125,10 +97,7 @@ static int __init bfin_cs_gptimer0_init(void)
 {
 	setup_gptimer0();
 
-	bfin_cs_gptimer0.mult = \
-		clocksource_hz2mult(get_sclk(), bfin_cs_gptimer0.shift);
-
-	if (clocksource_register(&bfin_cs_gptimer0))
+	if (clocksource_register_hz(&bfin_cs_gptimer0, get_sclk()))
 		panic("failed to register clocksource");
 
 	return 0;
-- 
1.7.3.2.146.gca209


  parent reply	other threads:[~2010-11-01 20:13 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-01 20:12 [PATCH 00/10] clocksource_register_khz/hz cleanups (for 2.6.38) John Stultz
2010-11-01 20:12 ` [PATCH 01/10] x86: Convert untested clocksources to clocksource_register_hz/khz John Stultz
2010-11-01 20:12 ` [PATCH 02/10] ia64: convert " John Stultz
2010-11-01 20:12 ` [PATCH 03/10] cris: convert to clocksource_register_khz John Stultz
2010-11-01 20:12 ` [PATCH 04/10] tile: convert to use clocksource_register_hz John Stultz
2010-11-11 21:21   ` Chris Metcalf
2010-11-11 22:06     ` john stultz
2010-11-11 22:22       ` Peter Zijlstra
2010-11-11 23:21         ` john stultz
2010-11-11 22:17     ` john stultz
2010-11-01 20:12 ` [PATCH 05/10] parisc: convert to clocksource_register_hz/khz John Stultz
2010-11-01 20:12 ` [PATCH 06/10] microblaze: " John Stultz
2010-11-10 13:10   ` Michal Simek
2010-11-01 20:12 ` [PATCH 07/10] avr32: Convert to clocksource_register_hz John Stultz
2010-11-01 20:12 ` John Stultz [this message]
2010-11-01 20:12 ` [PATCH 09/10] xtensa: convert to clocksource_register_hz/khz John Stultz
2010-11-01 20:12 ` [PATCH 10/10] sparc: " John Stultz

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=1288642350-1599-9-git-send-email-johnstul@us.ibm.com \
    --to=johnstul@us.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=vapier@gentoo.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

Powered by JetHome