[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 4/6] device_tree: Add support for reading device

From: Peter Maydell
Subject: Re: [Qemu-devel] [PATCH 4/6] device_tree: Add support for reading device tree properties
Date: Fri, 6 Jul 2012 16:34:08 +0100

On 6 July 2012 02:56, Peter Crosthwaite <address@hidden> wrote:
> Can we generalise and get functionality for reading cells with offsets
> as well? Your function assumes (and asserts) that the property is a
> single cell, but can we add a index parameter for reading a non-0th
> property out of a multi-cell prop? Needed for reading things like
> ranges, regs and interrupt properties.

I was playing about with this and I'm really not sure that we should
be providing a "read a single u32 from a u32 array property" at the
device_tree.c layer. For example, for handling the ranges property
what you really want to do is treat it as a list of tuples (including
doing something sensible if it doesn't have the right length to be
a complete list), so the code that knows the structure of the ranges
property is better off calling qemu_devtree_getprop to get a uint32_t*
for the whole array. Then it has the whole thing as a straightforward
C array which will be much easier and more efficient to handle than
constantly bouncing back into the fdt layer to read each uint32_t.

I've also just realised that I'm assuming that the pointer returned
by fdt_getprop() is naturally aligned for a 32 bit integer if the
property is a 32 bit integer -- is that valid?

-- PMM

reply via email to

[Prev in Thread] Current Thread [Next in Thread]