From: David Gibson <david@gibson.dropbear.id.au>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: Peter Crosthwaite <peter.crosthwaite@petalogix.com>,
patches@linaro.org, Alexander Graf <agraf@suse.de>,
qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 1/2] device_tree: Add qemu_devtree_setprop_sized_cells() utility function
Date: Thu, 27 Jun 2013 10:15:19 +1000 [thread overview]
Message-ID: <20130627001519.GB10614@voom.fritz.box> (raw)
In-Reply-To: <CAFEAcA9Xm=QR617vN6dAHqCCQWKTtnC=Jg2Qie_MfJCptLTSGQ@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 2611 bytes --]
On Wed, Jun 26, 2013 at 11:50:26AM +0100, Peter Maydell wrote:
> On 26 June 2013 11:31, Alexander Graf <agraf@suse.de> wrote:
> > I think it makes sense to make this API special-purpose for "reg".
> > We currently have a generic "put any number of 32bit values into the
> > property" function (qemu_devtree_setprop_cells).
>
> Yes, but that doesn't work for things that aren't simple arrays
> of 32 bit values, so I think that a generic way to deal
> with those too would be useful. If you wanted to write a
> "ranges" property you'd need this too, so it doesn't just
> apply to "reg".
>
> I think we could avoid the "varargs doesn't promote" problem
> by using a varargs-macro wrapper:
>
> #define qemu_devtree_setprop_sized_cells(fdt, node, prop, ...) \
> do { \
> uint64_t args[] = { __VA_ARGS__ }; \
> do_qemu_devtree_setprop_sized_cells(fdt, node, prop, \
> args, sizeof(args));
> } while (0)
>
> which will promote everything (including the size arguments,
> harmlessly) to uint64_t, and avoids having a varargs function.
Heh. Oops, didn't read this before I suggested the same thing.
Although a statement expression will let you actually get any fdt
error codes out.
> > Can't we also just add a qemu_devtree_setprop_reg() that walks
> > the tree downwards in search for #address-cells and #size-cells
> > and assembles the correct reg property from a list of 64bit
> > arguments?
>
> Do we have an actual use for this? It seems pretty complicated.
> I would expect that in practice there are two major use cases:
> (a) create your own fdt from scratch (in which case you can
> just make everything 64 bits and in any case will know
> when creating nodes what the #address-cells etc are)
> (b) modify an existing fdt, in which case you definitely don't
> want to go poking around too deeply in the tree; anything
> more than just "put an extra node in the root" is starting
> to get pretty chancy.
So, I tend to think that "reg" and "ranges" specific helpers would be
nicer than having to add the size for every parameter. But I was
thinking of passing in the address-cells and size-cells values rather
than having the function dig around in the tree to get them.
The other way to avoid varargs would be to have a helper that just
adds one entry at a time, using fdt_appendprop().
--
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
[-- Attachment #2: Type: application/pgp-signature, Size: 198 bytes --]
next prev parent reply other threads:[~2013-06-27 0:18 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-24 10:22 [Qemu-devel] [PATCH 0/2] device_tree: add qemu_devtree_setprop_sized_cells() Peter Maydell
2013-06-24 10:22 ` [Qemu-devel] [PATCH 1/2] device_tree: Add qemu_devtree_setprop_sized_cells() utility function Peter Maydell
2013-06-24 10:56 ` Alexander Graf
2013-06-24 11:02 ` Peter Maydell
2013-06-25 23:38 ` David Gibson
2013-06-26 8:49 ` Peter Maydell
2013-06-26 10:31 ` Alexander Graf
2013-06-26 10:50 ` Peter Maydell
2013-06-26 11:42 ` Alexander Graf
2013-06-26 12:38 ` Peter Crosthwaite
2013-06-26 12:44 ` Alexander Graf
2013-06-27 0:17 ` David Gibson
2013-06-27 0:27 ` Anthony Liguori
2013-06-26 13:13 ` Peter Maydell
2013-06-26 13:31 ` Peter Maydell
2013-06-27 0:15 ` David Gibson [this message]
2013-06-27 0:10 ` David Gibson
2013-06-24 10:22 ` [Qemu-devel] [PATCH 2/2] arm/boot: Use qemu_devtree_setprop_sized_cells() Peter Maydell
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=20130627001519.GB10614@voom.fritz.box \
--to=david@gibson.dropbear.id.au \
--cc=agraf@suse.de \
--cc=patches@linaro.org \
--cc=peter.crosthwaite@petalogix.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.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).