From patchwork Sat Jun 23 23:06:57 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 166823 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 13AC6B6F9F for ; Sun, 24 Jun 2012 10:59:50 +1000 (EST) Received: from localhost ([::1]:57275 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SiZTn-0003Mi-Sk for incoming@patchwork.ozlabs.org; Sat, 23 Jun 2012 19:10:59 -0400 Received: from eggs.gnu.org ([208.118.235.92]:38114) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SiZR7-0007p6-3D for qemu-devel@nongnu.org; Sat, 23 Jun 2012 19:08:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SiZR1-0002NK-K6 for qemu-devel@nongnu.org; Sat, 23 Jun 2012 19:08:12 -0400 Received: from cantor2.suse.de ([195.135.220.15]:34875 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SiZR1-0002ML-C2; Sat, 23 Jun 2012 19:08:07 -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 1AB8DA3ABA; Sun, 24 Jun 2012 01:08:06 +0200 (CEST) From: Alexander Graf To: qemu-devel qemu-devel Date: Sun, 24 Jun 2012 01:06:57 +0200 Message-Id: <1340492856-21126-34-git-send-email-agraf@suse.de> X-Mailer: git-send-email 1.6.0.2 In-Reply-To: <1340492856-21126-1-git-send-email-agraf@suse.de> References: <1340492856-21126-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: Blue Swirl , qemu-ppc Mailing List , Aurelien Jarno Subject: [Qemu-devel] [PATCH 33/72] 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 Reviewed-by: Peter Crosthwaite --- device_tree.c | 8 ++++++++ device_tree.h | 3 +++ 2 files changed, 11 insertions(+), 0 deletions(-) diff --git a/device_tree.c b/device_tree.c index 94a239e..2905f9a 100644 --- a/device_tree.c +++ b/device_tree.c @@ -132,6 +132,14 @@ 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 *target_node_path) +{ + uint32_t phandle = fdt_get_phandle(fdt, findnode_nofail(fdt, target_node_path)); + 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 1e671e2..754bd2b 100644 --- a/device_tree.h +++ b/device_tree.h @@ -22,6 +22,9 @@ int qemu_devtree_setprop_cell(void *fdt, const char *node_path, const char *property, uint32_t val); 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 *target_node_path); int qemu_devtree_nop_node(void *fdt, const char *node_path); int qemu_devtree_add_subnode(void *fdt, const char *name);