summaryrefslogtreecommitdiff
path: root/arch/blackfin
diff options
context:
space:
mode:
authorYi Li <yi.li@analog.com>2009-09-15 08:55:47 +0000
committerMike Frysinger <vapier@gentoo.org>2009-12-15 00:13:43 -0500
commit298571249a1990cd3c6c6ab40250a4a9c18ab5d1 (patch)
tree5fb7f04e8b68b80e4b3925116664a280cf22cd8c /arch/blackfin
parentceb33be95afcfbc4079af334835a345288f9f6ca (diff)
downloadlinux-298571249a1990cd3c6c6ab40250a4a9c18ab5d1.tar.gz
linux-298571249a1990cd3c6c6ab40250a4a9c18ab5d1.tar.xz
Blackfin: use common code for cycle->nanosecond conversion
No point in redefining things that common code already does for us. Also use CYC2NS_SCALE_FACTOR to better reflect reality and for better precision. Signed-off-by: Yi Li <yi.li@analog.com> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'arch/blackfin')
-rw-r--r--arch/blackfin/kernel/time-ts.c26
1 files changed, 4 insertions, 22 deletions
diff --git a/arch/blackfin/kernel/time-ts.c b/arch/blackfin/kernel/time-ts.c
index 2855f0ff865c..eef528389d2f 100644
--- a/arch/blackfin/kernel/time-ts.c
+++ b/arch/blackfin/kernel/time-ts.c
@@ -46,20 +46,8 @@
#define CYC2NS_SCALE_FACTOR 10 /* 2^10, carefully chosen */
-static inline unsigned long cyc2ns_scale(unsigned long cpu_khz)
-{
- return (1000000 << CYC2NS_SCALE_FACTOR) / cpu_khz;
-}
-
-static inline unsigned long long cycles_2_ns(cycle_t cyc, unsigned long cyc2ns_scale)
-{
- return (cyc * cyc2ns_scale) >> CYC2NS_SCALE_FACTOR;
-}
-
#if defined(CONFIG_CYCLES_CLOCKSOURCE)
-static unsigned long cycles_cyc2ns_scale;
-
static notrace cycle_t bfin_read_cycles(struct clocksource *cs)
{
return __bfin_cycles_off + (get_cycles() << __bfin_cycles_mod);
@@ -70,19 +58,17 @@ static struct clocksource bfin_cs_cycles = {
.rating = 400,
.read = bfin_read_cycles,
.mask = CLOCKSOURCE_MASK(64),
- .shift = 22,
+ .shift = CYC2NS_SCALE_FACTOR,
.flags = CLOCK_SOURCE_IS_CONTINUOUS,
};
static inline unsigned long long bfin_cs_cycles_sched_clock(void)
{
- return cycles_2_ns(bfin_read_cycles(&bfin_cs_cycles), cycles_cyc2ns_scale);
+ return cyc2ns(&bfin_cs_cycles, bfin_read_cycles(&bfin_cs_cycles));
}
static int __init bfin_cs_cycles_init(void)
{
- cycles_cyc2ns_scale = cyc2ns_scale(get_cclk() / 1000);
-
bfin_cs_cycles.mult = \
clocksource_hz2mult(get_cclk(), bfin_cs_cycles.shift);
@@ -97,8 +83,6 @@ static int __init bfin_cs_cycles_init(void)
#ifdef CONFIG_GPTMR0_CLOCKSOURCE
-unsigned long gptimer0_cyc2ns_scale;
-
void __init setup_gptimer0(void)
{
disable_gptimers(TIMER0bit);
@@ -121,19 +105,17 @@ static struct clocksource bfin_cs_gptimer0 = {
.rating = 350,
.read = bfin_read_gptimer0,
.mask = CLOCKSOURCE_MASK(32),
- .shift = 22,
+ .shift = CYC2NS_SCALE_FACTOR,
.flags = CLOCK_SOURCE_IS_CONTINUOUS,
};
static inline unsigned long long bfin_cs_gptimer0_sched_clock(void)
{
- return cycles_2_ns(bfin_read_TIMER0_COUNTER(), gptimer0_cyc2ns_scale);
+ return cyc2ns(&bfin_cs_gptimer0, bfin_read_TIMER0_COUNTER());
}
static int __init bfin_cs_gptimer0_init(void)
{
- gptimer0_cyc2ns_scale = cyc2ns_scale(get_sclk() / 1000);
-
setup_gptimer0();
bfin_cs_gptimer0.mult = \