All of lore.kernel.org
 help / color / mirror / Atom feed
From: slash.tmp@free.fr (Mason)
To: linux-arm-kernel@lists.infradead.org
Subject: Preprocessor arithmetic in dtsi files (base + offset)
Date: Thu, 26 Nov 2015 15:44:28 +0100	[thread overview]
Message-ID: <56571ACC.9080306@free.fr> (raw)
In-Reply-To: <20151126135957.GC8644@n2100.arm.linux.org.uk>

On 26/11/2015 14:59, Russell King - ARM Linux wrote:
> On Thu, Nov 26, 2015 at 02:16:16PM +0100, Mason wrote:
>> #define SCU_BASE 0x20000000
>>
>> 	scu: scu at XXX {
>> 		compatible = "arm,cortex-a9-scu";
>> 		reg = <SCU_BASE 0x100>;
>> 	
>> 	gic: interrupt-controller at XXX {
>> 		compatible = "arm,cortex-a9-gic";
>> 		reg = <SCU_BASE+0x1000 0x1000>, <SCU_BASE+0x100 0x0100>;
> 
> You don't get preprocessor arithmetic here.  What you get is this passed
> to DTC:
> 
> 		reg = <0x20000000+0x1000 0x1000>...
> 
> The only time the preprocessor does arithmetic is when it needs to
> evaluate an expression, eg, in an #if statement.

Doh! Brain malfunction. No arithmetic indeed.
Working with the preprocessor would have to involve token-pasting.

#define SCU_BASE(OFFSET)	2000##OFFSET
#define SCU_BASEX(OFFSET)	0x2000##OFFSET

	gic: interrupt-controller at SCU_BASE(1000) {
		reg = <SCU_BASEX(1000) 0x1000>, <SCU_BASEX(0100) 0x0100>;
	};

My very own abomination!

Regards.

WARNING: multiple messages have this Message-ID (diff)
From: Mason <slash.tmp-GANU6spQydw@public.gmane.org>
To: Russell King - ARM Linux <linux-lFZ/pmaqli7XmaaqVzeoHQ@public.gmane.org>
Cc: Linux ARM
	<linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org>,
	DT <devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org>,
	Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org>,
	Pawel Moll <pawel.moll-5wv7dgnIgG8@public.gmane.org>,
	Sebastian Frias
	<sebastian_frias-y1yR0Z3OICC7zZZRDBGcUA@public.gmane.org>
Subject: Re: Preprocessor arithmetic in dtsi files (base + offset)
Date: Thu, 26 Nov 2015 15:44:28 +0100	[thread overview]
Message-ID: <56571ACC.9080306@free.fr> (raw)
In-Reply-To: <20151126135957.GC8644-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>

On 26/11/2015 14:59, Russell King - ARM Linux wrote:
> On Thu, Nov 26, 2015 at 02:16:16PM +0100, Mason wrote:
>> #define SCU_BASE 0x20000000
>>
>> 	scu: scu@XXX {
>> 		compatible = "arm,cortex-a9-scu";
>> 		reg = <SCU_BASE 0x100>;
>> 	
>> 	gic: interrupt-controller@XXX {
>> 		compatible = "arm,cortex-a9-gic";
>> 		reg = <SCU_BASE+0x1000 0x1000>, <SCU_BASE+0x100 0x0100>;
> 
> You don't get preprocessor arithmetic here.  What you get is this passed
> to DTC:
> 
> 		reg = <0x20000000+0x1000 0x1000>...
> 
> The only time the preprocessor does arithmetic is when it needs to
> evaluate an expression, eg, in an #if statement.

Doh! Brain malfunction. No arithmetic indeed.
Working with the preprocessor would have to involve token-pasting.

#define SCU_BASE(OFFSET)	2000##OFFSET
#define SCU_BASEX(OFFSET)	0x2000##OFFSET

	gic: interrupt-controller@SCU_BASE(1000) {
		reg = <SCU_BASEX(1000) 0x1000>, <SCU_BASEX(0100) 0x0100>;
	};

My very own abomination!

Regards.

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2015-11-26 14:44 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-26 13:16 Preprocessor arithmetic in dtsi files (base + offset) Mason
2015-11-26 13:16 ` Mason
2015-11-26 13:52 ` Mark Rutland
2015-11-26 13:52   ` Mark Rutland
2015-11-26 13:59 ` Russell King - ARM Linux
2015-11-26 13:59   ` Russell King - ARM Linux
2015-11-26 14:44   ` Mason [this message]
2015-11-26 14:44     ` Mason
2015-11-26 16:23     ` Geert Uytterhoeven
2015-11-26 16:23       ` Geert Uytterhoeven
2015-11-26 17:51       ` Robin Murphy
2015-11-26 17:51         ` Robin Murphy
2015-12-02 22:14       ` Mason
2015-12-02 22:14         ` Mason

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=56571ACC.9080306@free.fr \
    --to=slash.tmp@free.fr \
    --cc=linux-arm-kernel@lists.infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.