]> git.proxmox.com Git - qemu.git/commitdiff
dt: add helper for phandle allocation
authorAlexander Graf <agraf@suse.de>
Thu, 17 May 2012 14:58:55 +0000 (16:58 +0200)
committerAlexander Graf <agraf@suse.de>
Sat, 23 Jun 2012 23:04:46 +0000 (01:04 +0200)
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 <agraf@suse.de>
device_tree.c
device_tree.h

index d0378961f0f216a875ce76e872dde51de4ab0b95..75412747b71642df88226477db1204db3a497dd0 100644 (file)
@@ -191,6 +191,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;
+
+    return phandle++;
+}
+
 int qemu_devtree_nop_node(void *fdt, const char *node_path)
 {
     int r;
index 5f76f40eeb716c00fe66b439f46f2d5a035974cb..97af3454f7eb95fdef6d4e854061de6eec0aaf40 100644 (file)
@@ -27,6 +27,7 @@ int qemu_devtree_setprop_phandle(void *fdt, const char *node_path,
                                  const char *property,
                                  const char *target_node_path);
 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);