From: Albert ARIBAUD <albert.u.boot@aribaud.net>
To: u-boot@lists.denx.de
Subject: [U-Boot] RFC: getramsize() prototype and volatile qualifier
Date: Thu, 21 Apr 2011 19:50:50 +0200 [thread overview]
Message-ID: <4DB06E7A.3060904@aribaud.net> (raw)
In-Reply-To: <BANLkTikY6gDNTkZhtLM4QzV2sB_NpYNHVA@mail.gmail.com>
Le 21/04/2011 19:02, Mike Frysinger a ?crit :
> On Thu, Apr 21, 2011 at 3:09 AM, Albert ARIBAUD wrote:
>> Call it a detail, but I see that get_ram_size() calls sometime qualify
>> their argument as volatile and sometimes not, and this makes checkpatch
>> complain that volatiles are Bad(tm), which I would like to get fixed.
>>
>> The prototype for get_ram_size() in is
>>
>> long get_ram_size (volatile long *, long);
>>
>> While I understand that the way get_ram_size() works, it needs to
>> perform volatile *accesses* to addresses computed from its arguments, I
>> don't see why it requires one of the arguments themselves to be volatile.
>>
>> Am I missing something here, particularly about some toolchain requiring
>> the argument to be volatile? I see no reason it should, but better safe
>> than sorry.
>
> the argument isnt volatile, the memory it points to is. since
> get_ram_size() itself doesnt dereference the argument (only goes
> through a local "addr"), the volatile marking in the prototype could
> be dropped, but personally i dont see the point. the prototype doesnt
> require callers to add volatile markings to their own code, and i
> could see someone using "base" in the future after the volatile being
> dropped and people not noticing right away. the current code is safe
> and causes no problems by itself, so i see no value in changing it.
>
> this sounds like useless "gotta be checkpatch clean" work by people
> blindly following its output.
> -mike
Just because checkpatch complains about something does not mean that
particular complaint is without merit. :)
Yes, the code works as it is; but it'll work just as well if volatile is
removed from the prototype and calls, and that'll make the code simpler
and more homogeneous overall, plus it'll give checkpatch one less cause
for complaint. We gain something there, if not a functional plus, an
overal quality plus.
As for people fiddling with get_ram_size() *body* and removing the
volatile 'addr' and use the non-volatile 'base' directly, why would
they? They will plainly see that 'addr' is volatile and 'base' is not
(all the more because removing the volatile' attribute from 'base' will
require casting it to 'base+int' where it belongs), and the very role of
the function makes it clear to them that the volatile attribute is
required for 'addr', so they'll keep 'addr'.
Plus, get_ram_size() is pretty stable -- actually, it has changed only
once in 2006 since its creation in 2004.
Amicalement,
--
Albert.
next prev parent reply other threads:[~2011-04-21 17:50 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-21 7:09 [U-Boot] RFC: getramsize() prototype and volatile qualifier Albert ARIBAUD
2011-04-21 17:02 ` Mike Frysinger
2011-04-21 17:50 ` Albert ARIBAUD [this message]
2011-04-21 22:28 ` Mike Frysinger
2011-04-22 5:52 ` Albert ARIBAUD
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=4DB06E7A.3060904@aribaud.net \
--to=albert.u.boot@aribaud.net \
--cc=u-boot@lists.denx.de \
/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