From patchwork Mon Apr 10 15:33:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olliver Schinagl X-Patchwork-Id: 749089 X-Patchwork-Delegate: joe.hershberger@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3w1vXH0NT6z9sNj for ; Tue, 11 Apr 2017 01:40:31 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=schinagl.nl header.i=@schinagl.nl header.b="M4JBrRss"; dkim-atps=neutral Received: by lists.denx.de (Postfix, from userid 105) id B4CD3C21C63; Mon, 10 Apr 2017 15:37:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=KHOP_BIG_TO_CC, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id B502BC21C8D; Mon, 10 Apr 2017 15:34:50 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 4388AC21C33; Mon, 10 Apr 2017 15:34:14 +0000 (UTC) Received: from 7of9.schinagl.nl (7of9.schinagl.nl [62.251.20.244]) by lists.denx.de (Postfix) with ESMTPS id EB60EC21C26 for ; Mon, 10 Apr 2017 15:34:13 +0000 (UTC) Received: from um-mbp-306.cloud.ultimaker.com (static-98-101-100-159.thenetworkfactory.nl [159.100.101.98]) by 7of9.schinagl.nl (Postfix) with ESMTPA id C48CEAC88E; Mon, 10 Apr 2017 17:34:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=schinagl.nl; s=7of9; t=1491838450; bh=c8GaNaDM3ppkmdqJWeOtLmwMdrMMoZQY6w9DCUbGZXE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=M4JBrRss9GBs+r+nkEnYiwtgpVWUdwA+maBtChzoZn/pXSKR1pt0WIRzJ/j6h5LfG RU98WBeHP+8qH8eJaaEmUMmjt+MGJvzeHB7dda+ypC+ZtS1jTcfcW60hZco7RgB4/J fV7w23Kgl2xllyhJEi07bC8TekPXdsAGpJqEEROM= From: Olliver Schinagl To: Jagan Teki , Maxime Ripard , Simon Glass , Joe Hershberger Date: Mon, 10 Apr 2017 17:33:43 +0200 Message-Id: <20170410153356.2664-9-oliver@schinagl.nl> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170410153356.2664-1-oliver@schinagl.nl> References: <20170410153356.2664-1-oliver@schinagl.nl> X-Mailman-Approved-At: Mon, 10 Apr 2017 15:34:41 +0000 Cc: Mugunthan V N , Marcus Cooper , Philipp Tomsich , Stefan Roese , u-boot@lists.denx.de, Aleksei Mamlin , Ian Campbell , Bernhard Nortmann , dev@linux-sunxi.org, Andre Przywara , Phil Han , Hans de Goede , Zoltan Herpai , Olliver Schinagl , Jelle de Jong Subject: [U-Boot] [PATCHv2 08/21] fdt: fixup_eth: Remove code duplication with a function X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 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" In fdt_support.c we use a loop to parse the mac address string from the fdt blob, net.h has a function for this however, so lets use it. Also, rename the variable from tmp to something more descriptive. Signed-off-by: Olliver Schinagl --- common/fdt_support.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/common/fdt_support.c b/common/fdt_support.c index d462bf0642..4d05465232 100644 --- a/common/fdt_support.c +++ b/common/fdt_support.c @@ -469,8 +469,8 @@ int fdt_fixup_memory(void *blob, u64 start, u64 size) void fdt_fixup_ethernet(void *fdt) { - int i, j, prop; - char *tmp, *end; + int i, prop; + char *fdt_eth_addr; char mac[ETH_ENETADDR_ENV_NAME_LEN]; const char *path; unsigned char mac_addr[ARP_HLEN]; @@ -509,16 +509,11 @@ void fdt_fixup_ethernet(void *fdt) } else { continue; } - tmp = getenv(mac); - if (!tmp) + fdt_eth_addr = getenv(mac); + if (!fdt_eth_addr) continue; - for (j = 0; j < 6; j++) { - mac_addr[j] = tmp ? - simple_strtoul(tmp, &end, 16) : 0; - if (tmp) - tmp = (*end) ? end + 1 : end; - } + eth_parse_enetaddr(fdt_eth_addr, mac_addr); do_fixup_by_path(fdt, path, "mac-address", &mac_addr, 6, 0);