linux-mips
[Top] [All Lists]

Re: how to access structured registers correctly

To: Hiroshi DOYU <Hiroshi_DOYU@montavista.co.jp>
Subject: Re: how to access structured registers correctly
From: Ralf Baechle <ralf@linux-mips.org>
Date: Tue, 26 Jul 2005 15:06:43 -0400
Cc: linux-mips@linux-mips.org
In-reply-to: <20050726182531.6341586f.Hiroshi_DOYU@montavista.co.jp>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <20050726182531.6341586f.Hiroshi_DOYU@montavista.co.jp>
Sender: linux-mips-bounce@linux-mips.org
User-agent: Mutt/1.4.2.1i
On Tue, Jul 26, 2005 at 06:25:31PM +0900, Hiroshi DOYU wrote:
> Date: Tue, 26 Jul 2005 18:25:31 +0900
> From: Hiroshi DOYU <Hiroshi_DOYU@montavista.co.jp>
> To:   linux-mips@linux-mips.org
> Subject: how to access structured registers correctly
> Content-Type: text/plain; charset=US-ASCII
> 
> Hello experts,
> 
> I am wondering how to access registers correctly by usging structured 
> register definitions in TX4938 particularly.
> 
> Some time ago, Linus told "volatile" on a data structure as described 
> below,
> 
>       http://www.ussg.iu.edu/hypermail/linux/kernel/0401.0/1387.html
> 
> 
> In tx4938, every register access is done by using "volatile" like below.

Linus is right, volatile is a dangerous thing.  If you want to write
portable code there's a bunch of things that are not being taken care of
by plain C - even though in my opinion foo->somereg = 42 is more
readable than writel(somereg, 42).  Among the things the pointer to
volatile struct method doesn't catch are endianess conversion that might
be necessary on some systems, write merging, dealing with write buffers
or completly insane methods of attaching the bus such as the infamous
ISA / EISA cage that's attached to the host system through a USB
interface.

Now, how does that affect your TX4928 code?  Probably not terribly much
because you're using a SOC so the configuration of the system is fixed.

  Ralf

<Prev in Thread] Current Thread [Next in Thread>