[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20080508.012354.82382504.anemo@mba.ocn.ne.jp>
Date: Thu, 08 May 2008 01:23:54 +0900 (JST)
From: Atsushi Nemoto <anemo@....ocn.ne.jp>
To: dwalker@...sta.com
Cc: tglx@...utronix.de, akpm@...ux-foundation.org, johnstul@...ibm.com,
ralf@...ux-mips.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] clocksource: shift helper
On Tue, 06 May 2008 09:39:14 -0700, Daniel Walker <dwalker@...sta.com> wrote:
> > > This is a little helper I pulled from the mips tree.
> > ...
> > > Signed-off-by: Daniel Walker <dwalker@...sta.com>
> >
> > And who is the original author of this little helper in the MIPS tree?
>
> commit 16b7b2ac0148e839da86af8747b6fa4aad43a9b7
> Author: Atsushi Nemoto <anemo@....ocn.ne.jp>
I think Ralf's version is better starting point.
commit 93c846f9047f392fc2335668a5234edfbddb7cdc
Author: Ralf Baechle <ralf@...ux-mips.org>
Date: Fri Oct 19 08:13:08 2007 +0100
[MIPS] time: Helpers to compute clocksource/event shift and mult values.
These helpers are live in arch/mips/kernel/time.c now.
void __init clocksource_set_clock(struct clocksource *cs, unsigned int clock)
{
u64 temp;
u32 shift;
/* Find a shift value */
for (shift = 32; shift > 0; shift--) {
temp = (u64) NSEC_PER_SEC << shift;
do_div(temp, clock);
if ((temp >> 32) == 0)
break;
}
cs->shift = shift;
cs->mult = (u32) temp;
}
BTW, comparing this with clocksource_hz2mult(), inserting
temp += clock / 2;
to just before do_div() line might be better.
---
Atsushi Nemoto
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists