All of lore.kernel.org
 help / color / mirror / Atom feed
From: arnd@arndb.de (Arnd Bergmann)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v6 01/15] ARM: mxs: Add core definitions
Date: Wed, 15 Dec 2010 18:08:41 +0100	[thread overview]
Message-ID: <201012151808.41969.arnd@arndb.de> (raw)
In-Reply-To: <20101215164757.GF9937@n2100.arm.linux.org.uk>

On Wednesday 15 December 2010, Russell King - ARM Linux wrote:
> 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)

But isn't a hardwire virtual I/O address something that should be
used only very rarely?

I would assume that we only need to have the base address of the
mapping window defined somewhere and then use offsets:

#ifdef __ASSEMBLY__
#define IOMEM_BASE	0xf0000000
#else
#define IOMEM_BASE	((void __iomem *)0xf0000000)
#endif

#define FOO_BASE	IOMEM_BASE + 0x18000
#define BAR_BASE	IOMEM_BASE + 0x20000

> 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.

With the autiting, it certainly isn't that bad. One problem
I still see is that it's defined in the platform directory,
rather than somewhere in arch/arm/include/asm/, where it could
be mandated for use across all (or all new) platforms.

Introducing generic infrastructure at a platform level seems
problematic because the good parts will need to get copied
everywhere while the bad parts get stuck in obsolete platforms
forever.

	Arnd

  reply	other threads:[~2010-12-15 17:08 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
2010-12-15 17:08       ` Arnd Bergmann [this message]
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=201012151808.41969.arnd@arndb.de \
    --to=arnd@arndb.de \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.