From 3601b572820ee5f3676ab24c068a4e011b72236d Mon Sep 17 00:00:00 2001 From: Alexander Graf Date: Thu, 17 May 2012 16:58:55 +0200 Subject: dt: add helper for phandle allocation 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 --- device_tree.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'device_tree.c') diff --git a/device_tree.c b/device_tree.c index d0378961f0..75412747b7 100644 --- a/device_tree.c +++ b/device_tree.c @@ -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; -- cgit v1.2.1