linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: Being more anal about iospace accesses..
@ 2004-09-15 18:25 linux
  0 siblings, 0 replies; 35+ messages in thread
From: linux @ 2004-09-15 18:25 UTC (permalink / raw)
  To: joern; +Cc: linux-kernel

> Nice.
>
> But it still leaves me confused.  Before I had this code:
>
>	struct regs {
>		uint32_t status;
>		...
>	}
>
>	...
>
>	struct regs *regs = ioremap(...);
>	uint32_t status = regs->status;
>	...
> 
> So now I should do it like this:
>
>	#define REG_STATUS 0
>
>	...
>
>	void __iomem *regs = ioremap(...);
>	uint32_t status = readl(regs + REG_STATUS);
>	...
>
> But wait, that only works when long is 32bit wide.  Plus I could be
> stupid enough and "#define REG_STATUS 64" while the register space is
> just 64 bytes long.  It solves the confusion about address spaces,
> agreed, but overall I'm more confused now.  Hope it's just temporary.

No, you should do:

	struct regs {
	      uint32_t status;
	      ...
	}

	...

	struct regs __iomem *regs = ioremap(...);
	uint32_t status = ioread32(&regs->status);

^ permalink raw reply	[flat|nested] 35+ messages in thread

end of thread, other threads:[~2004-09-18 13:06 UTC | newest]

Thread overview: 35+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <Pine.LNX.4.58.0409081543320.5912@ppc970.osdl.org>
     [not found] ` <Pine.LNX.4.58.0409150737260.2333@ppc970.osdl.org>
2004-09-15 16:30   ` Being more anal about iospace accesses Linus Torvalds
2004-09-15 16:54     ` Jörn Engel
2004-09-15 17:07       ` Linus Torvalds
2004-09-15 17:32         ` Jörn Engel
2004-09-15 17:57           ` Linus Torvalds
2004-09-15 18:06             ` Linus Torvalds
2004-09-15 19:34             ` Greg KH
2004-09-15 19:53               ` Linus Torvalds
2004-09-15 20:06                 ` Greg KH
2004-09-16 14:58             ` Horst von Brand
2004-09-15 17:45         ` Nikita Danilov
2004-09-15 18:09           ` Linus Torvalds
2004-09-15 18:40         ` Chris Wedgwood
2004-09-15 17:07       ` Jeff Garzik
2004-09-15 17:16       ` Roland Dreier
2004-09-15 17:39         ` Linus Torvalds
2004-09-15 20:07           ` Russell King
2004-09-15 17:36       ` Horst von Brand
2004-09-15 17:40       ` Brian Gerst
2004-09-15 16:56     ` Dave Jones
2004-09-15 17:19     ` Roger Luethi
2004-09-15 17:23     ` Richard B. Johnson
2004-09-15 22:21     ` Deepak Saxena
2004-09-15 22:46       ` Linus Torvalds
2004-09-15 23:09         ` Deepak Saxena
2004-09-16 12:51           ` Geert Uytterhoeven
2004-09-16 22:10             ` Deepak Saxena
2004-09-15 22:29     ` Roland Dreier
2004-09-15 23:26       ` Being more careful " Linus Torvalds
2004-09-16  0:10         ` viro
2004-09-16 11:40           ` David Woodhouse
2004-09-16 12:25         ` David Woodhouse
2004-09-16 14:01           ` Linus Torvalds
2004-09-18  9:46             ` Kai Henningsen
2004-09-15 18:25 Being more anal " linux

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