[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-ppc] [Qemu-devel] [PATCH 07/31] dt: add helper for phandle all
From: |
Peter Crosthwaite |
Subject: |
Re: [Qemu-ppc] [Qemu-devel] [PATCH 07/31] dt: add helper for phandle allocation |
Date: |
Wed, 06 Jun 2012 15:18:28 +1000 |
On Wed, 2012-06-06 at 01:52 +0200, Alexander Graf wrote:
> Phandle references work by having 2 pieces:
>
> - a "phandle" 1-cell property in the device tree node
> - a reference to the same value in a property we want to point
> to the other node
>
> To generate the 1-cell property, we need an allocation mechanism that
> gives us a unique number space. This patch adds an allocator for these
> properties.
>
> Signed-off-by: Alexander Graf <address@hidden>
> ---
> device_tree.c | 7 +++++++
> device_tree.h | 1 +
> 2 files changed, 8 insertions(+), 0 deletions(-)
>
> diff --git a/device_tree.c b/device_tree.c
> index d4f1f0a..317bdd0 100644
> --- a/device_tree.c
> +++ b/device_tree.c
> @@ -220,6 +220,13 @@ int qemu_devtree_setprop_phandle(void *fdt, const char
> *node_path,
> return qemu_devtree_setprop_cell(fdt, node_path, property, phandle);
> }
>
> +uint32_t qemu_devtree_alloc_phandle(void *fdt)
> +{
> + static int phandle = 0x8000;
can easily double check for duplicates. Would also allow you to start
from 1 rather than magic number 0x8000?
while (fdt_node_offset_by_phandle(fdt, phandle) != FDT_ERR_NOTFOUND)
phandle++;
> +
> + return phandle++;
> +}
> +
> int qemu_devtree_nop_node(void *fdt, const char *node_path)
> {
> int r;
> diff --git a/device_tree.h b/device_tree.h
> index 5464dc7..f37a4da 100644
> --- a/device_tree.h
> +++ b/device_tree.h
> @@ -35,6 +35,7 @@ int qemu_devtree_setprop_string(void *fdt, const char
> *node_path,
> int qemu_devtree_setprop_phandle(void *fdt, const char *node_path,
> const char *property, const char *string);
> uint32_t qemu_devtree_get_phandle(void *fdt, const char *path);
> +uint32_t qemu_devtree_alloc_phandle(void *fdt);
> int qemu_devtree_nop_node(void *fdt, const char *node_path);
> int qemu_devtree_add_subnode(void *fdt, const char *name);
>
- [Qemu-ppc] [PATCH 30/31] dt: Add global option to set phandle start offset, (continued)
- [Qemu-ppc] [PATCH 30/31] dt: Add global option to set phandle start offset, Alexander Graf, 2012/06/05
- [Qemu-ppc] [PATCH 29/31] PPC: e500: Extend address/size of / to 64bit, Alexander Graf, 2012/06/05
- [Qemu-ppc] [PATCH 01/31] dt: allow add_subnode to create root subnodes, Alexander Graf, 2012/06/05
- [Qemu-ppc] [PATCH 16/31] PPC: e500: dt: create serial nodes dynamically, Alexander Graf, 2012/06/05
- [Qemu-ppc] [PATCH 19/31] PPC: e500: dt: create pci node dynamically, Alexander Graf, 2012/06/05
- [Qemu-ppc] [PATCH 28/31] PPC: e500: Define addresses as always 64bit, Alexander Graf, 2012/06/05
- [Qemu-ppc] [PATCH 06/31] dt: add helper for empty dt creation, Alexander Graf, 2012/06/05
- [Qemu-ppc] [PATCH 07/31] dt: add helper for phandle allocation, Alexander Graf, 2012/06/05
- Re: [Qemu-ppc] [Qemu-devel] [PATCH 07/31] dt: add helper for phandle allocation,
Peter Crosthwaite <=
[Qemu-ppc] [PATCH 22/31] PPC: e500: dt: use 64bit cell helper, Alexander Graf, 2012/06/05
[Qemu-ppc] [PATCH 23/31] PPC: e500: dt: use target_phys_addr_t for ramsize, Alexander Graf, 2012/06/05
[Qemu-ppc] [PATCH 09/31] PPC: e500: require libfdt, Alexander Graf, 2012/06/05
[Qemu-ppc] [PATCH 24/31] PPC: e500: enable manual loading of dtb blob, Alexander Graf, 2012/06/05
[Qemu-ppc] [PATCH 26/31] PPC: e500: Use new MPIC dt format, Alexander Graf, 2012/06/05