Linux MIPS Architecture development
 help / color / mirror / Atom feed
From: Mikael Pettersson <mikpe@it.uu.se>
To: Thomas Gleixner <tglx@linutronix.de>
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
Subject: Re: [PATCH] Make MIPS dynamic clocksource/clockevent clock code generic
Date: Tue, 20 Oct 2009 10:19:12 +0200	[thread overview]
Message-ID: <19165.29312.300540.500942@pilspetsen.it.uu.se> (raw)
In-Reply-To: <alpine.LFD.2.00.0910200454300.2863@localhost.localdomain>

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.

  reply	other threads:[~2009-10-20  8:19 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-17 22:48 [PATCH] Make MIPS dynamic clocksource/clockevent clock code generic Linus Walleij
2009-10-18 22:10 ` Mikael Pettersson
2009-10-19  5:17 ` Shane McDonald
2009-10-19  5:17   ` Shane McDonald
2009-10-20  2:25 ` Ralf Baechle
2009-10-20  3:50 ` Thomas Gleixner
2009-10-20  8:19   ` Mikael Pettersson [this message]
2009-10-20 21:27   ` Linus Walleij
2009-10-20 21:27     ` Linus Walleij
2009-10-20 21:56   ` David Daney
2009-10-20 22:16     ` Linus Walleij
2009-10-20 22:16       ` Linus Walleij
2009-10-20 22:44       ` David Daney
2009-10-20 22:44         ` David Daney

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=19165.29312.300540.500942@pilspetsen.it.uu.se \
    --to=mikpe@it.uu.se \
    --cc=linus.walleij@stericsson.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@linux-mips.org \
    --cc=ralf@linux-mips.org \
    --cc=tglx@linutronix.de \
    /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