From patchwork Mon Aug 1 06:23:01 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kumar Gala X-Patchwork-Id: 107665 X-Patchwork-Delegate: galak@kernel.crashing.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 94EABB702E for ; Mon, 1 Aug 2011 16:23:23 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id DD3C128149; Mon, 1 Aug 2011 08:23:17 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id XerMAPqs0eHY; Mon, 1 Aug 2011 08:23:17 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 921432813D; Mon, 1 Aug 2011 08:23:12 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 62DC72813D for ; Mon, 1 Aug 2011 08:23:09 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Y98Hmy1JVEip for ; Mon, 1 Aug 2011 08:23:08 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from gate.crashing.org (gate.crashing.org [63.228.1.57]) by theia.denx.de (Postfix) with ESMTPS id 1EE2328148 for ; Mon, 1 Aug 2011 08:23:07 +0200 (CEST) Received: from localhost (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.13.8) with ESMTP id p716N25h012957; Mon, 1 Aug 2011 01:23:03 -0500 From: Kumar Gala To: u-boot@lists.denx.de Date: Mon, 1 Aug 2011 01:23:01 -0500 Message-Id: <1312179781-27813-3-git-send-email-galak@kernel.crashing.org> X-Mailer: git-send-email 1.5.6.5 In-Reply-To: <1312179781-27813-2-git-send-email-galak@kernel.crashing.org> References: <1312179781-27813-1-git-send-email-galak@kernel.crashing.org> <1312179781-27813-2-git-send-email-galak@kernel.crashing.org> Subject: [U-Boot] [PATCH 2/2] fdt: Add new fdt_create_phandle helper X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Add a helper function that will return a phandle value for the given node. If the node doesn't have a phandle already one will be created. Signed-off-by: Kumar Gala Acked-by: Gerald Van Baren --- common/fdt_support.c | 20 ++++++++++++++++++++ include/fdt_support.h | 1 + 2 files changed, 21 insertions(+), 0 deletions(-) diff --git a/common/fdt_support.c b/common/fdt_support.c index 8f7323d..46aa842 100644 --- a/common/fdt_support.c +++ b/common/fdt_support.c @@ -1235,6 +1235,26 @@ int fdt_set_phandle(void *fdt, int nodeoffset, uint32_t phandle) return ret; } +/* + * fdt_create_phandle: Create a phandle property for the given node + * + * @fdt: ptr to device tree + * @nodeoffset: node to update + */ +int fdt_create_phandle(void *fdt, int nodeoffset) +{ + /* see if there is a phandle already */ + int phandle = fdt_get_phandle(fdt, nodeoffset); + + /* if we got 0, means no phandle so create one */ + if (phandle == 0) { + phandle = fdt_alloc_phandle(fdt); + fdt_set_phandle(fdt, nodeoffset, phandle); + } + + return phandle; +} + #if defined(CONFIG_VIDEO) int fdt_add_edid(void *blob, const char *compat, unsigned char *edid_buf) { diff --git a/include/fdt_support.h b/include/fdt_support.h index fdb9307..8f06aac 100644 --- a/include/fdt_support.h +++ b/include/fdt_support.h @@ -90,6 +90,7 @@ int fdt_node_offset_by_compat_reg(void *blob, const char *compat, phys_addr_t compat_off); int fdt_alloc_phandle(void *blob); int fdt_set_phandle(void *fdt, int nodeoffset, uint32_t phandle); +int fdt_create_phandle(void *fdt, int nodeoffset); int fdt_add_edid(void *blob, const char *compat, unsigned char *buf); int fdt_verify_alias_address(void *fdt, int anode, const char *alias,