From patchwork Tue Jun 5 23:52:54 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 163218 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id D273CB6EF3 for ; Wed, 6 Jun 2012 11:25:20 +1000 (EST) Received: from localhost ([::1]:49060 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sc3eK-0006lJ-Uz for incoming@patchwork.ozlabs.org; Tue, 05 Jun 2012 19:58:56 -0400 Received: from eggs.gnu.org ([208.118.235.92]:53065) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sc3ct-0003vb-JW for qemu-devel@nongnu.org; Tue, 05 Jun 2012 19:58:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Sc3Z4-0002Ps-BH for qemu-devel@nongnu.org; Tue, 05 Jun 2012 19:57:27 -0400 Received: from cantor2.suse.de ([195.135.220.15]:36430 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sc3Z4-0002P4-4x; Tue, 05 Jun 2012 19:53:30 -0400 Received: from relay2.suse.de (unknown [195.135.220.254]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id 9F8D5A30B8; Wed, 6 Jun 2012 01:53:28 +0200 (CEST) From: Alexander Graf To: "qemu-devel@nongnu.org Developers" Date: Wed, 6 Jun 2012 01:52:54 +0200 Message-Id: <1338940402-28502-4-git-send-email-agraf@suse.de> X-Mailer: git-send-email 1.6.0.2 In-Reply-To: <1338940402-28502-1-git-send-email-agraf@suse.de> References: <1338940402-28502-1-git-send-email-agraf@suse.de> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6 X-Received-From: 195.135.220.15 Cc: qemu-ppc Mailing List Subject: [Qemu-devel] [PATCH 03/31] dt: add helper for phandle references X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Phandles are the fancy device tree name for "pointer to another node". To create a phandle property, we most likely want to reference to the node we're pointing to by its path. So create a helper that allows us to do so. Signed-off-by: Alexander Graf --- device_tree.c | 7 +++++++ device_tree.h | 2 ++ 2 files changed, 9 insertions(+), 0 deletions(-) diff --git a/device_tree.c b/device_tree.c index b1dff4f..8e9262c 100644 --- a/device_tree.c +++ b/device_tree.c @@ -162,6 +162,13 @@ int qemu_devtree_setprop_string(void *fdt, const char *node_path, return r; } +int qemu_devtree_setprop_phandle(void *fdt, const char *node_path, + const char *property, const char *string) +{ + uint32_t phandle = fdt_get_phandle(fdt, findnode_nofail(fdt, string)); + return qemu_devtree_setprop_cell(fdt, node_path, property, 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 9db7f86..2e87c58 100644 --- a/device_tree.h +++ b/device_tree.h @@ -31,6 +31,8 @@ int qemu_devtree_setprop_cell4(void *fdt, const char *node_path, uint32_t val2, uint32_t val3, uint32_t val4); int qemu_devtree_setprop_string(void *fdt, const char *node_path, const char *property, const char *string); +int qemu_devtree_setprop_phandle(void *fdt, const char *node_path, + const char *property, const char *string); int qemu_devtree_nop_node(void *fdt, const char *node_path); int qemu_devtree_add_subnode(void *fdt, const char *name);