All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iop: use generic clock mult/shift compute functions
@ 2009-12-29 15:26 Mikael Pettersson
  2010-01-08 17:26 ` Russell King - ARM Linux
  0 siblings, 1 reply; 3+ messages in thread
From: Mikael Pettersson @ 2009-12-29 15:26 UTC (permalink / raw)
  To: linux-arm-kernel

The 2.6.33-rc kernel now has generic functions for computing
mult and shift factors for clocksources and clockevents. Thus
we can remove the equivalent private code from the ARM IOP
platform and use the generic code instead.

Tested on an n2100 iop32x machine. Verfied to result in the
exact same mult and shift factors as before.

Signed-off-by: Mikael Pettersson <mikpe@it.uu.se>
---
 arch/arm/plat-iop/time.c |   50 +++++------------------------------------------
 1 file changed, 6 insertions(+), 44 deletions(-)

diff -rupN linux-2.6.33-rc2/arch/arm/plat-iop/time.c linux-2.6.33-rc2.arm-iop-use-generic-clock-mult-shift-functions/arch/arm/plat-iop/time.c
--- linux-2.6.33-rc2/arch/arm/plat-iop/time.c	2009-12-26 15:20:55.000000000 +0100
+++ linux-2.6.33-rc2.arm-iop-use-generic-clock-mult-shift-functions/arch/arm/plat-iop/time.c	2009-12-26 21:34:26.000000000 +0100
@@ -44,27 +44,6 @@ static struct clocksource iop_clocksourc
 	.flags		= CLOCK_SOURCE_IS_CONTINUOUS,
 };
 
-static void __init iop_clocksource_set_hz(struct clocksource *cs, unsigned int hz)
-{
-	u64 temp;
-	u32 shift;
-
-	/* Find shift and mult values for hz. */
-	shift = 32;
-	do {
-		temp = (u64) NSEC_PER_SEC << shift;
-		do_div(temp, hz);
-		if ((temp >> 32) == 0)
-			break;
-	} while (--shift != 0);
-
-	cs->shift = shift;
-	cs->mult = (u32) temp;
-
-	printk(KERN_INFO "clocksource: %s uses shift %u mult %#x\n",
-	       cs->name, cs->shift, cs->mult);
-}
-
 /*
  * IOP sched_clock() implementation via its clocksource.
  */
@@ -130,27 +109,6 @@ static struct clock_event_device iop_clo
 	.set_mode	= iop_set_mode,
 };
 
-static void __init iop_clockevent_set_hz(struct clock_event_device *ce, unsigned int hz)
-{
-	u64 temp;
-	u32 shift;
-
-	/* Find shift and mult values for hz. */
-	shift = 32;
-	do {
-		temp = (u64) hz << shift;
-		do_div(temp, NSEC_PER_SEC);
-		if ((temp >> 32) == 0)
-			break;
-	} while (--shift != 0);
-
-	ce->shift = shift;
-	ce->mult = (u32) temp;
-
-	printk(KERN_INFO "clockevent: %s uses shift %u mult %#lx\n",
-	       ce->name, ce->shift, ce->mult);
-}
-
 static irqreturn_t
 iop_timer_interrupt(int irq, void *dev_id)
 {
@@ -190,7 +148,9 @@ void __init iop_init_time(unsigned long 
 	 */
 	write_tmr0(timer_ctl & ~IOP_TMR_EN);
 	setup_irq(IRQ_IOP_TIMER0, &iop_timer_irq);
-	iop_clockevent_set_hz(&iop_clockevent, tick_rate);
+	clockevents_calc_mult_shift(&iop_clockevent, tick_rate, 4);
+	printk(KERN_INFO "clockevent: %s uses shift %u mult %#x\n",
+	       iop_clockevent.name, iop_clockevent.shift, iop_clockevent.mult);
 	iop_clockevent.max_delta_ns =
 		clockevent_delta2ns(0xfffffffe, &iop_clockevent);
 	iop_clockevent.min_delta_ns =
@@ -207,6 +167,8 @@ void __init iop_init_time(unsigned long 
 	write_trr1(0xffffffff);
 	write_tcr1(0xffffffff);
 	write_tmr1(timer_ctl);
-	iop_clocksource_set_hz(&iop_clocksource, tick_rate);
+	clocksource_calc_mult_shift(&iop_clocksource, tick_rate, 4);
+	printk(KERN_INFO "clocksource: %s uses shift %u mult %#x\n",
+	       iop_clocksource.name, iop_clocksource.shift, iop_clocksource.mult);
 	clocksource_register(&iop_clocksource);
 }

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] iop: use generic clock mult/shift compute functions
  2009-12-29 15:26 [PATCH] iop: use generic clock mult/shift compute functions Mikael Pettersson
@ 2010-01-08 17:26 ` Russell King - ARM Linux
  2010-01-09  0:30   ` Dan Williams
  0 siblings, 1 reply; 3+ messages in thread
From: Russell King - ARM Linux @ 2010-01-08 17:26 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Dec 29, 2009 at 04:26:41PM +0100, Mikael Pettersson wrote:
> The 2.6.33-rc kernel now has generic functions for computing
> mult and shift factors for clocksources and clockevents. Thus
> we can remove the equivalent private code from the ARM IOP
> platform and use the generic code instead.
> 
> Tested on an n2100 iop32x machine. Verfied to result in the
> exact same mult and shift factors as before.

Good, can we have it in the patch system please?

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] iop: use generic clock mult/shift compute functions
  2010-01-08 17:26 ` Russell King - ARM Linux
@ 2010-01-09  0:30   ` Dan Williams
  0 siblings, 0 replies; 3+ messages in thread
From: Dan Williams @ 2010-01-09  0:30 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, 2010-01-08 at 10:26 -0700, Russell King - ARM Linux wrote:
> On Tue, Dec 29, 2009 at 04:26:41PM +0100, Mikael Pettersson wrote:
> > The 2.6.33-rc kernel now has generic functions for computing
> > mult and shift factors for clocksources and clockevents. Thus
> > we can remove the equivalent private code from the ARM IOP
> > platform and use the generic code instead.
> > 
> > Tested on an n2100 iop32x machine. Verfied to result in the
> > exact same mult and shift factors as before.
> 
> Good, can we have it in the patch system please?

It's pushed out to the 'fixes' branch of xscaleiop.git.  Please pull
from:

git://git.kernel.org/pub/scm/linux/kernel/git/djbw/xscaleiop.git fixes

I was going to check it out on my iop13xx, but the board is occupied and
I doubt it will cause problems given the other testing.

--
Dan

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-01-09  0:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-12-29 15:26 [PATCH] iop: use generic clock mult/shift compute functions Mikael Pettersson
2010-01-08 17:26 ` Russell King - ARM Linux
2010-01-09  0:30   ` Dan Williams

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.