public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "H. Peter Anvin" <hpa@zytor.com>
To: Sam Ravnborg <sam@ravnborg.org>
Cc: LKML <linux-kernel@vger.kernel.org>, Ingo Molnar <mingo@elte.hu>
Subject: Re: use of volatile in iounmap()?
Date: Fri, 28 Mar 2008 13:51:12 -0700	[thread overview]
Message-ID: <47ED5A40.9020307@zytor.com> (raw)
In-Reply-To: <20080328203427.GA14256@uranus.ravnborg.org>

Sam Ravnborg wrote:
> While reviewing some CAN driver I stumbled on iounmap
> which has following prototype on x86:
> 
> extern void iounmap(volatile void __iomem *addr);
> 
> I argued that the driver should not use volatile
> but then I cannot explain why the argument to
> iounmap takes a volatile.
> 
> The same goes for many other functions in
> the io*.h headers.
> 
> Grepping the other archs they mostly follow
> same pattern.
> 
> Can anyone explain the rational for volatile in this case.
> 

Yes.  The use of volatile in a function prototype like this means that 
it is valid to pass a volatile pointer to that function -- in other 
words, we're telling gcc that we're not going to do anything with the 
pointer that is invalid for a volatile pointer.

A lot of the "volatile considered harmful" stuff that has been bandied 
about is explicitly about marking *data* items volatile (it does have 
its uses, but it's easy to get wrong); Linus has explicitly made the 
distinction between volatile *data* and volatile *operations*.

	-hpa

  reply	other threads:[~2008-03-28 20:51 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-28 20:34 use of volatile in iounmap()? Sam Ravnborg
2008-03-28 20:51 ` H. Peter Anvin [this message]
2008-03-28 21:04   ` Sam Ravnborg
2008-03-28 21:07     ` H. Peter Anvin
2008-03-28 21:17 ` Al Viro

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=47ED5A40.9020307@zytor.com \
    --to=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=sam@ravnborg.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