Skip to content

Commit

Permalink
dt: add helper for phandle allocation
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
agraf committed Jun 23, 2012
1 parent ce36252 commit 3601b57
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions device_tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions device_tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 3601b57

Please sign in to comment.