linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: Magnus Damm <magnus.damm@gmail.com>
Cc: linux-kernel@vger.kernel.org, horms@verge.net.au, arnd@arndb.de,
	linux-sh@vger.kernel.org, johnstul@us.ibm.com, rjw@sisk.pl,
	lethal@linux-sh.org, gregkh@linuxfoundation.org, olof@lixom.net
Subject: Re: [PATCH] clocksource: em_sti: Emma Mobile STI driver
Date: Mon, 7 May 2012 21:10:07 +0200 (CEST)	[thread overview]
Message-ID: <alpine.LFD.2.02.1205072054130.6271@ionos> (raw)
In-Reply-To: <20120503125611.4314.52231.sendpatchset@w520>

On Thu, 3 May 2012, Magnus Damm wrote:
> +/* private flags */
> +#define FLAG_CLOCKEVENT (1 << 0)
> +#define FLAG_CLOCKSOURCE (1 << 1)
> +
> +static int em_sti_start(struct em_sti_priv *p, unsigned long flag)
> +{
> +	int ret = 0;
> +	unsigned long flags;
> +
> +	spin_lock_irqsave(&p->lock, flags);
> +
> +	if (!(p->flags & (FLAG_CLOCKEVENT | FLAG_CLOCKSOURCE)))
> +		ret = em_sti_enable(p);

That's confusing. You seem to enable both CLOCKEVENT and CLOCKSOURCE
independent of "flag" value.

> +
> +	if (!ret)
> +		p->flags |= flag;

And then just or "flag" ??????

> +	spin_unlock_irqrestore(&p->lock, flags);
> +
> +	return ret;
> +}
> +
> +static void em_sti_stop(struct em_sti_priv *p, unsigned long flag)
> +{
> +	unsigned long flags;
> +	unsigned long f;
> +
> +	spin_lock_irqsave(&p->lock, flags);
> +
> +	f = p->flags & (FLAG_CLOCKEVENT | FLAG_CLOCKSOURCE);
> +	p->flags &= ~flag;
> +
> +	if (f && !(p->flags & (FLAG_CLOCKEVENT | FLAG_CLOCKSOURCE)))
> +		em_sti_disable(p);

Huch? If the caller wants to disable the clockevent, you stop the
clocksource as well because em_sti_disable() stops the clock.

/me is confused.

> +static void em_sti_clock_event_start(struct em_sti_priv *p)
> +{
> +	struct clock_event_device *ced = &p->ced;
> +
> +	em_sti_start(p, FLAG_CLOCKEVENT);
> +
> +	/* TODO: calculate good shift from rate and counter bit width */
> +
> +	ced->shift = 32;
> +	ced->mult = div_sc(p->rate, NSEC_PER_SEC, ced->shift);

IIRC, we have a generic function to do that :)

Thanks,

	tglx

  parent reply	other threads:[~2012-05-07 19:10 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-03 12:56 [PATCH] clocksource: em_sti: Emma Mobile STI driver Magnus Damm
2012-05-07  5:20 ` Simon Horman
2012-05-07 19:10 ` Thomas Gleixner [this message]
2012-05-08 17:06   ` Magnus Damm

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=alpine.LFD.2.02.1205072054130.6271@ionos \
    --to=tglx@linutronix.de \
    --cc=arnd@arndb.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=horms@verge.net.au \
    --cc=johnstul@us.ibm.com \
    --cc=lethal@linux-sh.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sh@vger.kernel.org \
    --cc=magnus.damm@gmail.com \
    --cc=olof@lixom.net \
    --cc=rjw@sisk.pl \
    /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;
as well as URLs for NNTP newsgroup(s).