devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Gibson <david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org>
To: Paul Walmsley <paul-DWxLp4Yu+b8AvxtiuMwx3w@public.gmane.org>
Cc: "devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org"
	<devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org>,
	Arnaud Lacombe <lacombar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Subject: Re: [RFC PATCH] dtc: Add support for named constants
Date: Wed, 31 Aug 2011 13:37:31 +1000	[thread overview]
Message-ID: <20110831033731.GC26462@yookeroo.fritz.box> (raw)
In-Reply-To: <alpine.DEB.2.00.1108301459340.26173-rwI8Ez+7Ko+d5PgPZx9QOdBPR1lH4CV8@public.gmane.org>

On Tue, Aug 30, 2011 at 03:04:08PM -0600, Paul Walmsley wrote:
> Hi,
> 
> On Tue, 30 Aug 2011, Stephen Warren wrote:
> 
> > David Gibson wrote at Monday, August 29, 2011 10:23 PM:
> > > On Tue, Aug 23, 2011 at 04:43:20PM -0600, Stephen Warren wrote:
> > > > You may define constants as follows:
> > > >
> > > > /define/ $TWO 2;
> > > > /define/ $FOUR 4;
> > > > /define/ $OTHER $FOUR;
> > > >
> > > > And properties may use these values as follows:
> > > >
> > > > foo = <1 $TWO 3 $FOUR 5>;
> > ...
> > > > Note 2: I'd prefer the syntax of /define/ to be:
> > > >
> > > > /define/ TWO 2;
> 
> Some preprocessing support would be very useful for us on OMAP, where we 
> have some register bitfields that we'd like to use symbolic names for.
> 
> One question, though.  Documentation/devicetree/booting-without-of.txt[1] 
> says:
> 
>    It is also suggested that you pipe your source file through cpp (gcc
>    preprocessor) so you can use #include's, #define for constants, 
>    etc...
> 
> Is it no longer recommended to use cpp for this purpose?

Yes and now.  I actually prefer the idea of using cpp, or at least
cpp-like processing to handle macros and the like in dts - Jon's
approach was different, instead implementing functions, of a sort, in
dtc itself.

The difficulty with cpp is that # already appears naturally as the
first character in a line in many dts files due to the #address-cells
and #size-cells properties for example.  That makes distinguishing the
cpp directives properly lexically difficult.  It will usually actually
work, with a little fiddling, but what exact fiddling is required
depends on the cpp version which makes it kind of unsuitable as a
general solution.

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

  parent reply	other threads:[~2011-08-31  3:37 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-23 22:43 [RFC PATCH] dtc: Add support for named constants Stephen Warren
     [not found] ` <1314139400-31984-1-git-send-email-swarren-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2011-08-30  4:23   ` David Gibson
     [not found]     ` <20110830042316.GH4254-787xzQ0H9iQXU02nzanrWNbf9cGiqdzd@public.gmane.org>
2011-08-30 16:37       ` Stephen Warren
     [not found]         ` <74CDBE0F657A3D45AFBB94109FB122FF04B3279D55-C7FfzLzN0UxDw2glCA4ptUEOCMrvLtNR@public.gmane.org>
2011-08-30 21:04           ` Paul Walmsley
     [not found]             ` <alpine.DEB.2.00.1108301459340.26173-rwI8Ez+7Ko+d5PgPZx9QOdBPR1lH4CV8@public.gmane.org>
2011-08-31  3:37               ` David Gibson [this message]
2011-08-31  3:33           ` David Gibson

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=20110831033731.GC26462@yookeroo.fritz.box \
    --to=david-xt8fgy+axnrb3ne2bgzf6laj5h9x9tb+@public.gmane.org \
    --cc=devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org \
    --cc=lacombar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=paul-DWxLp4Yu+b8AvxtiuMwx3w@public.gmane.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;
as well as URLs for NNTP newsgroup(s).