From patchwork Sat Oct 9 17:33:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 1538837 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=gc1HBA4H; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HRXKF5ydRz9sPf for ; Sun, 10 Oct 2021 04:36:01 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B44D583698; Sat, 9 Oct 2021 19:34:50 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="gc1HBA4H"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DE45083683; Sat, 9 Oct 2021 19:34:25 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 1E614836A2 for ; Sat, 9 Oct 2021 19:34:01 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=kabel@kernel.org Received: by mail.kernel.org (Postfix) with ESMTPSA id AE87661055; Sat, 9 Oct 2021 17:34:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1633800841; bh=tHnApqk4OKnVjU5TZymYTiBfVWVK7qdX5+YZ7tLMqkU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gc1HBA4H0aUQNPh1B3/2tGil1mkf+Uxy74ow4pXjJLHzdIagCT5d3155z7/EN0uuN 9sr5XCd+djQ1RexN+Yif3pFLitHmkM4N8y0PJ46TUFuaQAopjLXVGpn7VOEaR3Krat aq1mTH6NE+1W+DsGnmp255hz+qEeQzs7wOdGkDseJOJqu42S6u5K1o1vj9eLLI8mQd rgYMRNerxeFYsFLii/CYnv82jCQDIDKNZTl2grFVbuEm01OjLlIN6l3rrBjmUt0sX2 o7p7k2fZC/SxX5Ckuyiec0U0rRP1eSt8Oh6/IZDtVZ4rnX23FKXqfHE37roqljgEh2 NtsjHYRudeudQ== From: =?utf-8?q?Marek_Beh=C3=BAn?= To: Stefan Roese Cc: u-boot@lists.denx.de, pali@kernel.org, =?utf-8?q?Marek_Beh=C3=BAn?= Subject: [PATCH u-boot-marvell 09/12] arm: mvebu: turris_omnia: Overwrite ethaddr only if invalid Date: Sat, 9 Oct 2021 19:33:43 +0200 Message-Id: <20211009173346.7859-10-kabel@kernel.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211009173346.7859-1-kabel@kernel.org> References: <20211009173346.7859-1-kabel@kernel.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean From: Marek BehĂșn Currently we always overwrite ethaddrs with those from EEPROM. In order to allow user to use a cloned MAC address in U-Boot, change the code so that it sets ethaddr variables only if they aren't set or are invalid. Signed-off-by: Marek BehĂșn Reviewed-by: Stefan Roese --- board/CZ.NIC/turris_omnia/turris_omnia.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/board/CZ.NIC/turris_omnia/turris_omnia.c b/board/CZ.NIC/turris_omnia/turris_omnia.c index a48e1f5c30..7a86111890 100644 --- a/board/CZ.NIC/turris_omnia/turris_omnia.c +++ b/board/CZ.NIC/turris_omnia/turris_omnia.c @@ -518,6 +518,15 @@ static void increment_mac(u8 *mac) } } +static void set_mac_if_invalid(int i, u8 *mac) +{ + u8 oldmac[6]; + + if (is_valid_ethaddr(mac) && + !eth_env_get_enetaddr_by_index("eth", i, oldmac)) + eth_env_set_enetaddr_by_index("eth", i, mac); +} + int misc_init_r(void) { int err; @@ -550,18 +559,11 @@ int misc_init_r(void) mac[4] = mac1[2]; mac[5] = mac1[3]; - if (is_valid_ethaddr(mac)) - eth_env_set_enetaddr("eth1addr", mac); - + set_mac_if_invalid(1, mac); increment_mac(mac); - - if (is_valid_ethaddr(mac)) - eth_env_set_enetaddr("eth2addr", mac); - + set_mac_if_invalid(2, mac); increment_mac(mac); - - if (is_valid_ethaddr(mac)) - eth_env_set_enetaddr("ethaddr", mac); + set_mac_if_invalid(0, mac); out: return 0;