Re: [RFC PATCH] dtc: Add support for named constants
From: David Gibson <hidden>
Date: 2011-08-31 03:37:31
On Tue, Aug 30, 2011 at 03:04:08PM -0600, Paul Walmsley wrote:
Hi, On Tue, 30 Aug 2011, Stephen Warren wrote:quoted
David Gibson wrote at Monday, August 29, 2011 10:23 PM:quoted
On Tue, Aug 23, 2011 at 04:43:20PM -0600, Stephen Warren wrote:quoted
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>;...quoted
quoted
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