From: Russell King - ARM Linux <linux@arm.linux.org.uk>
To: linux-arm-kernel@lists.infradead.org,
John Stultz <johnstul@us.ibm.com>,
Thomas Gleixner <tglx@linutronix.de>
Cc: Alessandro Rubini <rubini@unipv.it>,
Kukjin Kim <kgene.kim@samsung.com>,
Eric Miao <eric.y.miao@gmail.com>,
Linus Walleij <linus.walleij@stericsson.com>,
Erik Gilling <konkers@android.com>,
Nicolas Pitre <nico@fluxnic.net>,
Tony Lindgren <tony@atomide.com>, Imre Kaloz <kaloz@openwrt.org>,
"Hans J. Koch" <hjk@hansjkoch.de>,
Sascha Hauer <kernel@pengutronix.de>,
Colin Cross <ccross@android.com>, Olof Johansson <olof@lixom.net>,
linux-omap@vger.kernel.org, Wan ZongShun <mcuos.com@gmail.com>,
Lennert Buytenhek <kernel@wantstofly.org>,
Krzysztof Halasa <khc@pm.waw.pl>
Subject: Re: [PATCH 06/13] clocksource: add common mmio clocksource
Date: Tue, 10 May 2011 10:59:20 +0100 [thread overview]
Message-ID: <20110510095920.GB29977@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <E1QJhNe-0000yh-HS@rmk-PC.arm.linux.org.uk>
On Tue, May 10, 2011 at 08:29:18AM +0100, Russell King - ARM Linux wrote:
> +cycle_t clocksource_mmio_readl_up(struct clocksource *c)
> +{
> + return readl_relaxed(to_mmio_clksrc(c)->reg);
> +}
> +
> +cycle_t clocksource_mmio_readl_down(struct clocksource *c)
> +{
> + return ~readl_relaxed(to_mmio_clksrc(c)->reg);
> +}
> +
> +cycle_t clocksource_mmio_readw_up(struct clocksource *c)
> +{
> + return readw_relaxed(to_mmio_clksrc(c)->reg);
> +}
> +
> +cycle_t clocksource_mmio_readw_down(struct clocksource *c)
> +{
> + return ~(unsigned)readw_relaxed(to_mmio_clksrc(c)->reg);
> +}
I probably ought to point out why that cast is there: readw* returns an
u16.
u16 will be promoted to 'int' by the compiler, then not'd, and then
extended to cycle_t (64-bit). This extension is a signed extension
which not only results in more code than required, but also results in
a delay slot not being filled.
It's the u16 -> signed int -> cycle_t which causes the signed extension.
u16 -> cycle_t doesn't involve changing the signed-ness of the type, so
doesn't suffer.
Neither does readl as it returns a u32 which doesn't need any promotion
to an int type.
So, rather than allow the compiler to do automatic promotion to a signed
int, the cast is there to ensure that it becomes an unsigned int instead.
next prev parent reply other threads:[~2011-05-10 9:59 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-10 7:27 [PATCH 00/13] Consolidate simple ARM MMIO clock sources Russell King - ARM Linux
2011-05-10 7:27 ` [PATCH 01/13] Make clocksource name const Russell King - ARM Linux
2011-05-10 7:28 ` [PATCH 03/13] ARM: omap1: delete useless interrupt handler Russell King - ARM Linux
2011-05-10 12:49 ` Kevin Hilman
2011-05-12 7:25 ` Tony Lindgren
2011-05-10 7:28 ` [PATCH 04/13] ARM: omap1: convert to using readl/writel instead of volatile struct Russell King - ARM Linux
2011-05-12 7:45 ` Tony Lindgren
2011-05-10 7:29 ` [PATCH 06/13] clocksource: add common mmio clocksource Russell King - ARM Linux
2011-05-10 8:38 ` Sascha Hauer
2011-05-10 8:46 ` Russell King - ARM Linux
2011-05-12 7:43 ` Tony Lindgren
2011-05-10 9:59 ` Russell King - ARM Linux [this message]
2011-05-11 8:15 ` viresh kumar
2011-05-11 8:35 ` [PATCH 06/13 v2] " Russell King - ARM Linux
2011-05-12 8:03 ` [PATCH 06/13] " Thomas Gleixner
2011-05-10 7:34 ` [PATCH 13/13] clocksource: convert OMAP1 to 32-bit down counting clocksource Russell King - ARM Linux
2011-05-12 7:46 ` Tony Lindgren
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=20110510095920.GB29977@n2100.arm.linux.org.uk \
--to=linux@arm.linux.org.uk \
--cc=ccross@android.com \
--cc=eric.y.miao@gmail.com \
--cc=hjk@hansjkoch.de \
--cc=johnstul@us.ibm.com \
--cc=kaloz@openwrt.org \
--cc=kernel@pengutronix.de \
--cc=kernel@wantstofly.org \
--cc=kgene.kim@samsung.com \
--cc=khc@pm.waw.pl \
--cc=konkers@android.com \
--cc=linus.walleij@stericsson.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-omap@vger.kernel.org \
--cc=mcuos.com@gmail.com \
--cc=nico@fluxnic.net \
--cc=olof@lixom.net \
--cc=rubini@unipv.it \
--cc=tglx@linutronix.de \
--cc=tony@atomide.com \
/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).