linux-mips
[Top] [All Lists]

Re: [PATCH] Make MIPS dynamic clocksource/clockevent clock code generic

To: Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH] Make MIPS dynamic clocksource/clockevent clock code generic
From: Mikael Pettersson <mikpe@it.uu.se>
Date: Tue, 20 Oct 2009 10:19:12 +0200
Cc: Linus Walleij <linus.walleij@stericsson.com>, linux-mips@linux-mips.org, Ralf Baechle <ralf@linux-mips.org>, Mikael Pettersson <mikpe@it.uu.se>, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org
In-reply-to: <alpine.LFD.2.00.0910200454300.2863@localhost.localdomain>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <1255819715-19763-1-git-send-email-linus.walleij@stericsson.com> <alpine.LFD.2.00.0910200454300.2863@localhost.localdomain>
Sender: linux-mips-bounce@linux-mips.org
Thomas Gleixner writes:
 > > +static inline void clockevent_set_clock(struct clock_event_device *dev, 
 > > u32 hz)
 > > +{
 > > +  u64 temp;
 > > +  u32 shift;
 > > +
 > > +  /* Find a shift value */
 > > +  for (shift = 32; shift > 0; shift--) {
 > > +          temp = (u64) hz << shift;
 > > +          do_div(temp, NSEC_PER_SEC);
 > > +          if ((temp >> 32) == 0)
 > > +                  break;
 > > +  }
 > > +  dev->shift = shift;
 > > +  dev->mult = (u32) temp;
 > > +}
 > > +
 > > +
 > > +static inline void clocksource_set_clock(struct clocksource *cs, u32 hz)
 > > +{
 > > +  u64 temp;
 > > +  u32 shift;
 > > +
 > > +  /* Find a shift value */
 > > +  for (shift = 32; shift > 0; shift--) {
 > > +          temp = (u64) NSEC_PER_SEC << shift;
 > > +          do_div(temp, hz);
 > > +          if ((temp >> 32) == 0)
 > > +                  break;
 > > +  }
 > > +  cs->shift = shift;
 > > +  cs->mult = (u32) temp;
 > > +}
 > > +
 > 
 > So that's the same function twice, right ?

They are similar but not identical:

 > > +          temp = (u64) hz << shift;
 > > +          do_div(temp, NSEC_PER_SEC);

vs

 > > +          temp = (u64) NSEC_PER_SEC << shift;
 > > +          do_div(temp, hz);

I suppose both functions could be implemented by a suitably
parametric third function, but IMO that would just obscure things.

Making them non-inline I fully agree with.

<Prev in Thread] Current Thread [Next in Thread>