From patchwork Wed Jan 6 21:01:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lev Iserovich X-Patchwork-Id: 564190 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 B09821402F0 for ; Thu, 7 Jan 2016 18:44:25 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id BC01C4B8E8; Thu, 7 Jan 2016 08:44:23 +0100 (CET) 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 N_56HhZ3gnlQ; Thu, 7 Jan 2016 08:44:23 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id F22374B8BB; Thu, 7 Jan 2016 08:44:22 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 5F5794B92C for ; Wed, 6 Jan 2016 22:28:23 +0100 (CET) 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 9g0dJie-qKLG for ; Wed, 6 Jan 2016 22:28:23 +0100 (CET) X-Greylist: delayed 1529 seconds by postgrey-1.34 at theia; Wed, 06 Jan 2016 22:28:18 CET 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 drdwsfe1.nyc.desres.deshaw.com (nyvpn.deshawresearch.com [38.109.87.242]) by theia.denx.de (Postfix) with ESMTP id 0E43E4B926 for ; Wed, 6 Jan 2016 22:28:18 +0100 (CET) Received: from drdws0019.nyc.desres.deshaw.com (drdws0019.nyc.desres.deshaw.com [149.77.52.116]) by drdwsfe1.nyc.desres.deshaw.com (Postfix) with SMTP id E837EEAA1F; Wed, 6 Jan 2016 16:02:48 -0500 (EST) Received: (nullmailer pid 12204 invoked by uid 11825); Wed, 06 Jan 2016 21:02:48 -0000 From: Lev Iserovich To: u-boot@lists.denx.de Date: Wed, 6 Jan 2016 16:01:58 -0500 Message-Id: <1452114118-11100-1-git-send-email-iserovil@deshawresearch.com> X-Mailer: git-send-email 2.1.0 X-Mailman-Approved-At: Thu, 07 Jan 2016 08:44:20 +0100 Cc: Andre Przywara , Lev Iserovich , Scott Wood Subject: [U-Boot] [PATCH] fdt: fix setting MAC addresses for multiple interfaces X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" For multiple ethernet interfaces the FDT offset of '/aliases' will change as we are adding MAC addresses to the FDT. Therefore only the first interface ('ethernet0') will get properly updated in the FDT, with the rest getting FDT errors when we try to set their MAC address. Switch to using fdt_get_alias() which is the proper way to get the FDT path. Signed-off-by: Lev Iserovich --- common/fdt_support.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/common/fdt_support.c b/common/fdt_support.c index 66464db..20e0e1c 100644 --- a/common/fdt_support.c +++ b/common/fdt_support.c @@ -481,16 +481,12 @@ int fdt_fixup_memory(void *blob, u64 start, u64 size) void fdt_fixup_ethernet(void *fdt) { - int node, i, j; + int i, j; char enet[16], *tmp, *end; char mac[16]; const char *path; unsigned char mac_addr[6]; - node = fdt_path_offset(fdt, "/aliases"); - if (node < 0) - return; - if (!getenv("ethaddr")) { if (getenv("usbethaddr")) { strcpy(mac, "usbethaddr"); @@ -505,7 +501,7 @@ void fdt_fixup_ethernet(void *fdt) i = 0; while ((tmp = getenv(mac)) != NULL) { sprintf(enet, "ethernet%d", i); - path = fdt_getprop(fdt, node, enet, NULL); + path = fdt_get_alias(fdt, enet); if (!path) { debug("No alias for %s\n", enet); sprintf(mac, "eth%daddr", ++i);