From patchwork Tue Sep 20 23:24:34 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Timur Tabi X-Patchwork-Id: 115648 X-Patchwork-Delegate: vanbaren@cideas.com 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 66FBAB6F7B for ; Wed, 21 Sep 2011 09:25:27 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 64CA3282C2; Wed, 21 Sep 2011 01:25:25 +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 IS1GiZXboNgO; Wed, 21 Sep 2011 01:25:25 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 57803282A8; Wed, 21 Sep 2011 01:25:23 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 0C81928295 for ; Wed, 21 Sep 2011 01:25:21 +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 iP6ZXX0d5SvA for ; Wed, 21 Sep 2011 01:25:20 +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 DB3EHSOBE004.bigfish.com (db3ehsobe004.messaging.microsoft.com [213.199.154.142]) by theia.denx.de (Postfix) with ESMTPS id 9C0EB282B3 for ; Wed, 21 Sep 2011 01:25:14 +0200 (CEST) Received: from mail68-db3-R.bigfish.com (10.3.81.250) by DB3EHSOBE004.bigfish.com (10.3.84.24) with Microsoft SMTP Server id 14.1.225.22; Tue, 20 Sep 2011 23:25:13 +0000 Received: from mail68-db3 (localhost.localdomain [127.0.0.1]) by mail68-db3-R.bigfish.com (Postfix) with ESMTP id 16CDEB804CA; Tue, 20 Sep 2011 23:25:13 +0000 (UTC) X-SpamScore: 0 X-BigFish: VS0(zzzz1202hzz8275bhz2dh2a8h668h839h) X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null); IPVD:NLI; H:mail.freescale.net; RD:none; EFVD:NLI X-FB-SS: 13, Received: from mail68-db3 (localhost.localdomain [127.0.0.1]) by mail68-db3 (MessageSwitch) id 1316561081543451_22980; Tue, 20 Sep 2011 23:24:41 +0000 (UTC) Received: from DB3EHSMHS018.bigfish.com (unknown [10.3.81.248]) by mail68-db3.bigfish.com (Postfix) with ESMTP id 25E26258052; Tue, 20 Sep 2011 23:24:39 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by DB3EHSMHS018.bigfish.com (10.3.87.118) with Microsoft SMTP Server (TLS) id 14.1.225.22; Tue, 20 Sep 2011 23:24:39 +0000 Received: from az33smr02.freescale.net (10.64.34.200) by 039-SN1MMR1-003.039d.mgd.msft.net (10.84.1.16) with Microsoft SMTP Server id 14.1.323.7; Tue, 20 Sep 2011 18:24:37 -0500 Received: from linux.am.freescale.net ([10.214.81.78]) by az33smr02.freescale.net (8.13.1/8.13.0) with ESMTP id p8KNOa3r024391; Tue, 20 Sep 2011 18:24:36 -0500 (CDT) From: Timur Tabi To: , , Date: Tue, 20 Sep 2011 18:24:34 -0500 Message-ID: <1316561076-24923-1-git-send-email-timur@freescale.com> X-Mailer: git-send-email 1.7.4.4 MIME-Version: 1.0 X-OriginatorOrg: freescale.com Subject: [U-Boot] [PATCH 1/3] fdt: check for fdt errors in fdt_create_phandle 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: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de fdt_create_phandle() was ignoring errors from fdt_set_phandle(). If an error occurs, print an error message and return 0, which is an invalid phandle. We also need to change the return type for fdt_create_phandle() to indicate that it cannot return an error code. Signed-off-by: Timur Tabi --- common/fdt_support.c | 11 +++++++++-- include/fdt_support.h | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/common/fdt_support.c b/common/fdt_support.c index 46aa842..698abf7 100644 --- a/common/fdt_support.c +++ b/common/fdt_support.c @@ -1241,15 +1241,22 @@ int fdt_set_phandle(void *fdt, int nodeoffset, uint32_t phandle) * @fdt: ptr to device tree * @nodeoffset: node to update */ -int fdt_create_phandle(void *fdt, int nodeoffset) +unsigned 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) { + int ret; + phandle = fdt_alloc_phandle(fdt); - fdt_set_phandle(fdt, nodeoffset, phandle); + ret = fdt_set_phandle(fdt, nodeoffset, phandle); + if (ret < 0) { + printf("Can't set phandle %u: %s\n", phandle, + fdt_strerror(ret)); + return 0; + } } return phandle; diff --git a/include/fdt_support.h b/include/fdt_support.h index 8f06aac..7206c56 100644 --- a/include/fdt_support.h +++ b/include/fdt_support.h @@ -90,7 +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); +unsigned 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,