linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: linux@arm.linux.org.uk (Russell King - ARM Linux)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v6 01/15] ARM: mxs: Add core definitions
Date: Wed, 15 Dec 2010 16:47:57 +0000	[thread overview]
Message-ID: <20101215164757.GF9937@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <201012151722.21939.arnd@arndb.de>

On Wed, Dec 15, 2010 at 05:22:21PM +0100, Arnd Bergmann wrote:
> On Monday 13 December 2010, Shawn Guo wrote:
> > +#ifdef __ASSEMBLER__
> > +#define IOMEM(addr)	(addr)
> > +#else
> > +#define IOMEM(addr)	((void __force __iomem *)(addr))
> > +#endif
> 
> This looks like a rather ugly hack to hide misuse of __iomem
> pointers. If you pass virtual addresses of I/O registers,
> just make them always be of type (void __iomem *), so you
> can actually benefit from the sparse annotations, rather
> working against them.

Err, no - you're not understanding its purpose.  It's used like so:

#define FOO_BASE		IOMEM(0xf0000000)

in headers, which means you can use FOO_BASE both in C code (and it'll
be correctly typed) and also use it in assembly code (where it will be
an assembly expression.)

The alternative is we end up with:

#define FOO_ASM_BASE		0xf0000000
#define FOO_C_BASE		((void __force __iomem *)0xf0000000)

Or worse still, we end up with stuff like:

#define FOO_BASE		0xf0000000

struct blah {
	unsigned long base;
};

unsigned int blah(struct blah *b, unsigned int reg)
{
	return readl(b->base + reg);
}

Having IOMEM(), which can be audited to only be used in header files
defining registers gets around such problems, and ensures that the C
code is written more correctly than it otherwise would be.

  parent reply	other threads:[~2010-12-15 16:47 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-13 12:54 [PATCH v6 00/15] ARM: mxs: Add initial support for MX23 and MX28 Shawn Guo
2010-12-13 12:54 ` [PATCH v6 01/15] ARM: mxs: Add core definitions Shawn Guo
2010-12-15 16:22   ` Arnd Bergmann
2010-12-15 16:40     ` Uwe Kleine-König
2010-12-15 16:58       ` Arnd Bergmann
2010-12-15 17:06         ` Uwe Kleine-König
2010-12-15 17:17           ` Arnd Bergmann
2010-12-15 17:27             ` Russell King - ARM Linux
2010-12-15 22:26               ` Arnd Bergmann
2010-12-15 18:49             ` Uwe Kleine-König
2010-12-16  1:37           ` Shawn Guo
2010-12-15 16:47     ` Russell King - ARM Linux [this message]
2010-12-15 17:08       ` Arnd Bergmann
2010-12-15 17:23         ` Russell King - ARM Linux
2010-12-15 17:51           ` Arnd Bergmann
2010-12-13 12:54 ` [PATCH v6 03/15] ARM: mxs: Add reset routines Shawn Guo
2010-12-13 12:55 ` [PATCH v6 06/15] ARM: mxs: Add timer support Shawn Guo
2010-12-13 13:53   ` Russell King - ARM Linux
2010-12-13 12:55 ` [PATCH v6 07/15] ARM: mxs: Add gpio support Shawn Guo
2010-12-13 12:55 ` [PATCH v6 08/15] ARM: mxs: Add iomux support Shawn Guo
2010-12-16  9:51   ` Uwe Kleine-König
2010-12-16 10:26     ` Shawn Guo
2010-12-13 12:55 ` [PATCH v6 15/15] ARM: mxs: Add build configuration for mxs Shawn Guo
2010-12-13 14:20 ` [PATCH v6 00/15] ARM: mxs: Add initial support for MX23 and MX28 Uwe Kleine-König
2010-12-14  8:31   ` [PATCH v6 00/15] ARM: mxs: Add initial support for MX23 andMX28 Shawn Guo
2010-12-14 13:00     ` Shawn Guo
2010-12-15 16:24 ` [PATCH v6 00/15] ARM: mxs: Add initial support for MX23 and MX28 Arnd Bergmann
2010-12-15 16:34   ` Uwe Kleine-König

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=20101215164757.GF9937@n2100.arm.linux.org.uk \
    --to=linux@arm.linux.org.uk \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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).