From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:47193) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ScIeu-0002Os-QS for qemu-devel@nongnu.org; Wed, 06 Jun 2012 12:00:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ScIeo-00040Q-5w for qemu-devel@nongnu.org; Wed, 06 Jun 2012 12:00:32 -0400 Message-ID: <4FCF7E92.4060207@suse.de> Date: Wed, 06 Jun 2012 18:00:18 +0200 From: Alexander Graf MIME-Version: 1.0 References: <1338940402-28502-1-git-send-email-agraf@suse.de> <1338940402-28502-8-git-send-email-agraf@suse.de> <1338959908.15420.17.camel@PetaLogix-ws2> In-Reply-To: <1338959908.15420.17.camel@PetaLogix-ws2> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 07/31] dt: add helper for phandle allocation List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Crosthwaite Cc: Scott Wood , qemu-ppc Mailing List , "qemu-devel@nongnu.org Developers" On 06/06/2012 07:18 AM, Peter Crosthwaite wrote: > 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 >> --- >> 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++; That's a nice one. It'd even allow us to drop the external phandle starting id patch. Scott, would this work for you? Alex