From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41454) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UrzuY-0007Gj-86 for qemu-devel@nongnu.org; Wed, 26 Jun 2013 20:18:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UrzuS-0005Ag-Va for qemu-devel@nongnu.org; Wed, 26 Jun 2013 20:18:06 -0400 Received: from ozlabs.org ([2402:b800:7003:1:1::1]:44242) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UrzuR-00059t-Lg for qemu-devel@nongnu.org; Wed, 26 Jun 2013 20:18:00 -0400 Date: Thu, 27 Jun 2013 10:15:19 +1000 From: David Gibson Message-ID: <20130627001519.GB10614@voom.fritz.box> References: <1372069376-30640-1-git-send-email-peter.maydell@linaro.org> <1372069376-30640-2-git-send-email-peter.maydell@linaro.org> <3708A7FB-9BEF-494C-B5A2-B1A97C1F78C4@suse.de> <20130625233850.GG25265@voom.fritz.box> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="tsOsTdHNUZQcU9Ye" Content-Disposition: inline In-Reply-To: Subject: Re: [Qemu-devel] [PATCH 1/2] device_tree: Add qemu_devtree_setprop_sized_cells() utility function List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: Peter Crosthwaite , patches@linaro.org, Alexander Graf , qemu-devel@nongnu.org --tsOsTdHNUZQcU9Ye Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Jun 26, 2013 at 11:50:26AM +0100, Peter Maydell wrote: > On 26 June 2013 11:31, Alexander Graf 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). >=20 > 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". >=20 > I think we could avoid the "varargs doesn't promote" problem > by using a varargs-macro wrapper: >=20 > #define qemu_devtree_setprop_sized_cells(fdt, node, prop, ...) \ > do { \ > uint64_t args[] =3D { __VA_ARGS__ }; \ > do_qemu_devtree_setprop_sized_cells(fdt, node, prop, \ > args, sizeof(args)); > } while (0) >=20 > 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? >=20 > 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(). --=20 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 --tsOsTdHNUZQcU9Ye Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.13 (GNU/Linux) iEYEARECAAYFAlHLhBcACgkQaILKxv3ab8b7XgCgka6b6n7/n+uVsDIbP5uUgV97 CW0AoIJkNjHyrj79nFKk+IQEovtKlgDv =bWE8 -----END PGP SIGNATURE----- --tsOsTdHNUZQcU9Ye--