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

On Fri, Mar 28, 2008 at 01:51:12PM -0700, H. Peter Anvin wrote:
> 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.
If I understand you correct then it is then not wrong to say
that we have the argument volatile to avoid warnings from gcc
when we pass a volatile pointer.

And then having the pointer marked volatile put a few restrictions
on iounmap().

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

Yes - but unfortunately the volatile-considered-harmful.txt
does many deal with the data part.

Thanks,
	Sam

  reply	other threads:[~2008-03-28 21:04 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
2008-03-28 21:04   ` Sam Ravnborg [this message]
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=20080328210422.GA14484@uranus.ravnborg.org \
    --to=sam@ravnborg.org \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    /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